Author Topic: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)  (Read 7863 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« on: July 22, 2017, 09:25:07 PM »
OP2 Map Imager is a Windows Console application that can render any Outpost 2 map in popular image formats and variable size. Programmed by me and Hooman in C++.

Directions
  • Download and unzip.
  • Recommend placing OP2MapImager and associated files in the root install directory of Outpost 2 to ease working with relative paths, but it should work from any directory.
  • Open the command prompt, navigate to the folder containing OP2MapImager.exe, and type “OP2MapImager -h” to get the usage message.
  • Use the Mission Scanner to find the filename of your favorite maps.
  • Renders will default to a relative directory from the executable of \MapRenders and have a scale factor of 4.

Current Release: 2.1.0
Download Current Release https://github.com/OutpostUniverse/OP2MapImager/releases/

Possible Future Improvements:
  • Ability to parse native OP2 BMP tile sets.
  • Find an image manipulation library that has a license closer to the MIT license.

If you have any comments, bugs concerns, suggestions, whatever else, please post or message me or Hooman.




Readme

OP2MapImager - Outpost 2 Map and Saved Game Imager
Developed by Hooman and Brett208 (Vagabond)

Check the OP2MapImager landing page for the newest version at https://wiki.outpost2.net/doku.php?id=outpost_2:helper_programs:op2mapimager.

+++ USAGE NOTES +++
  * Capable of saving multiple map files and entire directories.
  * The OP2MapImager executable and FreeImage.dll must be in the same directory as the tileset BMPs.
  * Scale Factor (-s) determines the final render size and represents the final pixel length of a single tile
    * Max Value: 32, renders at full size, or 32 pixels per tile.
    * Min Value: 1, renders at 1 pixel per tile

+++ EXAMPLE COMMANDS +++
  * OP2MapImager mapFilename.[map|OP2]
  * OP2MapImager -s 16 -o -q Ashes.map eden01.map sgame0.op2
  * OP2MapImager --Scale 8 --ImageFormat BMP [Directory of choice]

+++ OPTIONAL ARGUMENTS +++
  -H / --Help: Displays Help File
  -Q / --Quiet: [Default false] Add switch to run application without issuing console messages.
  -O / --Overwrite: [Default false] Add switch to allow application to overwrite existing files.
  -D / --DestinationDirectory: [Default MapRenders]. Add switch and name of new destination path.
  -I / --ImageFormat: [Default PNG]. Allows PNG|JPG|BMP. Sets the image format of the final render.
  -S / --Scale: [Default 4] Sets Scale Factor of image.
  -A / --AccessArchives [Default true]. Add switch to disable searching VOL archives for map and well files.

For more information about Outpost 2 visit the Outpost Universe (http://outpost2.net/).
Image Manipulation accomplished through FreeImage (http://freeimage.sourceforge.net/).


+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +


+++ INSTALL DIRECTIONS +++

Ensure OP2MapImager.exe and FreeImage.dll are in the same directory. They can be placed in the root OP2 install directory for ease of install and use. Advanced users may want to establish an environment variable to allow application's use in any directory.

Open a command prompt. Navigate to the directory with OP2MapImager.exe and type 'OP2MapImager -h' to see Usage Message.


+++ OUTPOST 2 TILESETS (WELL00XX.BMP) +++

The original tileset images (Wells) shipped with Outpost 2 use a special format that prevents them from being opened by typical pixel image manipulation software (like Gimp or Paint). If you attempt to render a map using the original Outpost 2 tileset images, OP2MapImager will throw an error. The current released version of Outpost 2 contains normally formatted tilesets and will not cause issues with OP2MapImager.

The tilesets (wells) must exist in the same directory as the map(s) chosen to render. The map and the tilesets may remain archived in their volume files for rendering as OP2MapImager is able to access volume files. OP2MapImager will first search for files loosely in the directory and then in the volume files alphabetically if the file does not exist loosely. Archive search may be disabled using the AccessArchives flag.


+++ SOURCE CODE LOCATION AND COMPILIATION +++

Source code may be found at: https://github.com/OutpostUniverse/OP2MapImager. See the file DeveloperReadMe.txt in the source code for specific instructions.


+++ Change Log +++

Ver 2.1.0
 * Remove Windows specific dependencies from code base (may now be compiled for use on Linux).
 * Allow compiling on both x86 (win32) and x64.
 * Allow accessing tilesets (wells) without removing them from archive files.
 * Bug Fix: Multiple directory search problems preventing OP2MapImager from finding tilesets or maps.
 * Bug Fix: Program crash when unable to find map file.

Ver 2.0.1 (07Nov2017)
  * Fixed security concern when outputting error messages from FreeImage.
  * Fixed bug not allowing rendering of loose maps in current working directory.
  * Reordered change log to be newest version first.
  * Added PDB file zipping to post build event script.

Ver 2.0.0 (12Oct2017)
  * Fixed crash if supplying an empty variable ("") for a command via the command prompt.
  * Changed method to provide current directory to use either '.' or './' instead of '/' or '\'.
  * Made the function XFile::replaceFilename platform agnostic.
  * Fixed typos in ReadMe.txt.
  * Removed namespace using statements from header files.
  * Removed Microsoft specific exception classes.
  * Removed Microsoft specific for each loops and replaced with C++ standard range loops.
  * Fixed crashing bug when attempting to render a map outside of the application's current working directory.

Ver 1.0.1 (23Jul2017)
 * Prevented creation of multiple renders of the same map if the map exists in multiple places in the same directory (IE both loosely in directory and in an archive).
 * When imaging all maps & saved games in a directory, prevented selection of wellpallet.map and SGAME10.OP2 since they are not valid maps.
 * Fixed typos in ReadMe.
 * Added Changelog.

Ver 1.0.0 (22Jul2017)
 * Initial Release
« Last Edit: August 24, 2019, 09:11:13 PM by Vagabond »

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #1 on: July 24, 2017, 11:01:30 PM »
I'm already releasing version 1.0.1 of the OP2MapImager.

While reveling in the enjoyment of using the finished product, I realized when rendering all maps in the directory, it would crash by trying to render SGAME10.OP2 (which really isn't a saved game at all). A few other bugs were also cleaned up. The new download is available on the first post of this thread.

Ver 1.0.1 (23Jul2017) Change Log
 * Prevented creation of multiple renders of the same map if the map exists in multiple places in the same directory (IE both loosely in directory and in an archive).
 * When imaging all maps & saved games in a directory, prevented selection of wellpallet.map and SGAME10.OP2 since they are not valid maps.
 * Fixed typos in ReadMe.
 * Added Changelog.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #2 on: July 24, 2017, 11:17:08 PM »
Dontcha just love finding those kinds of bugs?  ::)

Anyway, I failed to mention it earlier. This is awesome. Your work is appreciated!

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #3 on: July 25, 2017, 06:32:18 AM »
Indeed. You did a really nice job of pushing his through to completion.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #4 on: July 25, 2017, 10:28:39 AM »
Question:

Will it also output an image of the map, after all the volcanoes have blown up and released their lava to their predetermined spots?
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #5 on: July 25, 2017, 01:31:55 PM »
It supports reading maps from saved game files, so yes, it should show that if you have a saved game file from the right point in time.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #6 on: July 25, 2017, 04:01:39 PM »
Quote
Will it also output an image of the map, after all the volcanoes have blown up and released their lava to their predetermined spots?

Quote
It supports reading maps from saved game files, so yes, it should show that if you have a saved game file from the right point in time.

Exactly, the mapImager will render lava. Anything represented by a tile from the well tile sheets will be displayed on the save game renders.

So you will get rubble, walls, tubes, bulldozed ground, scorch marks, and lava.

You will not get any graphic not represented by a well tile sheet. So no buildings, mining beacons, vehicles, natural disasters, etc.

Check out the attached file for an example (need to be logged into the forum to see it). I just played about 10 minutes of the colony game Eden Starship and saved. It will show how lava, bulldozed tiles, tubes, rubble, etc will appear.



Side Note:
I noticed all the map images attached to a saved game are represented by 1 pixel per tile renders. If the tile is a building/unit of a player, the pixel representing the root location of the building/unit is filled in with that player's color. If it is a mining beacon, the space is filled in with a white pixel.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #7 on: October 12, 2017, 01:04:29 PM »
I just posted version 2.0.0 of the OP2MapImager. This is version 2 since the way relative directories are handled has been switched to using the . or ./ syntax. (It was just / earlier), which is a breaking change.

See below for full list of changes.

As always, if anyone encounters any bugs or wants to just post about their experience with the application, I am happy to hear about it.

Ver 2.0.0 (12Oct2017)
  * Fixed crash if supplying an empty variable ("") for a command via the command prompt.
  * Changed method to provide current directory to use either '.' or './' instead of '/' or '\'.
  * Made the function XFile::replaceFilename platform agnostic.
  * Fixed typos in ReadMe.txt.
  * Removed namespace using statements from header files.
  * Removed Microsoft specific exception classes.
  * Removed Microsoft specific for each loops and replaced with C++ standard range loops.
  * Fixed crashing bug when attempting to render a map outside of the application's current working directory.


-Brett

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #8 on: December 01, 2017, 01:24:34 PM »
I just compiled and released version 2.0.1 of OP2MapImager. It includes bugfixes only and no new features. Thanks to Hooman for making a small security fix to the program and cleaning a little on the OP2Utility project.

We are switching the release location for OP2MapImager to GitHub instead of the Outpost 2 wiki. You can find the newest releases at https://github.com/OutpostUniverse/OP2MapImager/releases.

Also, I'm now listing the PDB file for OP2MapImager with each release. If you encounter a bug and wish to debug on your own, you can use the PDB file to load full symbols into Visual Studio. This will allow you to step through the application, set breakpoints, variable watches, etc, without having to worry about download the repository and getting it to compile.

Let me know if anyone is using the OP2MapImager with success or with problems/suggestions.

Ver 2.0.1 (01Dec2017)
 
 * Fixed security concern when outputting error messages from FreeImage.
 * Fixed bug not allowing rendering of loose maps in current working directory.
 * Reordered change log to be newest version first.
 * Added PDB file zipping to post build event script.

Thanks,
-Brett

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #9 on: December 05, 2017, 03:06:13 PM »
Very nice!

I would just add a link from the wiki to the project release page if it hasn't already been done.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #10 on: December 05, 2017, 06:39:26 PM »
leeor,

Thanks,

The wiki page has already been updated as you suggested. OP2Archive also points to GitHub for newer release copies.

https://wiki.outpost2.net/doku.php?id=outpost_2:helper_programs:map_imager

-Brett

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #11 on: August 24, 2019, 09:14:52 PM »
Finally, after a really long time, we are releasing the next build of OP2MapImager. This version interacts seemlessly with files stored in volumes, can be compiled on Linux, and fixes a lot of directory bugs. For my part, I have completed what the tool was set out to do unless someone discovers bugs or needs a new feature added.

Use the link in the first post to the GitHub release section to download and use. Feedback is very welcome.

Version 2.1.0

 * Remove Windows specific dependencies from code base (may now be compiled for use on Linux).
 * Allow compiling on both x86 (win32) and x64.
 * Allow accessing tilesets (wells) without removing them from archive files.
 * Bug Fix: Multiple directory search problems preventing OP2MapImager from finding tilesets or maps.
 * Bug Fix: Program crash when unable to find map file.

Thanks,
Brett

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #12 on: August 25, 2019, 01:56:20 AM »
Hmm, I've got some good news and some bad news.

First the good news. I updated my repository, and easily built the code with a single make command. The code then ran flawlessly on a ../relative/path/to/outpost2Folder/ and produced a directory full of images below my current working directory. Great success.

The bad news, is that I realized my submodule was out of date (OP2Utility), and when I updated it and rebuilt, it failed to run as expected. The exact same command as above produced the error message:
Code: [Select]
No map file or save file found in the supplied directory.
Run without arguments to see usage message.


I tracked down with git reflog what my previous OP2Utility submodule was set to:
f125c4b62c682ecd2728a0d6deee10dbe34cb29d  (2019-04-01)  Merge pull request #289 from OutpostUniverse/cleanupMakefilePhonyRules

It works properly with the backdated submodule, but not with the current version.

It seems we broke something between then and now. A few of the changes are:
Prevent resource manager from returning directories
Fix creating new file in new directory
Allow empty volumes
Improve Palette Header construction
Zero-cost signed/unsigned negative check
Makefile cleanup

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #13 on: August 25, 2019, 02:24:16 AM »
I just ran a git bisect on the OP2Utility submodule. It identified the first bad commit as:
c4e4666fa2f94ddb3d0c01e40d8212356b9e1f8a  (2019-04-17)  Prevent Resource Manager From Returning Directories


Git bisect command:
Code: [Select]
git bisect start master f125c4b62c682ecd2728a0d6deee10dbe34cb29d
git bisect run sh -c "cd ..; make; ./OP2MapImager ../opu-git-svn/GameDownload/Outpost2/trunk/"

In the above, master is a known bad commit, while f125c... is a known good commit. As the bisect is being run from the submodule (OP2Utility), I must switch to the parent repository (OP2MapImager) before running the build (make), and trying to run the output. It bisected over the 47 commits in that range, and after an estimated 6 steps of building and running code, it narrowed the first bad commit down to c4e46.... It determined this based on the exit code from running OP2MapImager, which returns 0 on success and non-zero on failure.
« Last Edit: August 25, 2019, 02:26:27 AM by Hooman »

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: OP2 Map Imager (Variable scaled renders of Outpost 2 Maps)
« Reply #14 on: August 25, 2019, 12:29:44 PM »
I just tested by running `op2mapimager ../Outpost2/`. It was able to render the maps, so I think this is an issue isolated to the Linux build.

Maybe we need to beef up the unit tests on ResourceManager...