roofGrid / roofsDeflate (as pertains to save files)

Started by Renegrade, November 22, 2017, 09:15:47 PM

Previous topic - Next topic

Renegrade

Not sure if this is the correct sub-forum or not, but I actually have a question about the A18/B18 save file format.

In A17 and earlier, the roofGrid tags (and fog etc) had a roofs (or equivalent) tag contained within, which was basically just a base64-encoded bitfield or byte/word array.

A/B18 has something different - a roofDeflate, which is tremendously smaller.  The name and size suggests that it's the trusty old DEFLATE algorithm, none of my deflate-capable tools seem to recognize the data.  Or other tools:

$ file roof.bin
roof.bin: data

So my question is.. what exactly is in those deflate blocks?  Is it simply deflate output with some leading data, or something else entirely?  Or did I simply mess up whilst converting it to binary? :S

dfisher0065

Did you ever figure out how to decompress this?  I just posted something on Reddit before I saw this thread.  MAN I miss that bit array from before!

Loneshade

I'd assume its compressed with 7z format since thats the first letters my <roofgrid> always seems to start with?

Loneshade

Adding to my last comment I'm rather positive, that while the roof section is now deflated, also the old syntax still works - sadly my knowledge of the old syntax is limited and all I found was this post:

https://www.reddit.com/r/RimWorld/comments/44q9ci/how_to_edit_roofs_overhead_moutain/

So I assume that in theory you can simply replace your whole <roofGrid><roofsDeflate> section with an uncompressed <roofGrid><roofs> section and even, that saving after loading this file, you'd once again have it compressed, granting a perfect result.
Sadly I don't know exactly how that old syntax was constructed and what the start- and end-characters were, so while my saves load, I've not been able to get a usable result yet

Builder1234

Hi Guys, I just wanted to update this thread because using your method I successfully updated my game world roofgrid.  It was complicated, but it works!  My basic process was:

Find an old A16 or A17 save from before the compression where the roofgrid appears with the deflate tag now.  It's a much longer string, supporting the previous posters idea that it's compressed.  I couldn't figure out how to uncompress it, which is why I needed a previous save.  With the older save, use the rimworld_roof_editor tool for A16, and download the roof grid as a png file.  Here's the fun part, manually edit this png for your new world [this is fun...  I stitched together screenshots of my current map using paint, converted it down to 275 x 275 pixels, and manually colored it using the black/gray/white color coding for the roof_editor to reimport.  That took maybe 45 minutes itself].  Make sure it's the same grid size (e.g. 275 x 275 or 300 x 300), and once you're finished upload this using the rimworld_roof_editor tool again.  You're uploading it to the previous A16 save file, so when you're done grab the everything in the <roofgrid> </roofgrid> tag in the save game file.  Find your new B18 save game file.  Delete everything under the <roofgrid> </roofgrid> tag (including the tags), and replace it with the tag from the A16 save file with your modified roof grid.  Load the game and you'll see it changed!

Yes, that's very convoluted, but it works and until someone figures out how to decompress the <roofsdeflate> tag to get the original bitmap, that's how you'll have to do it!

Loneshade

Quote from: Builder1234 on May 01, 2018, 05:23:30 PM
Hi Guys, I just wanted to update this thread because using your method I successfully updated my game world roofgrid.  It was complicated, but it works!  My basic process was:

Find an old A16 or A17 save from before the compression where the roofgrid appears with the deflate tag now.  It's a much longer string, supporting the previous posters idea that it's compressed.  I couldn't figure out how to uncompress it, which is why I needed a previous save.  With the older save, use the rimworld_roof_editor tool for A16, and download the roof grid as a png file.  Here's the fun part, manually edit this png for your new world [this is fun...  I stitched together screenshots of my current map using paint, converted it down to 275 x 275 pixels, and manually colored it using the black/gray/white color coding for the roof_editor to reimport.  That took maybe 45 minutes itself].  Make sure it's the same grid size (e.g. 275 x 275 or 300 x 300), and once you're finished upload this using the rimworld_roof_editor tool again.  You're uploading it to the previous A16 save file, so when you're done grab the everything in the <roofgrid> </roofgrid> tag in the save game file.  Find your new B18 save game file.  Delete everything under the <roofgrid> </roofgrid> tag (including the tags), and replace it with the tag from the A16 save file with your modified roof grid.  Load the game and you'll see it changed!

Yes, that's very convoluted, but it works and until someone figures out how to decompress the <roofsdeflate> tag to get the original bitmap, that's how you'll have to do it!

great my theory was proven and already helped someone :)

Maybe an easy solution would be to to provide 100% mountain roof saves for the community. Then one can just copy over the section and afterwards remove non-necessary roofs in game?

Oceanshx

The compressing method is still confusing. But as suggested by @Loneshade, i obtained the full overhead mountain code for a 225*225 map. The main point is that 0.18 version can still congnize <roofGrid><roofs> tag though a normal savefiles uses <roofGrid><roofsDeflate> instead. So you can just open a normal 0.18 savefile and replace its <roofGrid><roofsDeflate> tags and content with <roofGrid><roofs> tags and content (repeating RCpEKkQq for 225*225/3 times, wow), and load the game, then save the game. and open the savefile again, you shall see it is updated automatically to the code below:
<roofGrid>
<roofsDeflate>
7cIxDQAAAAKgPuawfyZbeDFoCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwNg==
</roofsDeflate>
</roofGrid>


CannonFodder

This thread was very helpful in pointing me in the right direction when I ran into a roof editing issue today in B18. I've submitted a pull request for thearn's already awesome "Rimworld Savegame Roof-type Editor" that will hopefully allow more automated roof editing in B18.

https://ludeon.com/forums/index.php?topic=29812.msg411979#msg411979

neitsa

As a side comment, I explained the compression scheme in another post (although it was for the the terrain grid, it works exactly the same way for the other entries with "deflate" in their name).

The compression is just a zlib compression, without specific headers.

Loneshade

#10
That's the 100% mountain roof code for a 325x325 map:

            <roofGrid>
               <roofsDeflate>
7cIBCQAAAAKgP+3o/6Z+hGhTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODI=
</roofsDeflate>
            </roofGrid>