Clear records, stats, and secrets on new in-SOC gamedata creation

- Pre-emptive sanity check to some impending work
- Move M_UpdateUnlockablesAndExtraEmblems out of M_ClearSecrets
This commit is contained in:
toaster 2023-03-04 21:09:59 +00:00
parent 5296ab1397
commit f7617e7530
4 changed files with 12 additions and 7 deletions

View file

@ -2768,6 +2768,10 @@ void readmaincfg(MYFILE *f, boolean mainfile)
clear_emblems();
//clear_levels();
doClearLevels = true;
G_ClearRecords();
M_ClearStats();
M_ClearSecrets();
}
else if (!mainfile && !gamedataadded)
{

View file

@ -4371,21 +4371,21 @@ void G_LoadGameData(void)
if (M_CheckParm("-nodata"))
{
// Don't load at all.
// The following used to be in M_ClearSecrets, but that was silly.
M_UpdateUnlockablesAndExtraEmblems(false);
return;
}
if (M_CheckParm("-resetdata"))
{
// Don't load, but do save. (essentially, reset)
gamedata->loaded = true;
return;
goto finalisegamedata;
}
if (P_SaveBufferFromFile(&save, va(pandf, srb2home, gamedatafilename)) == false)
{
// No gamedata. We can save a new one.
gamedata->loaded = true;
return;
goto finalisegamedata;
}
// Version check
@ -4550,6 +4550,8 @@ void G_LoadGameData(void)
// done
P_SaveBufferFree(&save);
finalisegamedata:
// Don't consider loaded until it's a success!
// It used to do this much earlier, but this would cause the gamedata to
// save over itself when it I_Errors from the corruption landing point below,

View file

@ -554,9 +554,6 @@ void M_ClearSecrets(void)
Z_Free(gamedata->challengegrid);
gamedata->challengegrid = NULL;
gamedata->challengegridwidth = 0;
// Re-unlock any always unlocked things
M_UpdateUnlockablesAndExtraEmblems(false);
}
// ----------------------

View file

@ -66,6 +66,8 @@ static void M_EraseDataResponse(INT32 ch)
if (optionsmenu.erasecontext & EC_CHALLENGES)
M_ClearSecrets();
M_UpdateUnlockablesAndExtraEmblems(false);
F_StartIntro();
M_ClearMenus(true);
}