From e33e15d87f6e9a24be3258bd533737428d63c9c7 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Mon, 20 Apr 2020 19:08:31 -0400 Subject: [PATCH] Fix dedicated servers not waiting for client wipes. Now they run wipe logic to wait the same amount of time that clients do, without actually rendering anything. Previously, the server would start the new map immediately, and clients would frameskip up to the server when they were done wiping. --- src/d_clisrv.c | 20 +++++++++++++++++--- src/d_main.c | 48 ++++++++++++++++++++++++++---------------------- src/f_wipe.c | 4 +++- src/p_setup.c | 49 ++++++++++++++++++++++++++++++++----------------- 4 files changed, 78 insertions(+), 43 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3bc30830..34ce7b02 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5072,6 +5072,18 @@ static void CL_SendClientKeepAlive(void) HSendPacket(servernode, false, 0, 0); } +static void SV_SendServerKeepAlive(void) +{ + for (INT32 n = 1; n < MAXNETNODES; n++) + { + if (nodeingame[n]) + { + netbuffer->packettype = PT_BASICKEEPALIVE; + HSendPacket(n, false, 0, 0); + } + } +} + // send the client packet to the server static void CL_SendClientCmd(void) { @@ -5589,9 +5601,6 @@ void NetKeepAlive(void) UpdatePingTable(); - if (server) - CL_SendClientKeepAlive(); - // Sryder: What is FILESTAMP??? FILESTAMP GetPackets(); @@ -5605,6 +5614,11 @@ FILESTAMP CL_SendClientKeepAlive(); // No need to check for resynch because we aren't running any tics } + else + { + SV_SendServerKeepAlive(); + } + // No else because no tics are being run and we can't resynch during this Net_AckTicker(); diff --git a/src/d_main.c b/src/d_main.c index cde5a9df..44de3e51 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -279,29 +279,25 @@ static void D_Display(void) INT32 wipedefindex = 0; UINT8 i; - if (dedicated) - return; - - if (nodrawers) - return; // for comparative timing/profiling - - // check for change of screen size (video mode) - if (setmodeneeded && !wipe) - SCR_SetMode(); // change video mode - - if (vid.recalc) - SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() - - // change the view size if needed - if (setsizeneeded) + if (!dedicated) { - R_ExecuteSetViewSize(); - forcerefresh = true; // force background redraw - } + if (nodrawers) + return; // for comparative timing/profiling - // draw buffered stuff to screen - // Used only by linux GGI version - I_UpdateNoBlit(); + if (vid.recalc) + SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() + + // change the view size if needed + if (setsizeneeded) + { + R_ExecuteSetViewSize(); + forcerefresh = true; // force background redraw + } + + // draw buffered stuff to screen + // Used only by linux GGI version + I_UpdateNoBlit(); + } // save the current screen if about to wipe wipe = (gamestate != wipegamestate); @@ -319,7 +315,7 @@ static void D_Display(void) wipedefindex = wipe_multinter_toblack; } - if (rendermode != render_none) + if (!dedicated) { // Fade to black first if (gamestate != GS_LEVEL // fades to black on its own timing, always @@ -339,8 +335,16 @@ static void D_Display(void) F_WipeStartScreen(); } + else //dedicated servers + { + F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); + wipegamestate = gamestate; + } } + if (dedicated) //bail out after wipe logic + return false; + // do buffered drawing switch (gamestate) { diff --git a/src/f_wipe.c b/src/f_wipe.c index 3c8713d1..bb1397bc 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -372,7 +372,9 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) HWR_DoWipe(wipetype, wipeframe-1); // send in the wipe type and wipeframe because we need to cache the graphic else #endif - F_DoWipe(fmask); + if (rendermode != render_none) //this allows F_RunWipe to be called in dedicated servers + F_DoWipe(fmask); + I_OsPolling(); I_UpdateNoBlit(); diff --git a/src/p_setup.c b/src/p_setup.c index 8487b00f..decdc529 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2889,26 +2889,34 @@ boolean P_SetupLevel(boolean skipprecip) // Encore mode fade to pink to white // This is handled BEFORE sounds are stopped. - if (rendermode != render_none && encoremode && !prevencoremode && !demo.rewinding) + if (encoremode && !prevencoremode && !demo.rewinding) { tic_t locstarttime, endtime, nowtime; - S_StopMusic(); // er, about that... + if (rendermode != render_none) + { + S_StopMusic(); // er, about that... - S_StartSound(NULL, sfx_ruby1); + S_StartSound(NULL, sfx_ruby1); - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 122); + F_WipeStartScreen(); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 122); - F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_speclevel_towhite], false); + F_WipeEndScreen(); + F_RunWipe(wipedefs[wipe_speclevel_towhite], false); - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 120); - - F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_final], false); + F_WipeStartScreen(); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 120); + F_WipeEndScreen(); + F_RunWipe(wipedefs[wipe_level_final], false); + } + else //dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe + { + F_RunWipe(wipedefs[wipe_speclevel_towhite], false); + F_RunWipe(wipedefs[wipe_level_final], false); + } + locstarttime = nowtime = lastwipetic; endtime = locstarttime + (3*TICRATE)/2; @@ -2941,13 +2949,20 @@ boolean P_SetupLevel(boolean skipprecip) // Let's fade to white here // But only if we didn't do the encore startup wipe - if (rendermode != render_none && !ranspecialwipe && !demo.rewinding) + if (!ranspecialwipe && !demo.rewinding) { - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); + if(rendermode != render_none) + { + F_WipeStartScreen(); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); - F_WipeEndScreen(); - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); + F_WipeEndScreen(); + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); + } + else //dedicated servers + { + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); + } } // Reset the palette now all fades have been done