Wire up the stat counters

This commit is contained in:
GenericHeroGuy 2025-10-18 22:20:52 +02:00
parent 2a761e18aa
commit c9c56886aa
2 changed files with 20 additions and 5 deletions

View file

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

View file

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