From a4ed63033e2996d3fe9a942b33ab7a0487dc7526 Mon Sep 17 00:00:00 2001 From: Boondorl Date: Mon, 28 Jul 2025 00:06:08 -0400 Subject: [PATCH] Fixed quick save rotator breaking save logic The game should only ever save during the gameplay loop and never on the spot. Also fixes the quick save rotator skipping certain checks. --- src/d_event.h | 1 + src/d_net.cpp | 2 +- src/g_game.cpp | 24 ++++++++++++++++++++---- src/g_game.h | 2 +- src/playsim/p_lnspec.cpp | 2 +- wadsrc/static/zscript/constants.zs | 6 ++++++ 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/d_event.h b/src/d_event.h index 56ae9b07e..013e096d3 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -100,6 +100,7 @@ enum gameaction_t : int ga_intermission, ga_titleloop, ga_mapwarp, + ga_quicksave, }; extern gameaction_t gameaction; diff --git a/src/d_net.cpp b/src/d_net.cpp index 0a72bc5a3..abd0dc5fb 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2094,7 +2094,7 @@ static bool ShouldStabilizeTick() { return gameaction != ga_recordgame && gameaction != ga_newgame && gameaction != ga_newgame2 && gameaction != ga_loadgame && gameaction != ga_loadgamehidecon && gameaction != ga_autoloadgame && gameaction != ga_loadgameplaydemo - && gameaction != ga_savegame && gameaction != ga_autosave + && gameaction != ga_savegame && gameaction != ga_autosave && gameaction != ga_quicksave && gameaction != ga_worlddone && gameaction != ga_completed && gameaction != ga_screenshot && gameaction != ga_fullconsole; } diff --git a/src/g_game.cpp b/src/g_game.cpp index 1bad3c24c..b0ac2ec21 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1196,6 +1196,12 @@ void G_Ticker () savegamefile = ""; savedescription = ""; break; + case ga_quicksave: + G_DoSaveGame(true, true, savegamefile, savedescription.GetChars()); + gameaction = ga_nothing; + savegamefile = ""; + savedescription = ""; + break; case ga_autosave: G_DoAutoSave (); gameaction = ga_nothing; @@ -2145,9 +2151,9 @@ void G_DoLoadGame () // Called by the menu task. // Description is a 24 byte text string // -void G_SaveGame (const char *filename, const char *description) +void G_SaveGame (const char *filename, const char *description, bool quick) { - if (sendsave || gameaction == ga_savegame) + if (sendsave || gameaction == ga_savegame || gameaction == ga_quicksave) { Printf ("%s\n", GStrings.GetString("TXT_SAVEPENDING")); } @@ -2171,7 +2177,17 @@ void G_SaveGame (const char *filename, const char *description) { savegamefile = filename; savedescription = description; - sendsave = true; + if (quick) + { + sendsave = false; + gameaction = ga_quicksave; + } + else + { + sendsave = true; + if (gameaction == ga_quicksave) + gameaction = ga_nothing; + } } } @@ -2268,7 +2284,7 @@ void G_DoQuickSave () readableTime = myasctime (); description.Format("Quicksave %s", readableTime); - G_DoSaveGame (true, true, file, description.GetChars()); + G_SaveGame(file.GetChars(), description.GetChars(), true); } diff --git a/src/g_game.h b/src/g_game.h index fcb9a1974..07e30e101 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -64,7 +64,7 @@ void G_LoadGame (const char* name, bool hidecon=false); void G_DoLoadGame (void); // Called by M_Responder. -void G_SaveGame (const char *filename, const char *description); +void G_SaveGame (const char *filename, const char *description, bool quick = false); // Called by messagebox void G_DoQuickSave (); diff --git a/src/playsim/p_lnspec.cpp b/src/playsim/p_lnspec.cpp index faa3e888b..be85ba44f 100644 --- a/src/playsim/p_lnspec.cpp +++ b/src/playsim/p_lnspec.cpp @@ -3179,7 +3179,7 @@ FUNC(LS_TranslucentLine) FUNC(LS_Autosave) { - if (gameaction != ga_savegame) + if (gameaction != ga_savegame && gameaction != ga_quicksave) { Level->flags2 &= ~LEVEL2_NOAUTOSAVEHINT; Net_WriteInt8 (DEM_CHECKAUTOSAVE); diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index 8bb1af77f..226468c98 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -1150,6 +1150,12 @@ enum EGameAction ga_screenshot, ga_togglemap, ga_fullconsole, + ga_resumeconversation, + ga_intro, + ga_intermission, + ga_titleloop, + ga_mapwarp, + ga_quicksave, }; enum EPuffFlags