mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add per-gametype time stats
This commit is contained in:
parent
a7b3bc5938
commit
a0d52ddacd
6 changed files with 53 additions and 9 deletions
|
|
@ -4516,14 +4516,7 @@ static void G_DoCompleted(void)
|
|||
{
|
||||
if (gametype != GT_TUTORIAL)
|
||||
{
|
||||
UINT8 roundtype = GDGT_CUSTOM;
|
||||
|
||||
if (gametype == GT_RACE)
|
||||
roundtype = GDGT_RACE;
|
||||
else if (gametype == GT_BATTLE)
|
||||
roundtype = (battleprisons ? GDGT_PRISONS : GDGT_BATTLE);
|
||||
else if (gametype == GT_SPECIAL || gametype == GT_VERSUS)
|
||||
roundtype = GDGT_SPECIAL;
|
||||
UINT8 roundtype = M_GameDataGameType(gametype, battleprisons);
|
||||
|
||||
gamedata->roundsplayed[roundtype]++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ void srb2::save_ng_gamedata()
|
|||
GamedataJson ng {};
|
||||
|
||||
ng.playtime.total = gamedata->totalplaytime;
|
||||
ng.playtime.race = gamedata->modeplaytime[GDGT_RACE];
|
||||
ng.playtime.battle = gamedata->modeplaytime[GDGT_BATTLE];
|
||||
ng.playtime.prisons = gamedata->modeplaytime[GDGT_PRISONS];
|
||||
ng.playtime.special = gamedata->modeplaytime[GDGT_SPECIAL];
|
||||
ng.playtime.custom = gamedata->modeplaytime[GDGT_CUSTOM];
|
||||
ng.rings.total = gamedata->totalrings;
|
||||
ng.playtime.tumble = gamedata->totaltumbletime;
|
||||
ng.rounds.race = gamedata->roundsplayed[GDGT_RACE];
|
||||
|
|
@ -412,6 +417,11 @@ void srb2::load_ng_gamedata()
|
|||
gamedata->evercrashed = dirty;
|
||||
|
||||
gamedata->totalplaytime = js.playtime.total;
|
||||
gamedata->modeplaytime[GDGT_RACE] = js.playtime.race;
|
||||
gamedata->modeplaytime[GDGT_BATTLE] = js.playtime.battle;
|
||||
gamedata->modeplaytime[GDGT_PRISONS] = js.playtime.prisons;
|
||||
gamedata->modeplaytime[GDGT_SPECIAL] = js.playtime.special;
|
||||
gamedata->modeplaytime[GDGT_CUSTOM] = js.playtime.custom;
|
||||
gamedata->totalrings = js.rings.total;
|
||||
gamedata->totaltumbletime = js.playtime.tumble;
|
||||
gamedata->roundsplayed[GDGT_RACE] = js.rounds.race;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,23 @@ namespace srb2
|
|||
struct GamedataPlaytimeJson final
|
||||
{
|
||||
uint32_t total;
|
||||
uint32_t race;
|
||||
uint32_t battle;
|
||||
uint32_t prisons;
|
||||
uint32_t special;
|
||||
uint32_t custom;
|
||||
uint32_t tumble;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataPlaytimeJson, total, tumble)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(
|
||||
GamedataPlaytimeJson,
|
||||
total,
|
||||
race,
|
||||
battle,
|
||||
prisons,
|
||||
special,
|
||||
custom,
|
||||
tumble
|
||||
)
|
||||
};
|
||||
|
||||
struct GamedataRingsJson final
|
||||
|
|
|
|||
16
src/m_cond.c
16
src/m_cond.c
|
|
@ -652,6 +652,8 @@ void M_ClearStats(void)
|
|||
{
|
||||
UINT8 i;
|
||||
gamedata->totalplaytime = 0;
|
||||
for (i = 0; i < GDGT_MAX; ++i)
|
||||
gamedata->modeplaytime[i] = 0;
|
||||
gamedata->totalrings = 0;
|
||||
gamedata->totaltumbletime = 0;
|
||||
for (i = 0; i < GDGT_MAX; ++i)
|
||||
|
|
@ -3823,3 +3825,17 @@ boolean M_UseAlternateTitleScreen(void)
|
|||
extern consvar_t cv_alttitle;
|
||||
return cv_alttitle.value && M_SecretUnlocked(SECRET_ALTTITLE, true);
|
||||
}
|
||||
|
||||
INT32 M_GameDataGameType(INT32 lgametype, boolean lbattleprisons)
|
||||
{
|
||||
INT32 playtimemode = GDGT_CUSTOM;
|
||||
if (lgametype == GT_RACE)
|
||||
playtimemode = GDGT_RACE;
|
||||
else if (lgametype == GT_BATTLE)
|
||||
playtimemode = lbattleprisons ? GDGT_PRISONS : GDGT_BATTLE;
|
||||
else if (lgametype == GT_SPECIAL || lgametype == GT_VERSUS)
|
||||
playtimemode = GDGT_SPECIAL;
|
||||
|
||||
return playtimemode;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -369,6 +369,7 @@ struct gamedata_t
|
|||
|
||||
// PLAY TIME
|
||||
UINT32 totalplaytime;
|
||||
UINT32 modeplaytime[GDGT_MAX];
|
||||
UINT32 roundsplayed[GDGT_MAX];
|
||||
UINT32 totalrings;
|
||||
UINT32 totaltumbletime;
|
||||
|
|
@ -495,6 +496,7 @@ UINT16 M_EmblemMapNum(emblem_t *emblem);
|
|||
#define M_Achieved(a) ((a) >= MAXCONDITIONSETS || gamedata->achieved[a])
|
||||
|
||||
boolean M_UseAlternateTitleScreen(void);
|
||||
INT32 M_GameDataGameType(INT32 gametype, boolean battleprisons);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
|
|
@ -944,6 +944,15 @@ void P_Ticker(boolean run)
|
|||
// Keep track of how long they've been playing!
|
||||
gamedata->totalplaytime++;
|
||||
|
||||
if (gametype != GT_TUTORIAL)
|
||||
{
|
||||
INT32 mode = M_GameDataGameType(gametype, battleprisons);
|
||||
if (mode >= 0 && mode < GDGT_MAX)
|
||||
{
|
||||
gamedata->modeplaytime[mode]++;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO would this be laggy with more conditions in play...
|
||||
if (
|
||||
(leveltime > introtime
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue