diff --git a/src/d_main.c b/src/d_main.c index 22ca0ef88..aa79e6584 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -982,7 +982,6 @@ void D_ClearState(void) cht_debug = 0; emeralds = 0; memset(&luabanks, 0, sizeof(luabanks)); - lastqueuesaved = 0; // In case someone exits out at the same time they start a time attack run, // reset modeattacking diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c24b3cb9e..f391e83c1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6241,11 +6241,6 @@ void Command_ExitGame_f(void) { INT32 i; -#ifndef DEVELOP - // Wipes gp backup if appropriate - G_HandleSaveLevel(true); -#endif - LUA_HookBool(false, HOOK(GameQuit)); D_QuitNetGame(); diff --git a/src/doomstat.h b/src/doomstat.h index e5788f824..e6787116e 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -51,7 +51,6 @@ extern UINT8 mapmusrng; extern UINT32 maptol; extern INT32 cursaveslot; -extern UINT8 lastqueuesaved; extern UINT8 gamecomplete; // Extra abilities/settings for skins (combinable stuff) diff --git a/src/g_game.c b/src/g_game.c index 422c124a1..bffba112a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -123,7 +123,6 @@ precipprops_t precipprops[MAXPRECIP] = preciptype_t precip_freeslot = PRECIP_FIRSTFREESLOT; INT32 cursaveslot = 0; // Auto-save 1p savegame slot -UINT8 lastqueuesaved = 0; UINT8 gamecomplete = 0; marathonmode_t marathonmode = 0; @@ -3350,6 +3349,7 @@ void G_ExitLevel(void) else { // Back to the menu with you. + G_HandleSaveLevel(true); D_QuitNetGame(); CL_Reset(); D_ClearState(); @@ -4024,18 +4024,21 @@ void G_HandleSaveLevel(boolean removecondition) return; if (removecondition) - { - if (FIL_FileExists(gpbackup)) - remove(gpbackup); - return; - } + goto doremove; if (gamestate != GS_LEVEL - || roundqueue.size == 0 - || lastqueuesaved == roundqueue.position) + || roundqueue.size == 0) return; + if (roundqueue.position == 1) + goto doremove; + G_SaveGame(); + return; + +doremove: + if (FIL_FileExists(gpbackup)) + remove(gpbackup); } // Next map apparatus diff --git a/src/menus/play-char-select.c b/src/menus/play-char-select.c index 733c37848..c88512926 100644 --- a/src/menus/play-char-select.c +++ b/src/menus/play-char-select.c @@ -530,7 +530,7 @@ static void M_GPBackup(INT32 choice) SplitScreen_OnChange(); } - const UINT8 entry = lastqueuesaved-1; + const UINT8 entry = roundqueue.position-1; SV_StartSinglePlayerServer(roundqueue.entries[entry].gametype, false); @@ -541,7 +541,7 @@ static void M_GPBackup(INT32 choice) true, 1, false, - roundqueue.entries[lastqueuesaved-1].rankrestricted + roundqueue.entries[entry].rankrestricted ); M_ClearMenus(true); @@ -549,21 +549,17 @@ static void M_GPBackup(INT32 choice) // We can't put it deeper in the menuflow due to lack of guaranteed setup restoreMenu = &MainDef; } - } - else if (choice == MA_NO) - { - if (FIL_FileExists(gpbackup)) // just in case someone deleted it while we weren't looking. - remove(gpbackup); - M_CharacterSelect(0); + return; } + + M_CharacterSelect(-1); } void M_CharacterSelect(INT32 choice) { - (void)choice; - if (currentMenu == &MainDef + && choice != -1 && FIL_FileExists(gpbackup)) { M_StartMessage( diff --git a/src/p_saveg.c b/src/p_saveg.c index 054058d93..6474e5ed9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -5968,8 +5968,6 @@ boolean P_LoadGame(savebuffer_t *save) if (!P_UnArchiveLuabanksAndConsistency(save)) goto badloadgame; - lastqueuesaved = roundqueue.position; - return true; badloadgame: