From 4a5c7fcae2116942841a319497b9cd929c3140db Mon Sep 17 00:00:00 2001 From: Oni Date: Sat, 24 Aug 2024 07:22:48 +0000 Subject: [PATCH] Merge branch 'speedy-savestate' into 'master' Don't reload level on gamestate resend See merge request KartKrew/Kart!2225 --- src/p_saveg.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 5aa4b04bf..579dc798a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -5344,6 +5344,8 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool size_t i; size_t numTasks; + const INT16 prevgamemap = gamemap; + if (READUINT32(save->p) != ARCHIVEBLOCK_MISC) I_Error("Bad $$$.sav at archive block Misc"); @@ -5383,10 +5385,19 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool mapmusrng = READUINT8(save->p); - if (!P_LoadLevel(true, reloading)) + // Only reload the level during a gamestate reload + // if the map is horribly mismatched somehow. Minor + // differences in level state are already handled + // by other parts of the reload, so doing this + // on *every* reload wastes lots of time that we + // will need for rollback down the road. + if (!reloading || prevgamemap != gamemap) { - CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); - return false; + if (!P_LoadLevel(true, reloading)) + { + CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); + return false; + } } // get the time