mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add per-map time stats and TA/SPB time stats
This commit is contained in:
parent
3ebe235154
commit
23e4df3c90
6 changed files with 116 additions and 1 deletions
|
|
@ -165,6 +165,13 @@ struct recorddata_t
|
|||
UINT8 mapvisited;
|
||||
recordtimes_t timeattack; ///< Best times for Time Attack
|
||||
recordtimes_t spbattack; ///< Best times for SPB Attack
|
||||
UINT32 timeplayed;
|
||||
UINT32 netgametimeplayed;
|
||||
UINT32 modetimeplayed[5];
|
||||
UINT32 timeattacktimeplayed;
|
||||
UINT32 spbattacktimeplayed;
|
||||
UINT32 rounds;
|
||||
UINT32 wins;
|
||||
};
|
||||
|
||||
#define KARTSPEED_AUTO -1
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ void srb2::save_ng_gamedata()
|
|||
|
||||
ng.playtime.total = gamedata->totalplaytime;
|
||||
ng.playtime.netgame = gamedata->totalnetgametime;
|
||||
ng.playtime.timeattack = gamedata->timeattackingtotaltime;
|
||||
ng.playtime.spbattack = gamedata->spbattackingtotaltime;
|
||||
ng.playtime.race = gamedata->modeplaytime[GDGT_RACE];
|
||||
ng.playtime.battle = gamedata->modeplaytime[GDGT_BATTLE];
|
||||
ng.playtime.prisons = gamedata->modeplaytime[GDGT_PRISONS];
|
||||
|
|
@ -145,6 +147,15 @@ void srb2::save_ng_gamedata()
|
|||
map.stats.timeattack.bestlap = mapheaderinfo[i]->records.timeattack.lap;
|
||||
map.stats.spbattack.besttime = mapheaderinfo[i]->records.spbattack.time;
|
||||
map.stats.spbattack.bestlap = mapheaderinfo[i]->records.spbattack.lap;
|
||||
map.stats.time.total = mapheaderinfo[i]->records.timeplayed;
|
||||
map.stats.time.netgame = mapheaderinfo[i]->records.netgametimeplayed;
|
||||
map.stats.time.race = mapheaderinfo[i]->records.modetimeplayed[GDGT_RACE];
|
||||
map.stats.time.battle = mapheaderinfo[i]->records.modetimeplayed[GDGT_BATTLE];
|
||||
map.stats.time.prisons = mapheaderinfo[i]->records.modetimeplayed[GDGT_PRISONS];
|
||||
map.stats.time.special = mapheaderinfo[i]->records.modetimeplayed[GDGT_SPECIAL];
|
||||
map.stats.time.custom = mapheaderinfo[i]->records.modetimeplayed[GDGT_CUSTOM];
|
||||
map.stats.time.timeattack = mapheaderinfo[i]->records.timeattacktimeplayed;
|
||||
map.stats.time.spbattack = mapheaderinfo[i]->records.spbattacktimeplayed;
|
||||
ng.maps[lumpname] = std::move(map);
|
||||
}
|
||||
for (auto unloadedmap = unloadedmapheaders; unloadedmap; unloadedmap = unloadedmap->next)
|
||||
|
|
@ -160,6 +171,15 @@ void srb2::save_ng_gamedata()
|
|||
map.stats.timeattack.bestlap = unloadedmap->records.timeattack.lap;
|
||||
map.stats.spbattack.besttime = unloadedmap->records.spbattack.time;
|
||||
map.stats.spbattack.bestlap = unloadedmap->records.spbattack.lap;
|
||||
map.stats.time.total = unloadedmap->records.timeplayed;
|
||||
map.stats.time.netgame = unloadedmap->records.netgametimeplayed;
|
||||
map.stats.time.race = unloadedmap->records.modetimeplayed[GDGT_RACE];
|
||||
map.stats.time.battle = unloadedmap->records.modetimeplayed[GDGT_BATTLE];
|
||||
map.stats.time.prisons = unloadedmap->records.modetimeplayed[GDGT_PRISONS];
|
||||
map.stats.time.special = unloadedmap->records.modetimeplayed[GDGT_SPECIAL];
|
||||
map.stats.time.custom = unloadedmap->records.modetimeplayed[GDGT_CUSTOM];
|
||||
map.stats.time.timeattack = unloadedmap->records.timeattacktimeplayed;
|
||||
map.stats.time.spbattack = unloadedmap->records.spbattacktimeplayed;
|
||||
ng.maps[lumpname] = std::move(map);
|
||||
}
|
||||
for (int i = 0; i < gamedata->numspraycans; i++)
|
||||
|
|
@ -431,6 +451,8 @@ void srb2::load_ng_gamedata()
|
|||
|
||||
gamedata->totalplaytime = js.playtime.total;
|
||||
gamedata->totalnetgametime = js.playtime.netgame;
|
||||
gamedata->timeattackingtotaltime = js.playtime.timeattack;
|
||||
gamedata->spbattackingtotaltime = js.playtime.spbattack;
|
||||
gamedata->modeplaytime[GDGT_RACE] = js.playtime.race;
|
||||
gamedata->modeplaytime[GDGT_BATTLE] = js.playtime.battle;
|
||||
gamedata->modeplaytime[GDGT_PRISONS] = js.playtime.prisons;
|
||||
|
|
@ -582,6 +604,15 @@ void srb2::load_ng_gamedata()
|
|||
dummyrecord.timeattack.lap = mappair.second.stats.timeattack.bestlap;
|
||||
dummyrecord.spbattack.time = mappair.second.stats.spbattack.besttime;
|
||||
dummyrecord.spbattack.lap = mappair.second.stats.spbattack.bestlap;
|
||||
dummyrecord.timeplayed = mappair.second.stats.time.total;
|
||||
dummyrecord.netgametimeplayed = mappair.second.stats.time.netgame;
|
||||
dummyrecord.modetimeplayed[GDGT_RACE] = mappair.second.stats.time.race;
|
||||
dummyrecord.modetimeplayed[GDGT_BATTLE] = mappair.second.stats.time.battle;
|
||||
dummyrecord.modetimeplayed[GDGT_PRISONS] = mappair.second.stats.time.prisons;
|
||||
dummyrecord.modetimeplayed[GDGT_SPECIAL] = mappair.second.stats.time.special;
|
||||
dummyrecord.modetimeplayed[GDGT_CUSTOM] = mappair.second.stats.time.custom;
|
||||
dummyrecord.timeattacktimeplayed = mappair.second.stats.time.timeattack;
|
||||
dummyrecord.spbattacktimeplayed = mappair.second.stats.time.spbattack;
|
||||
|
||||
if (mapnum < nummapheaders && mapheaderinfo[mapnum])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ struct GamedataPlaytimeJson final
|
|||
{
|
||||
uint32_t total;
|
||||
uint32_t netgame;
|
||||
uint32_t timeattack;
|
||||
uint32_t spbattack;
|
||||
uint32_t race;
|
||||
uint32_t battle;
|
||||
uint32_t prisons;
|
||||
|
|
@ -41,6 +43,8 @@ struct GamedataPlaytimeJson final
|
|||
GamedataPlaytimeJson,
|
||||
total,
|
||||
netgame,
|
||||
timeattack,
|
||||
spbattack,
|
||||
race,
|
||||
battle,
|
||||
prisons,
|
||||
|
|
@ -194,12 +198,44 @@ struct GamedataMapStatsSpbAttackJson final
|
|||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataMapStatsSpbAttackJson, besttime, bestlap)
|
||||
};
|
||||
|
||||
struct GamedataMapStatsPlaytimeJson final
|
||||
{
|
||||
uint32_t total;
|
||||
uint32_t netgame;
|
||||
uint32_t race;
|
||||
uint32_t battle;
|
||||
uint32_t prisons;
|
||||
uint32_t special;
|
||||
uint32_t custom;
|
||||
uint32_t timeattack;
|
||||
uint32_t spbattack;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(
|
||||
GamedataMapStatsPlaytimeJson,
|
||||
total,
|
||||
netgame,
|
||||
race,
|
||||
battle,
|
||||
prisons,
|
||||
special,
|
||||
custom,
|
||||
timeattack,
|
||||
spbattack
|
||||
)
|
||||
};
|
||||
|
||||
struct GamedataMapStatsJson final
|
||||
{
|
||||
GamedataMapStatsTimeAttackJson timeattack;
|
||||
GamedataMapStatsSpbAttackJson spbattack;
|
||||
GamedataMapStatsPlaytimeJson time;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(GamedataMapStatsJson, timeattack, spbattack)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(
|
||||
GamedataMapStatsJson,
|
||||
timeattack,
|
||||
spbattack,
|
||||
time
|
||||
)
|
||||
};
|
||||
|
||||
struct GamedataMapJson final
|
||||
|
|
|
|||
|
|
@ -653,6 +653,8 @@ void M_ClearStats(void)
|
|||
UINT8 i;
|
||||
gamedata->totalplaytime = 0;
|
||||
gamedata->totalnetgametime = 0;
|
||||
gamedata->timeattackingtotaltime = 0;
|
||||
gamedata->spbattackingtotaltime = 0;
|
||||
for (i = 0; i < GDGT_MAX; ++i)
|
||||
gamedata->modeplaytime[i] = 0;
|
||||
gamedata->totalmenutime = 0;
|
||||
|
|
|
|||
|
|
@ -370,6 +370,8 @@ struct gamedata_t
|
|||
// PLAY TIME
|
||||
UINT32 totalplaytime;
|
||||
UINT32 totalnetgametime;
|
||||
UINT32 timeattackingtotaltime;
|
||||
UINT32 spbattackingtotaltime;
|
||||
UINT32 modeplaytime[GDGT_MAX];
|
||||
UINT32 totalmenutime;
|
||||
UINT32 totaltimestaringatstatistics;
|
||||
|
|
|
|||
37
src/p_tick.c
37
src/p_tick.c
|
|
@ -941,13 +941,28 @@ void P_Ticker(boolean run)
|
|||
|
||||
if (gamedata && gamestate == GS_LEVEL && !demo.playback)
|
||||
{
|
||||
mapheader_t *mapheader;
|
||||
|
||||
mapheader = mapheaderinfo[gamemap - 1];
|
||||
|
||||
// Keep track of how long they've been playing!
|
||||
gamedata->totalplaytime++;
|
||||
|
||||
// Map playtime
|
||||
if (mapheader)
|
||||
{
|
||||
mapheader->records.timeplayed++;
|
||||
}
|
||||
|
||||
// Netgame total time
|
||||
if (netgame)
|
||||
{
|
||||
gamedata->totalnetgametime++;
|
||||
|
||||
if (mapheader)
|
||||
{
|
||||
mapheader->records.netgametimeplayed++;
|
||||
}
|
||||
}
|
||||
|
||||
// Per-skin total playtime for all machine-local players
|
||||
|
|
@ -983,6 +998,28 @@ void P_Ticker(boolean run)
|
|||
if (mode >= 0 && mode < GDGT_MAX)
|
||||
{
|
||||
gamedata->modeplaytime[mode]++;
|
||||
if (mapheader)
|
||||
{
|
||||
mapheader->records.modetimeplayed[mode]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Attacking mode playtime
|
||||
if ((modeattacking & ATTACKING_TIME) != 0)
|
||||
{
|
||||
gamedata->timeattackingtotaltime++;
|
||||
if (mapheader)
|
||||
{
|
||||
mapheader->records.timeattacktimeplayed++;
|
||||
}
|
||||
}
|
||||
else if ((modeattacking & ATTACKING_SPB) != 0)
|
||||
{
|
||||
gamedata->spbattackingtotaltime++;
|
||||
if (mapheader)
|
||||
{
|
||||
mapheader->records.spbattacktimeplayed++;
|
||||
}
|
||||
}
|
||||
|
||||
// Per-skin mode playtime
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue