From dc4e14d9d9bbd6c06cacd71e43fe7ad0c4d09fa3 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 17 Nov 2023 16:58:22 +0000 Subject: [PATCH] G_DoCompleted: Use gamedata->deferredsave to reduce the number of intermediate gamedata saves --- src/g_game.c | 22 +++++++++++++--------- src/k_podium.cpp | 4 +++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 4c34f1c49..ca10a8791 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3622,6 +3622,10 @@ void G_UpdateVisited(void) if (demo.playback) return; + // For some reason, we don't want to update visitation flags. + if (prevmap != gamemap-1) + return; + // Check if every local player wiped out. for (i = 0; i < MAXPLAYERS; i++) { @@ -3662,7 +3666,7 @@ void G_UpdateVisited(void) CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); M_UpdateUnlockablesAndExtraEmblems(true, true); - G_SaveGameData(); + gamedata->deferredsave = true; } void G_HandleSaveLevel(boolean removecondition) @@ -4152,11 +4156,6 @@ static void G_DoCompleted(void) gamedata->deferredsave = true; } - // This isn't in the above block because other - // mechanisms can queue up a gamedata save. - if (gamedata->deferredsave) - G_SaveGameData(); - // Then, update some important game state. { legitimateexit = false; @@ -4224,10 +4223,10 @@ static void G_DoCompleted(void) nextmapoverride = NEXTMAP_TITLE+1; gamedata->finishedtutorialchallenge = true; - } - M_UpdateUnlockablesAndExtraEmblems(true, true); - G_SaveGameData(); + M_UpdateUnlockablesAndExtraEmblems(true, true); + gamedata->deferredsave = true; + } } else { @@ -4262,6 +4261,11 @@ static void G_DoCompleted(void) Y_StartIntermission(); G_UpdateVisited(); } + + // This isn't in the above blocks because many + // mechanisms can queue up a gamedata save. + if (gamedata->deferredsave) + G_SaveGameData(); } // See also F_EndCutscene, the only other place which handles intra-map/ending transitions diff --git a/src/k_podium.cpp b/src/k_podium.cpp index daada2ec6..a0c275846 100644 --- a/src/k_podium.cpp +++ b/src/k_podium.cpp @@ -980,9 +980,11 @@ void K_FinishCeremony(void) g_podiumData.ranking = true; - // Play the noise now (via G_UpdateVisited's concluding gamedata save) + // Play the noise now (via G_UpdateVisited's concluding challenge check) prevmap = gamemap-1; G_UpdateVisited(); + if (gamedata->deferredsave) + G_SaveGameData(); } /*--------------------------------------------------