From b29e6f0a469ea7efbc0cdd90475f6d754c442dfd Mon Sep 17 00:00:00 2001 From: FreakyMutantMan <freakymutantman@gmail.com> Date: Sun, 24 Nov 2024 19:20:03 -0800 Subject: [PATCH] Rewrite to instead have the game save at Position's end within G_Ticker - thanks to Ashnal for the input. --- src/g_game.c | 8 +++++++- src/menus/transient/pause-game.c | 2 -- src/p_saveg.c | 4 ++-- src/sdl/i_system.cpp | 5 +---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 8439d6bb3..bb3a064ab 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2041,6 +2041,12 @@ void G_Ticker(boolean run) P_InvincGrowMusic(); K_TickMidVote(); + + if (leveltime >= starttime && savescum) + { + G_ClearSavescumFlag(); + G_HandleSaveLevel(false); + } } if (g_fast_forward == 0 && demo.attract == DEMO_ATTRACT_CREDITS) @@ -3951,7 +3957,7 @@ void G_HandleSaveLevel(boolean removecondition) return; if ((roundqueue.position == 1 && roundqueue.entries[0].overridden == false) - || (players[consoleplayer].lives <= 1 && savescummer)) // because a life is lost on reload EDIT 11-21-24: and we need to make sure the life *should* be lost, because this now runs at menu exit to check for Position. + || (players[consoleplayer].lives <= 1 && !savescummer)) // because a life is lost on reload EDIT 11-21-24: and we need to make sure the life *should* be lost, because this now runs at menu exit to check for Position. goto doremove; G_SaveGame(); diff --git a/src/menus/transient/pause-game.c b/src/menus/transient/pause-game.c index e7c8838cb..1fa9c4275 100644 --- a/src/menus/transient/pause-game.c +++ b/src/menus/transient/pause-game.c @@ -564,8 +564,6 @@ static void M_ExitGameResponse(INT32 ch) } else { - G_ClearSavescumFlag(); - G_HandleSaveLevel(false); G_SetExitGameFlag(); M_SetMenuDelay(pid); // prevent another input } diff --git a/src/p_saveg.c b/src/p_saveg.c index 4b429f2bf..d67686496 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -99,7 +99,7 @@ static inline void P_ArchivePlayer(savebuffer_t *save, boolean savescumcheck) //CONS_Printf(M_GetText("\nLife or death for eggboy?")); // Prevent an exploit from occuring. - if ((leveltime >= starttime) || savescumcheck) + if (!savescumcheck) { //CONS_Printf(M_GetText("\nDEATH!")); WRITESINT8(save->p, (player->lives - 1)); @@ -6155,7 +6155,7 @@ static inline void P_ArchiveMisc(savebuffer_t *save, boolean savescummer) WRITEUINT32(save->p, rank->totalLaps); // If we're not deducting a life from the player, don't tick up their continues either. - if ((leveltime >= starttime) || savescummer) + if (!savescummer) { //CONS_Printf(M_GetText("Continue used!/n")); WRITEUINT32(save->p, (rank->continuesUsed + 1)); diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 2b9d60807..86cc965bd 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1664,11 +1664,8 @@ void I_Quit(void) // Make sure you lose points for ALT-F4 // ...but make sure you don't lose a life if you quit early in Grand Prix. if (Playing()) - { - G_ClearSavescumFlag(); - G_HandleSaveLevel(false); K_PlayerForfeit(consoleplayer, true); - } + G_SaveGameData(); // Tails 12-08-2002 //added:16-02-98: when recording a demo, should exit using 'q' key, -- GitLab