From 6fc29ce37d344954a22405350779cf9900edac19 Mon Sep 17 00:00:00 2001 From: Sryder Date: Fri, 6 Jul 2018 20:22:24 +0100 Subject: [PATCH] Always send gamestate to joiners. It's cut down already outside of levels, needed to stop Lua sending mobj references during intermission though. This is needed because in the past there was a separate way to send player information to joiners that has since been removed. Meaning player information is always desynched for joiners during anything but levels. --- src/d_clisrv.c | 12 +++++------- src/lua_script.c | 17 ++++++++++------- src/p_saveg.c | 5 ++++- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5231f059..4935632f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3535,7 +3535,7 @@ static void HandleConnect(SINT8 node) #ifdef JOININGAME if (nodewaiting[node]) { - if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING) && newnode) + if (newnode) { SV_SendSaveGame(node); // send a complete game state DEBFILE("send savegame\n"); @@ -3747,13 +3747,11 @@ static void HandlePacketFromAwayNode(SINT8 node) /// \note Wait. What if a Lua script uses some global custom variables synched with the NetVars hook? /// Shouldn't them be downloaded even at intermission time? /// Also, according to HandleConnect, the server will send the savegame even during intermission... - if (netbuffer->u.servercfg.gamestate == GS_LEVEL - /*|| netbuffer->u.servercfg.gamestate == GS_INTERMISSION - || netbuffer->u.servercfg.gamestate == GS_VOTING*/) - cl_mode = CL_DOWNLOADSAVEGAME; - else + /// Sryder 2018-07-05: If we don't want to send the player config another way we need to send the gamestate + /// At almost any gamestate there could be joiners... So just always send gamestate? + cl_mode = CL_DOWNLOADSAVEGAME; #endif - cl_mode = CL_CONNECTED; + cl_mode = CL_CONNECTED; break; } diff --git a/src/lua_script.c b/src/lua_script.c index 7ed30367..ef94cf30 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -962,13 +962,16 @@ void LUA_Archive(void) ArchiveExtVars(&players[i], "player"); } - for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - // archive function will determine when to skip mobjs, - // and write mobjnum in otherwise. - ArchiveExtVars(th, "mobj"); - } + if (gamestate == GS_LEVEL) + { + for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (th->function.acp1 == (actionf_p1)P_MobjThinker) + { + // archive function will determine when to skip mobjs, + // and write mobjnum in otherwise. + ArchiveExtVars(th, "mobj"); + } + } WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. LUAh_NetArchiveHook(NetArchive); // call the NetArchive hook in archive mode diff --git a/src/p_saveg.c b/src/p_saveg.c index 0fc69ad3..b98cf3e4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3195,7 +3195,10 @@ static void P_NetArchiveMisc(void) WRITEUINT32(save_p, ARCHIVEBLOCK_MISC); WRITEINT16(save_p, gamemap); - WRITEINT16(save_p, gamestate); + if (gamestate != GS_LEVEL) + WRITEINT16(save_p, GS_WAITINGPLAYERS); // nice hack to put people back into waitingplayers + else + WRITEINT16(save_p, gamestate); for (i = 0; i < MAXPLAYERS; i++) pig |= (playeringame[i] != 0)<