Previously each world object (there's one per overworld, caves, etc) had a "worldmapexplorer" entity attached to it that stored a "master copy" of the map, containing the sum of all exploration all players had made. This seems to not work properly anymore.
An idea for a new system building off of the cartography system the game now uses:
For each world, listen for player despawns
When a player despawns, save a hidden cartography map object with their map data.
When another player despawns, their map object overwrites the previous one (assumption: they have managed to sync with all stored maps).
Also listen for player spawns. When a player spawns in, load in the map data from the hidden object.
Possible defense against breaking the assumption of having synced:
Version the map data.
Initially, player map version is 0.
When a player despawns, they first sync in any saved map data, then save their map data.
The saved map version becomes max(player_map_version, previous_saved_map_version) + 1
When a player loads in:
Check for players in the world, and find the one with the highest map version number, saving their map.
This covers the case where player A has been in the world exploring, but hasn't despawned and saved their map, and a new joining player B needs A's map data that they uncovered prior to B joining.
Do this at most once a second, to prevent a huge load spike if reloading a world with everyone still connected, for example.
Then sync with the saved map data and give the spawning player its version number.
When syncing from the saved map, only sync if its version is greater than the player's.
I think this should result in consistent map saving without data loss.
Previously each world object (there's one per overworld, caves, etc) had a "worldmapexplorer" entity attached to it that stored a "master copy" of the map, containing the sum of all exploration all players had made. This seems to not work properly anymore.
An idea for a new system building off of the cartography system the game now uses:
Possible defense against breaking the assumption of having synced:
max(player_map_version, previous_saved_map_version) + 1
I think this should result in consistent map saving without data loss.