Change the rules of when GP Backup occours/is deleted

- Re-saved every time you lose a life, to prevent scumming
- Force-deletion of your backup has changed
    - Don't when saying NO to the GP Backup load prompt
    - Don't when returning to titlescreen under non-DEVELOP
    - DO when starting a new Grand Prix session of any cup
This commit is contained in:
toaster 2023-06-18 18:25:55 +01:00
parent 6b1fadd9d2
commit 3e6a5fda21
6 changed files with 17 additions and 27 deletions

View file

@ -982,7 +982,6 @@ void D_ClearState(void)
cht_debug = 0; cht_debug = 0;
emeralds = 0; emeralds = 0;
memset(&luabanks, 0, sizeof(luabanks)); memset(&luabanks, 0, sizeof(luabanks));
lastqueuesaved = 0;
// In case someone exits out at the same time they start a time attack run, // In case someone exits out at the same time they start a time attack run,
// reset modeattacking // reset modeattacking

View file

@ -6241,11 +6241,6 @@ void Command_ExitGame_f(void)
{ {
INT32 i; INT32 i;
#ifndef DEVELOP
// Wipes gp backup if appropriate
G_HandleSaveLevel(true);
#endif
LUA_HookBool(false, HOOK(GameQuit)); LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame(); D_QuitNetGame();

View file

@ -51,7 +51,6 @@ extern UINT8 mapmusrng;
extern UINT32 maptol; extern UINT32 maptol;
extern INT32 cursaveslot; extern INT32 cursaveslot;
extern UINT8 lastqueuesaved;
extern UINT8 gamecomplete; extern UINT8 gamecomplete;
// Extra abilities/settings for skins (combinable stuff) // Extra abilities/settings for skins (combinable stuff)

View file

@ -123,7 +123,6 @@ precipprops_t precipprops[MAXPRECIP] =
preciptype_t precip_freeslot = PRECIP_FIRSTFREESLOT; preciptype_t precip_freeslot = PRECIP_FIRSTFREESLOT;
INT32 cursaveslot = 0; // Auto-save 1p savegame slot INT32 cursaveslot = 0; // Auto-save 1p savegame slot
UINT8 lastqueuesaved = 0;
UINT8 gamecomplete = 0; UINT8 gamecomplete = 0;
marathonmode_t marathonmode = 0; marathonmode_t marathonmode = 0;
@ -3350,6 +3349,7 @@ void G_ExitLevel(void)
else else
{ {
// Back to the menu with you. // Back to the menu with you.
G_HandleSaveLevel(true);
D_QuitNetGame(); D_QuitNetGame();
CL_Reset(); CL_Reset();
D_ClearState(); D_ClearState();
@ -4024,18 +4024,21 @@ void G_HandleSaveLevel(boolean removecondition)
return; return;
if (removecondition) if (removecondition)
{ goto doremove;
if (FIL_FileExists(gpbackup))
remove(gpbackup);
return;
}
if (gamestate != GS_LEVEL if (gamestate != GS_LEVEL
|| roundqueue.size == 0 || roundqueue.size == 0)
|| lastqueuesaved == roundqueue.position)
return; return;
if (roundqueue.position == 1)
goto doremove;
G_SaveGame(); G_SaveGame();
return;
doremove:
if (FIL_FileExists(gpbackup))
remove(gpbackup);
} }
// Next map apparatus // Next map apparatus

View file

@ -530,7 +530,7 @@ static void M_GPBackup(INT32 choice)
SplitScreen_OnChange(); SplitScreen_OnChange();
} }
const UINT8 entry = lastqueuesaved-1; const UINT8 entry = roundqueue.position-1;
SV_StartSinglePlayerServer(roundqueue.entries[entry].gametype, false); SV_StartSinglePlayerServer(roundqueue.entries[entry].gametype, false);
@ -541,7 +541,7 @@ static void M_GPBackup(INT32 choice)
true, true,
1, 1,
false, false,
roundqueue.entries[lastqueuesaved-1].rankrestricted roundqueue.entries[entry].rankrestricted
); );
M_ClearMenus(true); 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 // We can't put it deeper in the menuflow due to lack of guaranteed setup
restoreMenu = &MainDef; 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 M_CharacterSelect(INT32 choice)
{ {
(void)choice;
if (currentMenu == &MainDef if (currentMenu == &MainDef
&& choice != -1
&& FIL_FileExists(gpbackup)) && FIL_FileExists(gpbackup))
{ {
M_StartMessage( M_StartMessage(

View file

@ -5968,8 +5968,6 @@ boolean P_LoadGame(savebuffer_t *save)
if (!P_UnArchiveLuabanksAndConsistency(save)) if (!P_UnArchiveLuabanksAndConsistency(save))
goto badloadgame; goto badloadgame;
lastqueuesaved = roundqueue.position;
return true; return true;
badloadgame: badloadgame: