Add total menu time stat

This commit is contained in:
Eidolon 2024-02-29 16:58:53 -06:00
parent a0d52ddacd
commit 19341b71a3
5 changed files with 12 additions and 0 deletions

View file

@ -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;

View file

@ -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
)
};

View file

@ -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();

View file

@ -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)

View file

@ -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;