brandon-ray / foxhole-facility-planner

Create blueprints for a bunker, facility, and more using this fan-made tool for the video game Foxhole. Formerly known as Foxhole Facility Planner, this tool now features facilities, bunkers, trenches, and more!
https://foxholeplanner.com
MIT License
37 stars 12 forks source link

Reduced precision for game saves to 3 places for x, y, z, rotation #39

Closed Romboter closed 1 year ago

Romboter commented 1 year ago

Save files reduced in size by about 15%

jimdcunningham commented 1 year ago

I actually really like how you used JSON stringify to just round all the positional data. I assume that also updates railPoints too? I desperately need to clean up the code that uses railPoints. Also, I was actually thinking about converting rotation from radians to degrees so it's even smaller in the save. Not sure how much overhead that'd add.

It'd be neat to keep working on this pr as just a nice little overhaul of saves in general. I might throw some commits on top of this, especially if saves are going to be served from the site in the future.

Romboter commented 1 year ago

Yep, it cleans up the railPoints too :)

Definitely some more savings to be had...if its worth the effort post LZMA idk... The numbers below are from manual manipulation of the json to simulate the output to judge savings of each option listed.

Once compressed using lzma the difference in percent is decent between the options but the actual space saved is smol in kb because lzma devman good.

The original save was 80kb and it compresses to 11.2kb Reducing precision to 3 brings it to 8kb Switching to degrees gets it to ~6.5-7kb Going nuclear on text + degrees gets it to ~5.8-6kb

Pre-compression numbers Original - 80kb Reducing precision to 3 - 66kb Going to degrees ~62kb Cutting text to minimum + degrees + precision 3 - ~44kb

jimdcunningham commented 1 year ago

Yeah, having shorthand names for all the props, converting building keys to ids, and replacing railpoints so that there's just a single object with the x/y/rotation for the handle seems like a given. Still blows my little mind how LZMA works. It's amazing.

Image data seems like where we'll get heavily beat to death. I'm thinking the only improvement I can add is giving image data ids and storing it outside of entities so that there's no duplicate image data.

This would also be a great time to just plop a little version number on the save. Ray and I talked about this yesterday a bit, and with all these changes this would be a nice time to use it since a lot of the properties will be changed around.