From c9c56886aa8ecef5ed08c942d1b65b36add0ff4d Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sat, 18 Oct 2025 22:20:52 +0200 Subject: [PATCH] Wire up the stat counters --- src/g_game.c | 8 +++----- src/k_stats.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 56d129986..584ce61bc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -616,8 +616,8 @@ maprecordpreset_t *G_AllocateMapRecordPreset(maprecord_t *record, const char *pr *preset = (maprecordpreset_t){ .prename = {0}, .version = version, - .bestlap = UINT32_MAX, - .besttime = UINT32_MAX, + .bestlap = 0, + .besttime = 0, .playtime = 0, }; strlcpy(preset->prename, presetname, sizeof(preset->prename)); @@ -2604,7 +2604,7 @@ static inline void G_PlayerFinishLevel(INT32 player) { if (legitimateexit && !demo.playback && !mapreset) // (yes you're allowed to unlock stuff this way when the game is modified) { - kartstats.matchesplayed++; + K_StatRound(); if (M_UpdateUnlockablesAndExtraEmblems()) S_StartSound(NULL, sfx_ncitem); G_SaveGameData(); @@ -4499,8 +4499,6 @@ static void G_DoCompleted(void) G_SetGamestate(GS_NULL); wipegamestate = GS_NULL; - K_StatRound(); - for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) diff --git a/src/k_stats.c b/src/k_stats.c index bfa177167..e5bcef4a9 100644 --- a/src/k_stats.c +++ b/src/k_stats.c @@ -11,12 +11,20 @@ void K_StatTicker(void) if (demo.playback) return; + maprecord_t *record = G_AllocateMapRecord(G_BuildMapName(gamemap)); + record->playtime++; kartstats.totalplaytime++; if (netgame) + { kartstats.onlineplaytime++; + } else if (modeattacking) + { + maprecordpreset_t *preset = G_AllocateMapRecordPreset(record, currentrecordpreset, currentrecordpresetversion); + preset->playtime++; kartstats.raplaytime++; + } if (gametype == GT_RACE) kartstats.raceplaytime++; @@ -68,6 +76,10 @@ void K_StatRound(void) if (demo.playback) return; + maprecord_t *record = G_AllocateMapRecord(G_BuildMapName(gamemap)); + record->roundsplayed++; + kartstats.matchesplayed++; + int numplayers = 0; for (int i = 0; i < MAXPLAYERS; ++i) @@ -79,9 +91,14 @@ void K_StatRound(void) if (numplayers > 1 && !players[consoleplayer].spectator) { if (players[consoleplayer].position == 1) + { + record->roundswon++; kartstats.totalwins++; + } else if (players[consoleplayer].position <= 3) // Should this check if there are more than 3 players in game? + { kartstats.totalpodium++; + } } }