Merge branch 'clear-data-fixes' into 'master'

Erase Data screen now has responsibilities more properly divided

Closes #1204 and #1155

See merge request KartKrew/Kart!2263
This commit is contained in:
Oni 2024-04-12 03:40:14 +00:00
commit 283f2188db
2 changed files with 59 additions and 15 deletions

View file

@ -344,14 +344,10 @@ void G_ClearRecords(void)
{
UINT16 i;
for (i = 0; i < numskins; i++)
{
memset(&skins[i].records, 0, sizeof(skins[i].records));
}
for (i = 0; i < nummapheaders; i++)
{
memset(&mapheaderinfo[i]->records, 0, sizeof(recorddata_t));
memset(&mapheaderinfo[i]->records.timeattack, 0, sizeof(recordtimes_t));
memset(&mapheaderinfo[i]->records.spbattack, 0, sizeof(recordtimes_t));
}
cupheader_t *cup;
@ -360,14 +356,11 @@ void G_ClearRecords(void)
memset(&cup->windata, 0, sizeof(cup->windata));
}
unloaded_skin_t *unloadedskin, *nextunloadedskin = NULL;
for (unloadedskin = unloadedskins; unloadedskin; unloadedskin = nextunloadedskin)
{
nextunloadedskin = unloadedskin->next;
Z_Free(unloadedskin);
}
unloadedskins = NULL;
// TODO: Technically, these should only remove time attack records here.
// But I'm out of juice for dev (+ literally, just finished some OJ).
// The stats need to be cleared in M_ClearStats, and I guess there's
// no perfect place to wipe mapvisited because it's not actually part of
// basegame progression... so here's fine for launch. ~toast 100424
unloaded_mapheader_t *unloadedmap, *nextunloadedmap = NULL;
for (unloadedmap = unloadedmapheaders; unloadedmap; unloadedmap = nextunloadedmap)
{

View file

@ -650,7 +650,8 @@ void M_ClearConditionSet(UINT16 set)
// Clear ALL secrets.
void M_ClearStats(void)
{
UINT8 i;
UINT16 i;
gamedata->totalplaytime = 0;
gamedata->totalnetgametime = 0;
gamedata->timeattackingtotaltime = 0;
@ -678,6 +679,54 @@ void M_ClearStats(void)
gamedata->musicstate = GDMUSIC_NONE;
gamedata->importprofilewins = false;
// Skins only store stats, not progression metrics. Good to clear entirely here.
for (i = 0; i < numskins; i++)
{
memset(&skins[i].records, 0, sizeof(skins[i].records));
}
unloaded_skin_t *unloadedskin, *nextunloadedskin = NULL;
for (unloadedskin = unloadedskins; unloadedskin; unloadedskin = nextunloadedskin)
{
nextunloadedskin = unloadedskin->next;
Z_Free(unloadedskin);
}
unloadedskins = NULL;
// We retain exclusively the most important stuff from maps.
UINT8 restoremapvisited;
recordtimes_t restoretimeattack;
recordtimes_t restorespbattack;
for (i = 0; i < nummapheaders; i++)
{
restoremapvisited = mapheaderinfo[i]->records.mapvisited;
restoretimeattack = mapheaderinfo[i]->records.timeattack;
restorespbattack = mapheaderinfo[i]->records.spbattack;
memset(&mapheaderinfo[i]->records, 0, sizeof(recorddata_t));
mapheaderinfo[i]->records.mapvisited = restoremapvisited;
mapheaderinfo[i]->records.timeattack = restoretimeattack;
mapheaderinfo[i]->records.spbattack = restorespbattack;
}
unloaded_mapheader_t *unloadedmap;
for (unloadedmap = unloadedmapheaders; unloadedmap; unloadedmap = unloadedmap->next)
{
restoremapvisited = unloadedmap->records.mapvisited;
restoretimeattack = unloadedmap->records.timeattack;
restorespbattack = unloadedmap->records.spbattack;
memset(&unloadedmap->records, 0, sizeof(recorddata_t));
unloadedmap->records.mapvisited = restoremapvisited;
unloadedmap->records.timeattack = restoretimeattack;
unloadedmap->records.spbattack = restorespbattack;
}
}
void M_ClearSecrets(void)
@ -707,6 +756,8 @@ void M_ClearSecrets(void)
if (!mapheaderinfo[i])
continue;
mapheaderinfo[i]->records.mapvisited = 0;
mapheaderinfo[i]->cache_spraycan = UINT16_MAX;
mapheaderinfo[i]->cache_maplock = MAXUNLOCKABLES;