Restoring the same functionality as we had before, but this time for a randomly generated world.
Moved the chunk data to Helper.overmap_manager. The Levelgenerator will read from and write to there
The chunks in the area around the player are devided into segments of 4x4 chunks, so 16 chunks. The size is arbitrary
These segments are purely for saving and loading, nothing else. Previously saved segments are loaded withing a 16 chunk radius around the player (if there's anything to load). Segments are unloaded if their coordinate is 28 chunks away. The chunks that the player walks on are loaded/unloaded much more quickly and their data is saved to loaded_chunk_data.chunks. To ensure periodic saving and not keeping a massive amount of chunks in memory, the chunk data in loaded_chunk_data.chunks array will be saved to disk in 4x4 segments. In an overmap grid of 100x100 this means 25x25 segments.
The map seed is saved and loaded, so you can continue with the same map you started on.
I tested it by starting a game, walked south for a bit, dropped a magazine in a container and exited the game. I then loaded the game and saw the same map and overmap, and the magazine was still in the container.
Testing was not thorough and I'm sure there's some bugs to fix, but this is a good first iteration.
The map data is saved like this:
Inside the segment folder you can find:
The contents looks like this:
I considered these alternatives for saving:
Save each chunk as it's being unloaded and load as needed, but this would create a lot of files
Unload the chunk but keep it's data in memory. When the game ends, separate all chunk data in memory into segments and save them to disk
Same as previous but save all chunk data in one big file
I think 4x4 is fine. Our largest tacticalmap is something like 6x6 which we were also saving in one file.
Requires #244
Restoring the same functionality as we had before, but this time for a randomly generated world.
loaded_chunk_data.chunks
. To ensure periodic saving and not keeping a massive amount of chunks in memory, the chunk data inloaded_chunk_data.chunks
array will be saved to disk in 4x4 segments. In an overmap grid of 100x100 this means 25x25 segments.I tested it by starting a game, walked south for a bit, dropped a magazine in a container and exited the game. I then loaded the game and saw the same map and overmap, and the magazine was still in the container.
Testing was not thorough and I'm sure there's some bugs to fix, but this is a good first iteration. The map data is saved like this:
Inside the segment folder you can find:
The contents looks like this:
I considered these alternatives for saving:
I think 4x4 is fine. Our largest tacticalmap is something like 6x6 which we were also saving in one file.