From a1ed3f8b23f5a231f725b15bb47cd1b6a831ca22 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 10 Apr 2024 20:22:29 +0100 Subject: [PATCH] "Clear GP and Record Data" has handed off some of its respnsibilities - Map visitation flags (used for level select access) are now cleared by using "Clear Challenges Data" instead - Custom courses will still have their data completely wiped here because it's the case most likely to mean "I want to remove everything", and because I don't want to pick through all the possible places to nuke 'em - Skin stats (and Eidolon's map stats) are now cleared by using "Clear Statistics Data" instead --- src/g_game.c | 21 +++++++-------------- src/m_cond.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 56b3538a9..bf37d5657 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -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) { diff --git a/src/m_cond.c b/src/m_cond.c index 000e553a3..27aac77bc 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -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;