From ec1041eaa22819bc123624e3d9ace7e1983c4dba Mon Sep 17 00:00:00 2001 From: Eidolon Date: Tue, 20 Feb 2024 19:29:41 -0600 Subject: [PATCH] Add support for spb attack records in json gamedata --- src/g_gamedata.cpp | 16 ++++++++++------ src/g_gamedata.h | 20 ++++++++++++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/g_gamedata.cpp b/src/g_gamedata.cpp index a685742b2..32cef1dc1 100644 --- a/src/g_gamedata.cpp +++ b/src/g_gamedata.cpp @@ -121,8 +121,10 @@ void srb2::save_ng_gamedata() map.visited.encore = mapheaderinfo[i]->records.mapvisited & MV_ENCORE; map.visited.spbattack = mapheaderinfo[i]->records.mapvisited & MV_SPBATTACK; map.visited.mysticmelody = mapheaderinfo[i]->records.mapvisited & MV_MYSTICMELODY; - map.stats.besttime = mapheaderinfo[i]->records.time; - map.stats.bestlap = mapheaderinfo[i]->records.lap; + map.stats.timeattack.besttime = mapheaderinfo[i]->records.time; + map.stats.timeattack.bestlap = mapheaderinfo[i]->records.lap; + map.stats.spbattack.besttime = 0; + map.stats.spbattack.bestlap = 0; ng.maps[lumpname] = map; } for (auto unloadedmap = unloadedmapheaders; unloadedmap; unloadedmap = unloadedmap->next) @@ -134,8 +136,10 @@ void srb2::save_ng_gamedata() map.visited.encore = unloadedmap->records.mapvisited & MV_ENCORE; map.visited.spbattack = unloadedmap->records.mapvisited & MV_SPBATTACK; map.visited.mysticmelody = unloadedmap->records.mapvisited & MV_MYSTICMELODY; - map.stats.besttime = unloadedmap->records.time; - map.stats.bestlap = unloadedmap->records.lap; + map.stats.timeattack.besttime = unloadedmap->records.time; + map.stats.timeattack.bestlap = unloadedmap->records.lap; + map.stats.spbattack.besttime = 0; + map.stats.spbattack.bestlap = 0; ng.maps[lumpname] = map; } for (int i = 0; i < gamedata->numspraycans; i++) @@ -499,8 +503,8 @@ void srb2::load_ng_gamedata() dummyrecord.mapvisited |= mappair.second.visited.encore ? MV_ENCORE : 0; dummyrecord.mapvisited |= mappair.second.visited.spbattack ? MV_SPBATTACK : 0; dummyrecord.mapvisited |= mappair.second.visited.mysticmelody ? MV_SPBATTACK : 0; - dummyrecord.lap = mappair.second.stats.bestlap; - dummyrecord.time = mappair.second.stats.besttime; + dummyrecord.time = mappair.second.stats.timeattack.besttime; + dummyrecord.lap = mappair.second.stats.timeattack.bestlap; if (mapnum < nummapheaders && mapheaderinfo[mapnum]) { diff --git a/src/g_gamedata.h b/src/g_gamedata.h index 4b9ebeb9d..b3412329c 100644 --- a/src/g_gamedata.h +++ b/src/g_gamedata.h @@ -126,12 +126,28 @@ struct GamedataMapVisitedJson final NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataMapVisitedJson, visited, beaten, encore, spbattack, mysticmelody) }; -struct GamedataMapStatsJson final +struct GamedataMapStatsTimeAttackJson final { uint32_t besttime; uint32_t bestlap; - NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataMapStatsJson, besttime, bestlap) + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataMapStatsTimeAttackJson, besttime, bestlap) +}; + +struct GamedataMapStatsSpbAttackJson final +{ + uint32_t besttime; + uint32_t bestlap; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataMapStatsSpbAttackJson, besttime, bestlap) +}; + +struct GamedataMapStatsJson final +{ + GamedataMapStatsTimeAttackJson timeattack; + GamedataMapStatsSpbAttackJson spbattack; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataMapStatsJson, timeattack, spbattack) }; struct GamedataMapJson final