[MP] Add custom save/restore implementation for use in multiplayer mods #452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NOTE: This is for save/restore in multiplayer itself, not the MP branch as a whole. It DOES NOT fix the current save/restore issues in the TF2 SDK, and is in fact victim to them as well!
This PR adds a custom implementation of save/restore for use in multiplayer mods. This implementation supports both level transitions as well as direct saving and loading.
Although save/restore commands and file management are handled by the engine, most of the actual saving and restoring is done directly in the server. This implementation basically uses the serverside save/restore functions to generate its own buffer and write it to a file. Then, when it needs to restore the save, it opens that file and reads that buffer into the game state. While this implementation is not one-to-one with default singleplayer save/restore, it effectively behaves the same in practice.
This implementation also includes its own block handler for restoring players as they connect to the server. This block handler saves players and their weapons separately from other entities and ties them to their Steam IDs (which are saved through new custom int64 handlers). When the save loads, this player data is retained until all players reconnect and have their data restored.
Please note that the issues which exist as of writing in default save/restore in the TF2 SDK (e.g. the VPhysics bugs) also apply to this system. Most forward level transitions are stable due to the limited complexity of entities which carry over, but backward level transitions and repeat transitions can crash depending on the map and the entities being restored, as happens in default save/restore. For example, due to the VPhysics save/restore bugs, maps with fully simulated vehicles (e.g. airboat, jeep, APCs, etc.) cannot be restored at all.
This PR is in draft status due to the following considerations:
PR Checklist
develop
branch OR targets another branch with a specific goal in mind