SnowyMouse / chimera

The update to Halo PC that never was
https://chimera.opencarnage.net
GNU General Public License v3.0
137 stars 26 forks source link

Map info command #38

Closed MangoFizz closed 3 years ago

MangoFizz commented 3 years ago

Well, here is the command that @Vaporeon requested on #34

Edit 1: There is no file size on Invader maps header :(

Aerocatia commented 3 years ago

Nice work.

The size value in the header is the uncompressed size. Invader compressed maps will always have this set correctly as it is used for decompression, however it is completely unreliable in regular format maps and it is often zeroed out. There are two reasons for this, one reason is to work around the max map size limitation as Halo checks this value rather than the actual size of the map, so if this value is set low you can load maps larger than the max size. The second reason is Halo leaks file descriptors when the map cache file size is over 128 MiB, so like bypassing the max size, setting the "size" in the header low will work around this bug too. When an invader-compressed map gets decompressed it zeroes the size field out so that is why it's not there.

The only reliable way to get the true size of a cache file is to check the file size on disk, same for getting the compressed size of an invader-compressed map.

Another thing to mention with maps in ram you have to account for raw data loaded from the resource maps too, so the actual memory buffer usage will be higher than just the regular uncompressed map size. IIRC Chimera already has a value for this somewhere you can use to display this correctly.

MangoFizz commented 3 years ago

Done! Now I'm getting the map file size from the map loading stuff. I also added some additional fields for compressed maps and RAM buffer.

SnowyMouse commented 3 years ago

Looks good! Thanks!