From 4dcf0fd3c4420c01362ef0919637e43d241c235f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 Oct 2023 11:48:32 +0200 Subject: [PATCH] get rid of the GetStats interface function. Now that all data it retrieves is available in shared code it is no longer needed. --- source/core/gamestruct.h | 1 - source/core/savegamehelp.cpp | 4 ++-- source/core/statistics.cpp | 32 +++++++++++++++++++--------- source/games/blood/src/blood.h | 2 -- source/games/blood/src/view.cpp | 11 ---------- source/games/duke/src/duke3d.h | 1 - source/games/duke/src/game_misc.cpp | 13 ----------- source/games/exhumed/src/exhumed.cpp | 5 ----- source/games/exhumed/src/exhumed.h | 2 -- source/games/sw/src/game.cpp | 6 ------ source/games/sw/src/game.h | 3 --- 11 files changed, 24 insertions(+), 56 deletions(-) diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 584930582..ad8578eaa 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -74,7 +74,6 @@ struct GameInterface virtual void loadPalette() = 0; virtual void FreeLevelData(); virtual void PlayHudSound() {} - virtual GameStats getStats() { return {}; } virtual void MenuOpened() {} virtual void MenuClosed() {} virtual void MenuSound(EMenuSounds snd) {} diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index f1849d658..12743d6a2 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -195,8 +195,8 @@ bool WriteSavegame(const char* filename, const char *name) char buf[100]; mysnprintf(buf, countof(buf), GAMENAME " %s", GetVersionString()); auto savesig = gi->GetSaveSig(); - auto gs = gi->getStats(); - FStringf timeStr("%02d:%02d", gs.timesecnd / 60, gs.timesecnd % 60); + auto gs = PlayClock / 120; + FStringf timeStr("%02d:%02d", gs / 60, gs % 60); auto lev = currentLevel; savegameinfo.OpenWriter(true); diff --git a/source/core/statistics.cpp b/source/core/statistics.cpp index 2dcfb60f9..4af4f5a35 100644 --- a/source/core/statistics.cpp +++ b/source/core/statistics.cpp @@ -50,6 +50,8 @@ #include "engineerrors.h" #include "gamestruct.h" #include "printf.h" +#include "mapinfo.h" +#include "gamecontrol.h" CVAR(Int, savestatistics, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(String, statfile, GAMENAMELOWERCASE "stat.txt", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) @@ -65,6 +67,7 @@ struct OneLevel { int totalkills = 0, killcount = 0; int totalsecrets = 0, secretcount = 0; + int supersecrets = 0; int leveltime = 0; FString Levelname; }; @@ -137,8 +140,11 @@ static void ParseStatistics(const char *fn, TArray &statlist) int h,m,s; sc.MustGetString(); - sscanf(sc.String, "%d:%d:%d", &h, &m, &s); - session.timeneeded= ((((h*60)+m)*60)+s); + if (3 == sscanf(sc.String, "%d:%d:%d", &h, &m, &s)) + { + session.timeneeded = ((((h * 60) + m) * 60) + s); + } + else session.timeneeded = 0; sc.MustGetNumber(); session.skill=sc.Number; @@ -155,8 +161,11 @@ static void ParseStatistics(const char *fn, TArray &statlist) int hour,min,sec; sc.MustGetString(); - sscanf(sc.String, "%d:%d:%d", &hour, &min, &sec); - lstats.timeneeded= ((((hour*60)+min)*60)+sec); + if (3 == sscanf(sc.String, "%d:%d:%d", &hour, &min, &sec)) + { + lstats.timeneeded = ((((hour * 60) + min) * 60) + sec); + } + else lstats.timeneeded = 0; lstats.skill = 0; } @@ -394,12 +403,13 @@ static void StoreLevelStats() LevelData.Reserve(1); LevelData[i].Levelname = LevelName; // should never happen } - auto stat = gi->getStats(); - LevelData[i].totalkills = stat.tkill; - LevelData[i].killcount = stat.kill; - LevelData[i].totalsecrets = stat.tsecret; - LevelData[i].secretcount = stat.secret; - LevelData[i].leveltime = stat.timesecnd; + SummaryInfo info{}; + Level.fillSummary(info); + LevelData[i].totalkills = info.maxkills; + LevelData[i].killcount = info.kills; + LevelData[i].totalsecrets = info.maxsecrets; + LevelData[i].secretcount = info.secrets; + LevelData[i].leveltime = PlayClock / 120; } //========================================================================== @@ -449,6 +459,7 @@ void STAT_Update(bool endofgame) FString lsection = ExtractFileBase(LevelData[i].Levelname); lsection.ToUpper(); infostring.Format("%4d/%4d, %3d/%3d", LevelData[i].killcount, LevelData[i].totalkills, LevelData[i].secretcount, LevelData[i].totalsecrets); + if (LevelData[i].supersecrets > 0) infostring.AppendFormat(":%d", LevelData[i].supersecrets); LevelStatEntry(es, lsection, infostring, LevelData[i].leveltime); } SaveStatistics(statfile, EpisodeStatistics); @@ -494,6 +505,7 @@ FSerializer& Serialize(FSerializer& arc, const char* key, OneLevel& l, OneLevel* ("killcount", l.killcount) ("totalsecrets", l.totalsecrets) ("secretcount", l.secretcount) + ("supersecrets", l.supersecrets) ("leveltime", l.leveltime) ("levelname", l.Levelname) .EndObject(); diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index 890a20f37..cee2267a7 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -139,8 +139,6 @@ struct GameInterface : public ::GameInterface void reapplyInputBits(InputPacket* const input) override { input->actions |= gPlayer[myconnectindex].input.actions & (~(SB_BUTTON_MASK | SB_RUN | SB_WEAPONMASK_BITS) | SB_CENTERVIEW); } void doPlayerMovement(const float scaleAdjust) override { gameInput.processMovement(&gPlayer[myconnectindex].Angles, scaleAdjust); } unsigned getCrouchState() override; - - GameStats getStats() override; }; END_BLD_NS diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 131bf133c..9f23a160b 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -100,17 +100,6 @@ void viewDrawText(FFont* pFont, const char* pString, int x, int y, int nShade, i // //--------------------------------------------------------------------------- -GameStats GameInterface::getStats() -{ - return { Level.kills.got, Level.kills.max, Level.secrets.got, Level.secrets.max, gFrameCount / kTicsPerSec, gPlayer[myconnectindex].fragCount }; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void viewDrawAimedPlayerName(PLAYER* pPlayer) { if (!cl_idplayers || (pPlayer->aim.XY().isZero())) diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 04f25ec05..e4dee01a9 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -30,7 +30,6 @@ struct GameInterface : public ::GameInterface void SetupSpecialTextures(TilesetBuildInfo& info) override; bool GenerateSavePic() override; void PlayHudSound() override; - GameStats getStats() override; void MenuOpened() override; void MenuSound(EMenuSounds snd) override; bool CanSave() override; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index af8d85396..95c308843 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -49,19 +49,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) BEGIN_DUKE_NS -//--------------------------------------------------------------------------- -// -// debug output -// -//--------------------------------------------------------------------------- - -GameStats GameInterface::getStats() -{ - player_struct* p = &ps[myconnectindex]; - return { Level.kills.got, Level.kills.max, Level.secrets.got, Level.secrets.max, p->player_par / REALGAMETICSPERSEC, p->frag }; -} - - //--------------------------------------------------------------------------- // // diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 8ebc8ebe5..00654dcb3 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -524,11 +524,6 @@ bool GameInterface::CanSave() return !bRecord && !bPlayback && !bInDemo && nTotalPlayers == 1 && nFreeze == 0; } -::GameStats GameInterface::getStats() -{ - return { Level.kills.got, Level.kills.max, Level.secrets.got, Level.secrets.max, PlayClock / 120, 0 }; -} - ::GameInterface* CreateInterface() { return new GameInterface; diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 5ca484fa8..a6ac4d27a 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -242,8 +242,6 @@ struct GameInterface : public ::GameInterface void reapplyInputBits(InputPacket* const input) override { input->actions |= PlayerList[nLocalPlayer].input.actions & SB_CENTERVIEW; } void doPlayerMovement(const float scaleAdjust) override { gameInput.processMovement(&PlayerList[nLocalPlayer].Angles, scaleAdjust); } unsigned getCrouchState() override; - - ::GameStats getStats() override; }; diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 50dd56153..5290f97ff 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -818,12 +818,6 @@ int StdRandomRange(int range) return new GameInterface; } -GameStats GameInterface::getStats() -{ - PLAYER* pp = Player + myconnectindex; - return { Level.kills.got, Level.kills.max, Level.secrets.got, Level.secrets.max, PlayClock / 120, 0 }; -} - void GameInterface::FreeLevelData() { TerminateLevel(); diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index be0fbd34c..78adfa092 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1904,9 +1904,6 @@ struct GameInterface : public ::GameInterface const auto pp = &Player[myconnectindex]; gameInput.processMovement(&pp->Angles, scaleAdjust, 0, !pp->sop, pp->sop_control ? (3.f / 1.40625f) : 1.f); } - - - GameStats getStats() override; };