Thanks for the patch! If one ignores the white space changes, this looks like you only needed to make very little changes to add server save game support. Given that, I'm open to adding this. How thoroughly did you test the patch? What happens to the players in the server? I suspect that it will not work properly as long as players are connected.
Reply To torr_samaho
Thanks for the patch! If one ignores the white space changes, this looks like you only needed to make very little changes to add server save game support. Given that, I'm open to adding this. How thoroughly did you test the patch? What happens to the players in the server? I suspect that it will not work properly as long as players are connected.
Hi, thanks for the input.
I tested it on Doom2 with 1 player, server+client on Linux. The test was on map01 and covered this:
- join server
- move around and kill two zombies in the room
- server: save game
- server: load game, the player was respawned (not quite sure where, it was a couple of months ago)
- repeated save+load one more time.
On Hexen I did it with 2 players (Windows+Linux official released clients) I did the following:
- server: changed map to the first hub (7 portals)
- joined the server, class cleric
- moved around, killed etties
- server: saved game
- second player joined, class warrior
- entered a level (is it frozen world something?), and played until the portal to go back was revealed
- server: saved the game as g1
- players went back to the hub
- server: load g1, the level "frozen" was loaded as it was left and the players were spawned in the entry room, no previously acquired weapons or items, as if they've just joined the game.
- went back to the hub, went through some levels
- server: saved the game as g2
- players disconnected, server shutdown, then started back up
- server: load g2
- players joined and were spawned on the frozen level entry room, where it was saved
- went back to hub and entered another previously visited level and it was as it was left (doors open etc)
Then I have repeated the same test on the second hub and second chapter of the game and it all worked ok.
The only glitch I have encountered was that the client crashed on the level, can't remember the name, it has a tall ledge, a pool below, a tower in the middle, and a few snake-creatures in the pool. Later on I discovered Hexen has a bug with players approaching very high ledges.
I can make another test if you like. I can check Heretic, Doom1, or maybe some specific level with many monsters, or moving items, like map30. What do you think?
Also, I don't work in C so I used VS Code and didn't bother to set up tabs/spaces. If you have any suggestions about formatting, I'd appreciate it. Thanks.
The patch allows server to save and load games by using commands save and load: save <name>, load <name>. So what I basically did is to allow saving and loading when network state is NETSTATE_SERVER and then skip writing the player data to the save file. Also, renderer is not present in a server so I used the M_CreateDummyPNG(). After loading, the players will be respawned at the beginning of the saved active level. All the levels touched in between (if playing from a Hexen hub) will be restored. Also, I have tested it with Doom 2 WAD. (I'm using Steam WADs if that matters). I'm using Linux, but I wanted to test it with the released 3.0 Windows executable client, so I used the revision 3.0-r170901-1140, dd3c3b57023f. The patch is for that revision. I'm not well versed in Mercurial so I hope the patch can be applied to newer revisions. If not I can provide a new one.