Save file format?

xminator

Chieftain
Joined
Sep 24, 2010
Messages
3
Is there a way to export the map from a specific save file? Including the fog of war?
 
Not really. The easiest way to access the data in a save game is load it into the game. I assume you ask such a question because you want access to the data outside the game. You can use UI.setClipboardText() to move data out of the game. You could do an array of the rows each with an array of the columns with each those an array of attributes of interest. I would recommend against using key/value pairs which increases readability of the raw data, but drastically increases the size. Certainly use key/value pairs at map or game level if for no other reason than to make it easy to tell what the file is when you open it. Stick in there an array giving names to the indexes you used for the tile information. With YnAMP's Ludicrous there's over 26K tiles. Maybe extract the decode values for types too. You might as well have everything needed to decode the file in the file. You have to paste it into something then save it. After that you can use it with anything that supports JSON. The JSON site lists 60+ and there's likely even more.

If you're really OCD and insist it has to be reading the save game file then I'll give you some idea what you have to do. I'll use a simple example, changing the gold. You record the amount of gold you have when you save the game. You don't know the format it's saved in. It could be fixed point, it could be floating point, it could be a string. You then use a cheat to give yourself more gold. Save that then compare the two. The only real change is the gold. It might have the date/time in there and other stuff that changes between the two saves. So you have to look at every change and try to guess which was the gold. Apps like ImHex will decode various formats all at once. Basically the same process for the map. Basically, but a whole lot more complicated because it's an array. If the rows and cols are fixed length you need 4 save games to figure out their length. If they're variable length you're going to need at least 6. The file is read from start to end and going backwards through an array with variable length cols is far harder than forwards. So you likely need to change just the first cell to figure out how to get to the to the beginning of the array. Hopefully they used tags so they can validate the file as they read it. The map is suppose to start here, did I read the right tag for the map. Element tag/length is easy to decode. It's in hex but basically the same as HTML, XML, etc. If they didn't use tags then you just have lengths, hopefully. You're going far down the rabbit hole for little reason. Just load the game and use the game functions to access the data.
 
You could create a custom map with a specific pattern to make it simpler to "reverse engineer" the map save format, though.
Good idea. You could customize the tiles on the top and bottom rows so that you know the length of the pattern and look for that many repetitions in the save file. Then you can look and see if there is a pattern that the engine creates just before or after the map data.
 
Back
Top Bottom