iso map and file size

Started by
12 comments, last by nex7 16 years, 5 months ago
sooo heres the deal right now i have my engine fully functional...everything works just fine... but.. my map files are huge... i have 4 layers terrain background middle foreground all of which are jagged arrays of objects so...if i have a map of 300x300 tiles....thats a lot of info to save out. the three upper layers have a lot of empty data but i wanted to keep the structure of the base map to make view culling easier. and each object in my terrain layer is unique because i want the terrain to be able to animate. soooo...any ideas of view culling or a better way to store a map? thanks!
Advertisement
The file structure doesn't have to reflect the memory structure, so you could certainly use a sparse or flyweight representation in the file, and still use a full representation in memory. Or you could zip your map files and unzip them at loading time—the holes in the structure would most probably be factored away quite efficiently.
yeah i was thinking about doing something like that...

save out to binary instead of xml...then zipping the binary data...

might take a bit to load the maps but hey...
Quote:Original post by nex7
...save out to binary instead of xml...


That should give you quite a bit of space savings right there.
Since disk speed is much, much slower than CPU, just the fact that you're loading a lot less data will probably be faster than reading raw XML. Instead of, or in addition to using ZIP, why not write your files in your raw, binary representation?
well im writing everything in c# and just using the c# serializer to save out all of my data.

a 50x50 map saved in binary is 1.5 meg
a 50x50 map saved in xml is 4.5 meg

both stupidly big for a 50x50 map..when im going to need much much much larger maps.
I decided to write out the ID of the object and a hash of <ID,Item>

on load i still create my big array but the file size is tiny in comparison to what it was.

thanks for the help.
Quote:a 50x50 map saved in binary is 1.5 meg
a 50x50 map saved in xml is 4.5 meg


I think right here is saying that you are saving in some strange way. I have no idea what you're doing. I typically have a 32-bit reference to the ID of the graphic template which is in memory (though even a 16-bit reference is often enough, since thats still plenty of templates). This way, your map file will just be 4x4x50x50 or 39 KBytes for a 50x50 map. If you are not using much of the other layers, you can use a 8-bit variable to state which layers are used of the next tile (or more optimally, next two tiles, so you use all of the 8 bits). This way it is +8 bits for every tile, but -32 bits for every layer not used. I'm sure this can knock down your map files quite a lot, too. I think what we need to know is what the "layers" contain.

[Edited by - Spodi on October 30, 2007 9:07:51 PM]
NetGore - Open source multiplayer RPG engine
some strange way = serialization of the objects out to xml

just taking a shortcut that i now have to fix.

all of the data came from the actual internal structure of the object....they have attributes to describe rendering and AI and quests....and inventory ...and anything else you could think of...then there is animation sets for each object.

each object...tiles include...is animated and can have a list of attributes to describe the abilities.

so...all of that directly serialized to xml = very large files.
There's no real reason to use serialization for a handful of arrays. Just read it and write it using BinaryReader/BinaryWriter. It's really easy and will be as small, or possibly smaller than it is in memory.

This topic is closed to new replies.

Advertisement