From 6d851f2bc8855d5dbd83471c95a834abd5c46d86 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 14 Feb 2022 15:43:56 +0000 Subject: [PATCH 1/3] P_LoadLevel is a mess, but attempt to fix a few things that shouldn't be happening with resyncs, including #209. Untested. --- src/p_saveg.c | 3 ++- src/p_setup.c | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 0561d365a..0a5da687f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -4496,7 +4496,8 @@ static inline boolean P_NetUnArchiveMisc(boolean reloading) // tell the sound code to reset the music since we're skipping what // normally sets this flag - mapmusflags |= MUSIC_RELOADRESET; + if (!reloading) + mapmusflags |= MUSIC_RELOADRESET; G_SetGamestate(READINT16(save_p)); diff --git a/src/p_setup.c b/src/p_setup.c index 1a1583a0a..b87f5014e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3943,9 +3943,12 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // will be set by player think. players[consoleplayer].viewz = 1; + // Cancel all d_main.c fadeouts (keep fade in though). + if (reloadinggamestate) + wipegamestate = gamestate; // Don't fade if reloading the gamestate // Encore mode fade to pink to white // This is handled BEFORE sounds are stopped. - if (encoremode && !prevencoremode && !demo.rewinding) + else if (encoremode && !prevencoremode && !demo.rewinding) { if (rendermode != render_none) { @@ -4007,10 +4010,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) } } - // Cancel all d_main.c fadeouts (keep fade in though). - if (reloadinggamestate) - wipegamestate = gamestate; // Don't fade if reloading the gamestate - // Special stage & record attack retry fade to white // This is handled BEFORE sounds are stopped. if (G_GetModeAttackRetryFlag()) @@ -4032,7 +4031,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // Let's fade to white here // But only if we didn't do the encore startup wipe - if (!demo.rewinding) + if (!demo.rewinding && !reloadinggamestate) { // Make sure all sounds are stopped before Z_FreeTags. S_StopSounds(); @@ -4204,10 +4203,9 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) { P_InitCamera(); memset(localaiming, 0, sizeof(localaiming)); + K_InitDirector(); } - K_InitDirector(); - wantedcalcdelay = wantedfrequency*2; indirectitemcooldown = 0; hyubgone = 0; @@ -4237,7 +4235,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) if (!(netgame || multiplayer || demo.playback) && !majormods) mapvisited[gamemap-1] |= MV_VISITED; - else if (netgame || multiplayer) + else if (!demo.playback) mapvisited[gamemap-1] |= MV_MP; // you want to record that you've been there this session, but not permanently G_AddMapToBuffer(gamemap-1); @@ -4260,7 +4258,11 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) lastmaploaded = gamemap; // HAS to be set after saving!! } - if (grandprixinfo.gp == true) + if (reloadinggamestate) + { + CONS_Printf("Gamestate reloaded; bot infomation may be corrupted, requires further testing...\n"); + } + else if (grandprixinfo.gp == true) { if (grandprixinfo.initalize == true) { From 0b97d954ad764e423a57a4bcb6dc98df5fe49000 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 16 Feb 2022 23:23:14 +0000 Subject: [PATCH 2/3] Tested with Chengi at one point, correct a few things from that. * Fixed a few prints happening on resync that shouldn't. * Fixed OGL loading not using levelfadecol. --- src/d_clisrv.c | 27 +++++++++++++++------------ src/hardware/hw_bsp.c | 2 +- src/p_setup.c | 6 ++---- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 855056cf1..5c4dd80d4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1292,20 +1292,23 @@ static void CL_LoadReceivedSavegame(boolean reloading) // load a base level if (P_LoadNetGame(reloading)) { - CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); - - if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) + if (!reloading) { - CON_LogMessage(va(": %s", mapheaderinfo[gamemap-1]->lvlttl)); - if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) - CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->zonttl)); - else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - CON_LogMessage(M_GetText(" Zone")); - if (mapheaderinfo[gamemap-1]->actnum > 0) - CON_LogMessage(va(" %d", mapheaderinfo[gamemap-1]->actnum)); - } + CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); - CON_LogMessage("\"\n"); + if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) + { + CON_LogMessage(va(": %s", mapheaderinfo[gamemap-1]->lvlttl)); + if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) + CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->zonttl)); + else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) + CON_LogMessage(M_GetText(" Zone")); + if (mapheaderinfo[gamemap-1]->actnum > 0) + CON_LogMessage(va(" %d", mapheaderinfo[gamemap-1]->actnum)); + } + + CON_LogMessage("\"\n"); + } } else { diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 4db69ff8b..df0b7113e 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -589,7 +589,7 @@ static void loading_status(void) sprintf(s, "%d%%", (++ls_percent)<<1); x = BASEVIDWIDTH/2; y = BASEVIDHEIGHT/2; - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); // Black background to match fade in effect //V_DrawPatchFill(W_CachePatchName("SRB2BACK",PU_CACHE)); // SRB2 background, ehhh too bright. M_DrawTextBox(x-58, y-8, 13, 1); V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); diff --git a/src/p_setup.c b/src/p_setup.c index b87f5014e..6e77d0435 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4224,7 +4224,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) P_MapEnd(); // Remove the loading shit from the screen - if (rendermode != render_none && !(titlemapinaction || reloadinggamestate)) + if (rendermode != render_none && !titlemapinaction && !reloadinggamestate) F_WipeColorFill(levelfadecol); if (precache || dedicated) @@ -4259,9 +4259,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) } if (reloadinggamestate) - { - CONS_Printf("Gamestate reloaded; bot infomation may be corrupted, requires further testing...\n"); - } + ; else if (grandprixinfo.gp == true) { if (grandprixinfo.initalize == true) From b158bfe37e48a52c01f6f7428209b072612ffd0e Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 17 Feb 2022 22:41:34 +0000 Subject: [PATCH 3/3] Always stop the sounds, because we're always calling Z_FreeTags and that can lead to invalid memory. (Should fix Rai's crash) --- src/p_setup.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 6e77d0435..f5a03e628 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4029,13 +4029,14 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) } */ + // Make sure all sounds are stopped before Z_FreeTags. + S_StopSounds(); + S_ClearSfx(); + // Let's fade to white here // But only if we didn't do the encore startup wipe if (!demo.rewinding && !reloadinggamestate) { - // Make sure all sounds are stopped before Z_FreeTags. - S_StopSounds(); - S_ClearSfx(); // Fade out music here. Deduct 2 tics so the fade volume actually reaches 0. // But don't halt the music! S_Start will take care of that. This dodges a MIDI crash bug.