retrieve time in fillSummary.

This commit is contained in:
Christoph Oelckers 2023-10-01 11:59:35 +02:00
parent 4dcf0fd3c4
commit ee07ae35aa
12 changed files with 20 additions and 25 deletions

View file

@ -41,6 +41,7 @@
#include "gamecontrol.h" #include "gamecontrol.h"
#include "raze_sound.h" #include "raze_sound.h"
#include "zstring.h" #include "zstring.h"
#include "statistics.h"
FString gSkillNames[MAXSKILLS]; FString gSkillNames[MAXSKILLS];
int gDefaultVolume = 0, gDefaultSkill = 1; int gDefaultVolume = 0, gDefaultSkill = 1;
@ -263,3 +264,14 @@ MapRecord* SetupUserMap(const char* boardfilename, const char *defaultmusic)
else map->music = defaultmusic; else map->music = defaultmusic;
return map; return map;
} }
void MapLocals::fillSummary(SummaryInfo& sum)
{
sum.kills = kills.got;
sum.maxkills = kills.max;
sum.secrets = secrets.got;
sum.maxsecrets = std::max(secrets.got, secrets.max); // If we found more than there are, increase the total. Blood's secret maintenance is too broken to get right.
sum.supersecrets = superSecrets.got;
sum.time = PlayClock;
// todo: centralize the remaining info as well.
}

View file

@ -237,17 +237,7 @@ struct MapLocals
{ {
StatRecord kills, secrets, superSecrets; StatRecord kills, secrets, superSecrets;
void fillSummary(SummaryInfo& sum) void fillSummary(SummaryInfo& sum);
{
sum.kills = kills.got;
sum.maxkills = kills.max;
sum.secrets = secrets.got;
sum.maxsecrets = std::max(secrets.got, secrets.max); // If we found more than there are, increase the total. Blood's secret maintenance is too broken to get right.
sum.supersecrets = superSecrets.got;
// todo: centralize the remaining info as well.
}
void clearStats() void clearStats()
{ {

View file

@ -207,6 +207,7 @@ void ShowIntermission(MapRecord* fromMap, MapRecord* toMap, SummaryInfo* info, C
completion_(false); completion_(false);
return; return;
} }
if (info) info->time /= 120;
bool bossexit = g_bossexit; bool bossexit = g_bossexit;
g_bossexit = false; g_bossexit = false;

View file

@ -409,7 +409,7 @@ static void StoreLevelStats()
LevelData[i].killcount = info.kills; LevelData[i].killcount = info.kills;
LevelData[i].totalsecrets = info.maxsecrets; LevelData[i].totalsecrets = info.maxsecrets;
LevelData[i].secretcount = info.secrets; LevelData[i].secretcount = info.secrets;
LevelData[i].leveltime = PlayClock / 120; LevelData[i].leveltime = info.time / 120;
} }
//========================================================================== //==========================================================================
@ -483,6 +483,7 @@ void STAT_Cancel()
int STAT_GetTotalTime() int STAT_GetTotalTime()
{ {
int statval = 0; int statval = 0;
StoreLevelStats(); StoreLevelStats();
for (unsigned i = 0; i < LevelData.Size(); i++) for (unsigned i = 0; i < LevelData.Size(); i++)
{ {

View file

@ -63,6 +63,7 @@
#include "mapinfo.h" #include "mapinfo.h"
#include "razefont.h" #include "razefont.h"
#include "gamefuncs.h" #include "gamefuncs.h"
#include "statistics.h"
#include "../version.h" #include "../version.h"
@ -199,6 +200,9 @@ void DrawAltHUD(SummaryInfo* info);
void UpdateStatusBar(SummaryInfo* info) void UpdateStatusBar(SummaryInfo* info)
{ {
info->time = Scale(info->time, 1000, 120); // The statusbar expects milliseconds
info->totaltime = STAT_GetTotalTime();
if (hud_size == Hud_Althud) if (hud_size == Hud_Althud)
{ {
DrawAltHUD(info); DrawAltHUD(info);

View file

@ -86,8 +86,6 @@ void UpdateStatusBar(PLAYER* pPlayer)
sum.kills = pPlayer ? pPlayer->fragCount : 0; sum.kills = pPlayer ? pPlayer->fragCount : 0;
sum.maxkills = -3; sum.maxkills = -3;
} }
sum.time = Scale(PlayClock, 1000, 120);
sum.totaltime = STAT_GetTotalTime();
UpdateStatusBar(&sum); UpdateStatusBar(&sum);
} }

View file

@ -1296,7 +1296,6 @@ void exitlevel(MapRecord* nextlevel)
SummaryInfo info{}; SummaryInfo info{};
Level.fillSummary(info); Level.fillSummary(info);
info.time = ps[0].player_par / GameTicRate;
info.endofgame = endofgame; info.endofgame = endofgame;
Mus_Stop(); Mus_Stop();

View file

@ -102,8 +102,6 @@ void DrawStatusBar()
SummaryInfo info{}; SummaryInfo info{};
Level.fillSummary(info); Level.fillSummary(info);
info.time = Scale(PlayClock, 1000, 120);
info.totaltime = STAT_GetTotalTime();
UpdateStatusBar(&info); UpdateStatusBar(&info);
} }

View file

@ -193,7 +193,6 @@ void GameInterface::LevelCompleted(MapRecord *to_map, int skill)
SummaryInfo info{}; SummaryInfo info{};
Level.fillSummary(info); Level.fillSummary(info);
info.supersecrets = nBestLevel;// hacky override info.supersecrets = nBestLevel;// hacky override
info.time = PlayClock * GameTicRate / 120;
if (to_map) selectedlevelnew = to_map->levelNumber; if (to_map) selectedlevelnew = to_map->levelNumber;
ShowIntermission(currentLevel, to_map, &info, [=](bool) ShowIntermission(currentLevel, to_map, &info, [=](bool)
{ {

View file

@ -89,8 +89,6 @@ void DrawStatusBar()
} }
SummaryInfo info{}; SummaryInfo info{};
Level.fillSummary(info); Level.fillSummary(info);
info.time = Scale(PlayClock, 1000, 120);
info.totaltime = STAT_GetTotalTime();
UpdateStatusBar(&info); UpdateStatusBar(&info);

View file

@ -643,9 +643,6 @@ void GameInterface::LevelCompleted(MapRecord* map, int skill)
SummaryInfo info{}; SummaryInfo info{};
Level.fillSummary(info); Level.fillSummary(info);
info.time = PlayClock / 120;
ShowIntermission(currentLevel, map, &info, [=](bool) ShowIntermission(currentLevel, map, &info, [=](bool)
{ {
if (map == nullptr) if (map == nullptr)

View file

@ -85,8 +85,6 @@ void UpdateStatusBar()
SummaryInfo info{}; SummaryInfo info{};
Level.fillSummary(info); Level.fillSummary(info);
info.time = Scale(PlayClock, 1000, 120);
info.totaltime = STAT_GetTotalTime();
::UpdateStatusBar(&info); ::UpdateStatusBar(&info);