Make a first-class feature instead of a passworded secret

- Now called "Grand Prix Backup"
- Filename is now `gpringsav.bkp`
- Since available in standard contexts, do a little extra guarding against unsporting behaviour:
    - In non-DEVELOP builds, delete Grand Prix Backup when returning to the titlescreen/menus.
- "undo your extra work and make it more generic" - Tyron
This commit is contained in:
toaster 2023-06-17 12:53:38 +01:00
parent 304bd383de
commit 12ff436877
10 changed files with 37 additions and 69 deletions

View file

@ -140,7 +140,7 @@ UINT16 numskincolors;
menucolor_t *menucolorhead, *menucolortail; menucolor_t *menucolorhead, *menucolortail;
char savegamename[256]; char savegamename[256];
char liveeventbackup[256]; char gpbackup[256];
char srb2home[256] = "."; char srb2home[256] = ".";
char srb2path[256] = "."; char srb2path[256] = ".";
@ -1327,7 +1327,7 @@ void D_SRB2Main(void)
// default savegame // default savegame
strcpy(savegamename, SAVEGAMENAME"%u.ssg"); strcpy(savegamename, SAVEGAMENAME"%u.ssg");
strcpy(liveeventbackup, "live"SAVEGAMENAME".bkp"); // intentionally not ending with .ssg strcpy(gpbackup, "gp"SAVEGAMENAME".bkp"); // intentionally not ending with .ssg
// Init the joined IP table for quick rejoining of past games. // Init the joined IP table for quick rejoining of past games.
M_InitJoinedIPArray(); M_InitJoinedIPArray();
@ -1358,7 +1358,7 @@ void D_SRB2Main(void)
// can't use sprintf since there is %u in savegamename // can't use sprintf since there is %u in savegamename
strcatbf(savegamename, srb2home, PATHSEP); strcatbf(savegamename, srb2home, PATHSEP);
strcatbf(liveeventbackup, srb2home, PATHSEP); strcatbf(gpbackup, srb2home, PATHSEP);
snprintf(luafiledir, sizeof luafiledir, "%s" PATHSEP "luafiles", srb2home); snprintf(luafiledir, sizeof luafiledir, "%s" PATHSEP "luafiles", srb2home);
#else // DEFAULTDIR #else // DEFAULTDIR
@ -1370,7 +1370,7 @@ void D_SRB2Main(void)
// can't use sprintf since there is %u in savegamename // can't use sprintf since there is %u in savegamename
strcatbf(savegamename, userhome, PATHSEP); strcatbf(savegamename, userhome, PATHSEP);
strcatbf(liveeventbackup, userhome, PATHSEP); strcatbf(gpbackup, userhome, PATHSEP);
snprintf(luafiledir, sizeof luafiledir, "%s" PATHSEP "luafiles", userhome); snprintf(luafiledir, sizeof luafiledir, "%s" PATHSEP "luafiles", userhome);
#endif // DEFAULTDIR #endif // DEFAULTDIR

View file

@ -6241,6 +6241,11 @@ 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

@ -2997,8 +2997,8 @@ void readmaincfg(MYFILE *f, boolean mainfile)
// can't use sprintf since there is %u in savegamename // can't use sprintf since there is %u in savegamename
strcatbf(savegamename, srb2home, PATHSEP); strcatbf(savegamename, srb2home, PATHSEP);
strcpy(liveeventbackup, va("live%s.bkp", timeattackfolder)); strcpy(gpbackup, va("gp%s.bkp", timeattackfolder));
strcatbf(liveeventbackup, srb2home, PATHSEP); strcatbf(gpbackup, srb2home, PATHSEP);
refreshdirmenu |= REFRESHDIR_GAMEDATA; refreshdirmenu |= REFRESHDIR_GAMEDATA;
gamedataadded = true; gamedataadded = true;

View file

@ -519,7 +519,7 @@ void CONS_Debug(UINT32 debugflags, const char *fmt, ...) FUNCDEBUG;
// Things that used to be in dstrings.h // Things that used to be in dstrings.h
#define SAVEGAMENAME "ringsav" #define SAVEGAMENAME "ringsav"
extern char savegamename[256]; extern char savegamename[256];
extern char liveeventbackup[256]; extern char gpbackup[256];
// m_misc.h // m_misc.h
#ifdef GETTEXT #ifdef GETTEXT

View file

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

View file

@ -124,7 +124,6 @@ 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 lastqueuesaved = 0;
boolean makelivebackup = false;
UINT8 gamecomplete = 0; UINT8 gamecomplete = 0;
marathonmode_t marathonmode = 0; marathonmode_t marathonmode = 0;
@ -4018,17 +4017,16 @@ void G_UpdateVisited(void)
G_SaveGameData(); G_SaveGameData();
} }
void G_HandleSaveLevel(void) void G_HandleSaveLevel(boolean removecondition)
{ {
if (!grandprixinfo.gp || !grandprixinfo.cup if (!grandprixinfo.gp || !grandprixinfo.cup
|| splitscreen || netgame || splitscreen || netgame)
|| !(makelivebackup || cursaveslot > 0))
return; return;
if (gamestate == GS_CEREMONY && makelivebackup) if (removecondition)
{ {
if (FIL_FileExists(liveeventbackup)) if (FIL_FileExists(gpbackup))
remove(liveeventbackup); remove(gpbackup);
return; return;
} }
@ -5665,10 +5663,10 @@ void G_LoadGame(void)
// memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots
memset(&savedata, 0, sizeof(savedata)); memset(&savedata, 0, sizeof(savedata));
if (makelivebackup) //if (makelivebackup)
strcpy(savename, liveeventbackup); strcpy(savename, gpbackup);
else //else
sprintf(savename, savegamename, cursaveslot); //sprintf(savename, savegamename, cursaveslot);
if (P_SaveBufferFromFile(&save, savename) == false) if (P_SaveBufferFromFile(&save, savename) == false)
{ {
@ -5677,7 +5675,7 @@ void G_LoadGame(void)
} }
memset(vcheck, 0, sizeof (vcheck)); memset(vcheck, 0, sizeof (vcheck));
sprintf(vcheck, (makelivebackup ? "back-up %d" : "version %d"), VERSION); sprintf(vcheck, "version %d", VERSION);
if (strcmp((const char *)save.p, (const char *)vcheck)) if (strcmp((const char *)save.p, (const char *)vcheck))
{ {
M_StartMessage("Savegame Load", va(M_GetText("Save game %s from different version"), savename), NULL, MM_NOTHING, NULL, "Return to Menu"); M_StartMessage("Savegame Load", va(M_GetText("Save game %s from different version"), savename), NULL, MM_NOTHING, NULL, "Return to Menu");
@ -5718,10 +5716,10 @@ void G_SaveGame(void)
char savename[256] = ""; char savename[256] = "";
savebuffer_t save = {0}; savebuffer_t save = {0};
if (makelivebackup) //if (makelivebackup)
strcpy(savename, liveeventbackup); strcpy(savename, gpbackup);
else //else
sprintf(savename, savegamename, cursaveslot); //sprintf(savename, savegamename, cursaveslot);
gameaction = ga_nothing; gameaction = ga_nothing;
{ {
@ -5735,7 +5733,7 @@ void G_SaveGame(void)
} }
memset(name, 0, sizeof (name)); memset(name, 0, sizeof (name));
sprintf(name, (makelivebackup ? "back-up %d" : "version %d"), VERSION); sprintf(name, "version %d", VERSION);
WRITEMEM(save.p, name, VERSIONSIZE); WRITEMEM(save.p, name, VERSIONSIZE);
P_SaveGame(&save); P_SaveGame(&save);

View file

@ -187,7 +187,7 @@ void G_StartTitleCard(void);
void G_PreLevelTitleCard(void); void G_PreLevelTitleCard(void);
boolean G_IsTitleCardAvailable(void); boolean G_IsTitleCardAvailable(void);
void G_HandleSaveLevel(void); void G_HandleSaveLevel(boolean removecondition);
void G_SaveGame(void); void G_SaveGame(void);
void G_LoadGame(void); void G_LoadGame(void);

View file

@ -116,26 +116,6 @@ static UINT8 cheatf_wrongwarp(void)
return 1; return 1;
} }
static UINT8 cheatf_backup(void)
{
/*if (modifiedgame)
return 0;*/
makelivebackup = true;
M_ClearMenus(true);
S_StartSound(0, sfx_kc42);
M_StartMessage("Live Event Mode",
M_GetText(
"Your progression in GP cups will be.\n"
"backed up whenever you complete a\n"
"round, in case of game crashes.\n"
), NULL, MM_NOTHING, NULL, NULL);
return 1;
}
#ifdef DEVELOP #ifdef DEVELOP
static UINT8 cheatf_devmode(void) static UINT8 cheatf_devmode(void)
{ {
@ -172,16 +152,6 @@ static cheatseq_t cheat_wrongwarp = {
(UINT8[]){ SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff } (UINT8[]){ SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff }
}; };
static cheatseq_t cheat_backup1 = {
NULL, cheatf_backup,
(UINT8[]){ SCRAMBLE('s'), SCRAMBLE('a'), SCRAMBLE('v'), SCRAMBLE('e'), SCRAMBLE('t'), SCRAMBLE('h'), SCRAMBLE('e'), SCRAMBLE('f'), SCRAMBLE('r'), SCRAMBLE('a'), SCRAMBLE('m'), SCRAMBLE('e'), SCRAMBLE('s'), 0xff }
};
static cheatseq_t cheat_backup2 = {
NULL, cheatf_backup,
(UINT8[]){ SCRAMBLE('s'), SCRAMBLE('a'), SCRAMBLE('v'), SCRAMBLE('e'), SCRAMBLE('t'), SCRAMBLE('h'), SCRAMBLE('e'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('i'), SCRAMBLE('m'), SCRAMBLE('a'), SCRAMBLE('l'), SCRAMBLE('s'), 0xff }
};
#ifdef DEVELOP #ifdef DEVELOP
static cheatseq_t cheat_devmode = { static cheatseq_t cheat_devmode = {
NULL, cheatf_devmode, NULL, cheatf_devmode,
@ -193,8 +163,6 @@ cheatseq_t *cheatseqlist[] =
{ {
&cheat_warp, &cheat_warp,
&cheat_wrongwarp, &cheat_wrongwarp,
&cheat_backup1,
&cheat_backup2,
#ifdef DEVELOP #ifdef DEVELOP
&cheat_devmode, &cheat_devmode,
#endif #endif

View file

@ -487,11 +487,10 @@ void M_CharacterSelectInit(void)
} }
static void M_MarathonLiveEventBackup(INT32 choice) static void M_GPBackup(INT32 choice)
{ {
if (choice == MA_YES) if (choice == MA_YES)
{ {
makelivebackup = true;
G_LoadGame(); G_LoadGame();
if (savedata.lives != 0) if (savedata.lives != 0)
@ -550,8 +549,8 @@ static void M_MarathonLiveEventBackup(INT32 choice)
} }
else if (choice == MA_NO) else if (choice == MA_NO)
{ {
if (FIL_FileExists(liveeventbackup)) // just in case someone deleted it while we weren't looking. if (FIL_FileExists(gpbackup)) // just in case someone deleted it while we weren't looking.
remove(liveeventbackup); remove(gpbackup);
M_CharacterSelect(0); M_CharacterSelect(0);
} }
@ -562,14 +561,13 @@ void M_CharacterSelect(INT32 choice)
(void)choice; (void)choice;
if (currentMenu == &MainDef if (currentMenu == &MainDef
&& FIL_FileExists(liveeventbackup)) && FIL_FileExists(gpbackup))
{ {
M_StartMessage( M_StartMessage(
"Live Event Backup", "Grand Prix Backup",
"A Live Event Backup was found.\n" "A Grand Prix Backup was found.\n"
"Do you want to resurrect the last run?\n" "Do you want to resurrect the last session?\n",
"(Fs in chat if we crashed on stream.)\n", M_GPBackup,
M_MarathonLiveEventBackup,
MM_YESNO, MM_YESNO,
"Resume the last run", "Resume the last run",
"Delete, play another way"); "Delete, play another way");

View file

@ -8362,7 +8362,7 @@ void P_PostLoadLevel(void)
P_RunCachedActions(); P_RunCachedActions();
G_HandleSaveLevel(); G_HandleSaveLevel(gamestate == GS_CEREMONY);
if (marathonmode & MA_INGAME) if (marathonmode & MA_INGAME)
{ {