From 19341b71a34745e4521ab735a630463874f5ff02 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Thu, 29 Feb 2024 16:58:53 -0600 Subject: [PATCH] Add total menu time stat --- src/g_gamedata.cpp | 2 ++ src/g_gamedata.h | 2 ++ src/k_menufunc.c | 6 ++++++ src/m_cond.c | 1 + src/m_cond.h | 1 + 5 files changed, 12 insertions(+) diff --git a/src/g_gamedata.cpp b/src/g_gamedata.cpp index 14c8a15f5..6cd19aaff 100644 --- a/src/g_gamedata.cpp +++ b/src/g_gamedata.cpp @@ -51,6 +51,7 @@ void srb2::save_ng_gamedata() ng.playtime.prisons = gamedata->modeplaytime[GDGT_PRISONS]; ng.playtime.special = gamedata->modeplaytime[GDGT_SPECIAL]; ng.playtime.custom = gamedata->modeplaytime[GDGT_CUSTOM]; + ng.playtime.menus = gamedata->totalmenutime; ng.rings.total = gamedata->totalrings; ng.playtime.tumble = gamedata->totaltumbletime; ng.rounds.race = gamedata->roundsplayed[GDGT_RACE]; @@ -422,6 +423,7 @@ void srb2::load_ng_gamedata() gamedata->modeplaytime[GDGT_PRISONS] = js.playtime.prisons; gamedata->modeplaytime[GDGT_SPECIAL] = js.playtime.special; gamedata->modeplaytime[GDGT_CUSTOM] = js.playtime.custom; + gamedata->totalmenutime = js.playtime.menus; gamedata->totalrings = js.rings.total; gamedata->totaltumbletime = js.playtime.tumble; gamedata->roundsplayed[GDGT_RACE] = js.rounds.race; diff --git a/src/g_gamedata.h b/src/g_gamedata.h index f5a2ea780..f00874acd 100644 --- a/src/g_gamedata.h +++ b/src/g_gamedata.h @@ -32,6 +32,7 @@ struct GamedataPlaytimeJson final uint32_t prisons; uint32_t special; uint32_t custom; + uint32_t menus; uint32_t tumble; NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT( @@ -42,6 +43,7 @@ struct GamedataPlaytimeJson final prisons, special, custom, + menus, tumble ) }; diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 618840024..b8155c46e 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -1429,6 +1429,12 @@ void M_Ticker(void) skullAnimCounter = 8; } + if (!Playing()) + { + // Anything in M_Ticker that isn't actively playing is considered "in menus" for time tracking + gamedata->totalmenutime++; + } + if (!Playing() && !M_GameTrulyStarted()) { M_GonerBGTick(); diff --git a/src/m_cond.c b/src/m_cond.c index 49d6177a6..e113d0b9f 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -654,6 +654,7 @@ void M_ClearStats(void) gamedata->totalplaytime = 0; for (i = 0; i < GDGT_MAX; ++i) gamedata->modeplaytime[i] = 0; + gamedata->totalmenutime = 0; gamedata->totalrings = 0; gamedata->totaltumbletime = 0; for (i = 0; i < GDGT_MAX; ++i) diff --git a/src/m_cond.h b/src/m_cond.h index c8933f9a9..c90877383 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -370,6 +370,7 @@ struct gamedata_t // PLAY TIME UINT32 totalplaytime; UINT32 modeplaytime[GDGT_MAX]; + UINT32 totalmenutime; UINT32 roundsplayed[GDGT_MAX]; UINT32 totalrings; UINT32 totaltumbletime;