From 3ebe23515486d7e1c6f24d5f41ca977c05653413 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Thu, 29 Feb 2024 19:38:24 -0600 Subject: [PATCH] Add total netgame time stat --- src/g_gamedata.cpp | 2 ++ src/g_gamedata.h | 2 ++ src/m_cond.c | 1 + src/m_cond.h | 1 + src/p_tick.c | 6 ++++++ 5 files changed, 12 insertions(+) diff --git a/src/g_gamedata.cpp b/src/g_gamedata.cpp index b8f54656d..6779f2917 100644 --- a/src/g_gamedata.cpp +++ b/src/g_gamedata.cpp @@ -46,6 +46,7 @@ void srb2::save_ng_gamedata() GamedataJson ng {}; ng.playtime.total = gamedata->totalplaytime; + ng.playtime.netgame = gamedata->totalnetgametime; ng.playtime.race = gamedata->modeplaytime[GDGT_RACE]; ng.playtime.battle = gamedata->modeplaytime[GDGT_BATTLE]; ng.playtime.prisons = gamedata->modeplaytime[GDGT_PRISONS]; @@ -429,6 +430,7 @@ void srb2::load_ng_gamedata() gamedata->evercrashed = dirty; gamedata->totalplaytime = js.playtime.total; + gamedata->totalnetgametime = js.playtime.netgame; gamedata->modeplaytime[GDGT_RACE] = js.playtime.race; gamedata->modeplaytime[GDGT_BATTLE] = js.playtime.battle; gamedata->modeplaytime[GDGT_PRISONS] = js.playtime.prisons; diff --git a/src/g_gamedata.h b/src/g_gamedata.h index 1c7260c81..21d9c79be 100644 --- a/src/g_gamedata.h +++ b/src/g_gamedata.h @@ -27,6 +27,7 @@ namespace srb2 struct GamedataPlaytimeJson final { uint32_t total; + uint32_t netgame; uint32_t race; uint32_t battle; uint32_t prisons; @@ -39,6 +40,7 @@ struct GamedataPlaytimeJson final NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT( GamedataPlaytimeJson, total, + netgame, race, battle, prisons, diff --git a/src/m_cond.c b/src/m_cond.c index 019f10ada..4d6ac752d 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -652,6 +652,7 @@ void M_ClearStats(void) { UINT8 i; gamedata->totalplaytime = 0; + gamedata->totalnetgametime = 0; for (i = 0; i < GDGT_MAX; ++i) gamedata->modeplaytime[i] = 0; gamedata->totalmenutime = 0; diff --git a/src/m_cond.h b/src/m_cond.h index 25abd437b..8d1281ad2 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -369,6 +369,7 @@ struct gamedata_t // PLAY TIME UINT32 totalplaytime; + UINT32 totalnetgametime; UINT32 modeplaytime[GDGT_MAX]; UINT32 totalmenutime; UINT32 totaltimestaringatstatistics; diff --git a/src/p_tick.c b/src/p_tick.c index a42161ce5..76cecc57b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -944,6 +944,12 @@ void P_Ticker(boolean run) // Keep track of how long they've been playing! gamedata->totalplaytime++; + // Netgame total time + if (netgame) + { + gamedata->totalnetgametime++; + } + // Per-skin total playtime for all machine-local players for (i = 0; i < MAXPLAYERS; i++) {