Skip to content

[MP] Add custom save/restore implementation for use in multiplayer mods #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: mapbase-mp-2025
Choose a base branch
from

Conversation

Blixibon
Copy link
Member

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:

  • This implementation has only been tested with bots and one real player.
  • This is mostly non-functional in TF2 at the moment, so it may need its own preprocessor to make sure it's compiled into HL2MP mods but not TF mods.
  • This might require some changes included in the SecobMod pull request.

PR Checklist

  • My PR follows all guidelines in the CONTRIBUTING.md file
  • My PR targets a develop branch OR targets another branch with a specific goal in mind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant