- Home /
Can we merge multiple save files for easier management?
Say my player has traveled across and altered one thousand terrains, I'd rather not make one thousand files to save all those changes. I'm curious if someone can point me towards how to merge those multiple files into one larger file allowing me to find and load/save only the sections I need. Or would such merged file require me to rewrite the entire file every save? I can imagine loading the one big file at the start, but then how do I safely save incremental changes without rewriting the whole thing?
For another way to look at it, say I am saving heightmap, splatmap, tree, grass, building, and object data per terrain all separately so that I can alter one without having to rewrite the whole file. Is there a way to merge these into a single file but still be able to only rewrite certain sections? Note that none of these arrays/lists have fixed sizes; the heightmap resolution can be changed in the settings, etc.
Or is having tons of files per world really not something I should be concerned about? Seems messy...
Answer by JedBeryll · Jan 25, 2017 at 05:49 AM
Interesting question, i guess it's better to have multiple small files instead of 1 big so you don't have to bother for lookups and overwriting just the part you need in a single file. You could make save folders for every single save so lets say you have a "Saves" folder and inside you have "Save1", "Save2" folders... so your files are still separated. I have seen this in many big games so if it worked for them it should work for you too.
That's where I am right now. A master folder for each player, then subfolders for each world, and files for all the data, but it quickly gets into the hundreds once the player starts exploring the world. It certainly works, heck unity uses tens of thousands of files, I just would much prefer a file per world ins$$anonymous$$d of hundreds if possible... Am looking at a database as a viable option right now... I don't understand how the one big data.dat approach is viable though some games seem to do that...
As much as it hurts to have so many files, I don't see a better, more manageable and faster way to do it.
What you can do is create a class that handles all the saving and loading ins$$anonymous$$d of searching for the right file and data everywhere. This should make at as clean as possible.