mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 15:02:39 +00:00
fixed time printing.
- In ZDoom the timer runs a bit too fast because roundoff errors make 35 tics only last 0.98 seconds. None of the internal timing has been changed, only the places where a time value is printed it will get adjusted for this discrepancy.
This commit is contained in:
parent
1fcde91298
commit
259466c3d4
7 changed files with 56 additions and 26 deletions
21
src/cmdlib.h
21
src/cmdlib.h
|
@ -62,4 +62,25 @@ struct FFileList
|
|||
|
||||
void ScanDirectory(TArray<FFileList> &list, const char *dirpath);
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Functions to compensate for a tic being a bit short.
|
||||
// Since ZDoom uses a milliseconds timer for game timing
|
||||
// 35 tics are actually only 0.98 seconds.
|
||||
// For real time display this needs to be adjusted
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
inline int AdjustTics(int tics)
|
||||
{
|
||||
return (tics * 98) / 100;
|
||||
}
|
||||
|
||||
inline int Tics2Seconds(int tics)
|
||||
{
|
||||
return (tics * 98) / (100 * TICRATE);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -886,8 +886,11 @@ class CommandDrawString : public SBarInfoCommand
|
|||
}
|
||||
break;
|
||||
case TIME:
|
||||
str.Format("%02d:%02d:%02d", (level.time/TICRATE)/3600, ((level.time/TICRATE)%3600)/60, (level.time/TICRATE)%60);
|
||||
{
|
||||
int sec = Tics2Seconds(level.time);
|
||||
str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60);
|
||||
break;
|
||||
}
|
||||
case LOGTEXT:
|
||||
str = statusBar->CPlayer->LogText;
|
||||
break;
|
||||
|
|
|
@ -867,7 +867,7 @@ static void DrawTime()
|
|||
: (hud_showtime < 6
|
||||
? level.time
|
||||
: level.totaltime);
|
||||
const int timeSeconds = timeTicks / TICRATE;
|
||||
const int timeSeconds = Tics2Seconds(timeTicks);
|
||||
|
||||
hours = timeSeconds / 3600;
|
||||
minutes = (timeSeconds % 3600) / 60;
|
||||
|
@ -994,7 +994,7 @@ void DrawHUD()
|
|||
|
||||
if (am_showtotaltime)
|
||||
{
|
||||
seconds = level.totaltime / TICRATE;
|
||||
seconds = Tics2Seconds(level.totaltime);
|
||||
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
|
||||
DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT);
|
||||
bottom -= fonth;
|
||||
|
@ -1004,14 +1004,14 @@ void DrawHUD()
|
|||
{
|
||||
if (level.clusterflags&CLUSTER_HUB)
|
||||
{
|
||||
seconds = level.time /TICRATE;
|
||||
seconds = Tics2Seconds(level.time);
|
||||
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
|
||||
DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT);
|
||||
bottom -= fonth;
|
||||
}
|
||||
|
||||
// Single level time for hubs
|
||||
seconds= level.maptime /TICRATE;
|
||||
seconds= Tics2Seconds(level.maptime);
|
||||
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
|
||||
DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT);
|
||||
}
|
||||
|
|
|
@ -1306,8 +1306,8 @@ void DBaseStatusBar::Draw (EHudState state)
|
|||
}
|
||||
else if (automapactive)
|
||||
{
|
||||
int y, time = level.time / TICRATE, height;
|
||||
int totaltime = level.totaltime / TICRATE;
|
||||
int y, time = Tics2Seconds(level.time), height;
|
||||
int totaltime = Tics2Seconds(level.totaltime);
|
||||
EColorRange highlight = (gameinfo.gametype & GAME_DoomChex) ?
|
||||
CR_UNTRANSLATED : CR_YELLOW;
|
||||
|
||||
|
|
|
@ -586,29 +586,33 @@ private:
|
|||
screen->DrawTexture (Images[back], left, top, DTA_CleanNoMove, true, DTA_Alpha, FRACUNIT*3/4, TAG_DONE);
|
||||
screen->DrawTexture (Images[bars], left, top, DTA_CleanNoMove, true, TAG_DONE);
|
||||
|
||||
|
||||
switch (CurrentPop)
|
||||
{
|
||||
case POP_Log:
|
||||
{
|
||||
int seconds = Tics2Seconds(level.time);
|
||||
// Draw the latest log message.
|
||||
mysnprintf (buff, countof(buff), "%02d:%02d:%02d",
|
||||
(level.time/TICRATE)/3600,
|
||||
((level.time/TICRATE)%3600)/60,
|
||||
(level.time/TICRATE)%60);
|
||||
mysnprintf(buff, countof(buff), "%02d:%02d:%02d",
|
||||
seconds / 3600,
|
||||
(seconds % 3600) / 60,
|
||||
(seconds) % 60);
|
||||
|
||||
screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+210*xscale, top+8*yscale, buff,
|
||||
screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, buff,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
|
||||
if (CPlayer->LogText != NULL)
|
||||
{
|
||||
FBrokenLines *lines = V_BreakLines (SmallFont2, 272, CPlayer->LogText);
|
||||
FBrokenLines *lines = V_BreakLines(SmallFont2, 272, CPlayer->LogText);
|
||||
for (i = 0; lines[i].Width >= 0; ++i)
|
||||
{
|
||||
screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+24*xscale, top+(18+i*12)*yscale,
|
||||
screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 24 * xscale, top + (18 + i * 12)*yscale,
|
||||
lines[i].Text, DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
V_FreeBrokenLines (lines);
|
||||
V_FreeBrokenLines(lines);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case POP_Keys:
|
||||
// List the keys the player has.
|
||||
|
|
|
@ -420,7 +420,7 @@ static void StoreLevelStats()
|
|||
LevelData[i].killcount = level.killed_monsters;
|
||||
LevelData[i].totalsecrets = level.total_secrets;
|
||||
LevelData[i].secretcount = level.found_secrets;
|
||||
LevelData[i].leveltime = level.maptime;
|
||||
LevelData[i].leveltime = AdjustTics(level.maptime);
|
||||
|
||||
// Check for living monsters. On some maps it can happen
|
||||
// that the counter misses some.
|
||||
|
@ -490,7 +490,7 @@ void STAT_ChangeLevel(const char *newl)
|
|||
}
|
||||
|
||||
infostring.Format("%4d/%4d, %3d/%3d, %2d", statvals[0], statvals[1], statvals[2], statvals[3], validlevels);
|
||||
FSessionStatistics *es = StatisticsEntry(sl, infostring, level.totaltime);
|
||||
FSessionStatistics *es = StatisticsEntry(sl, infostring, AdjustTics(level.totaltime));
|
||||
|
||||
for(unsigned i = 0; i < LevelData.Size(); i++)
|
||||
{
|
||||
|
|
|
@ -1460,7 +1460,7 @@ void WI_drawDeathmatchStats ()
|
|||
// Draw game time
|
||||
y += height + CleanYfac;
|
||||
|
||||
int seconds = plrs[me].stime / TICRATE;
|
||||
int seconds = Tics2Seconds(plrs[me].stime);
|
||||
int hours = seconds / 3600;
|
||||
int minutes = (seconds % 3600) / 60;
|
||||
seconds = seconds % 60;
|
||||
|
@ -1817,9 +1817,9 @@ void WI_updateStats ()
|
|||
cnt_kills[0] = plrs[me].skills;
|
||||
cnt_items[0] = plrs[me].sitems;
|
||||
cnt_secret[0] = plrs[me].ssecret;
|
||||
cnt_time = plrs[me].stime / TICRATE;
|
||||
cnt_time = Tics2Seconds(plrs[me].stime);
|
||||
cnt_par = wbs->partime / TICRATE;
|
||||
cnt_total_time = wbs->totaltime / TICRATE;
|
||||
cnt_total_time = Tics2Seconds(wbs->totaltime);
|
||||
}
|
||||
|
||||
if (sp_state == 2)
|
||||
|
@ -1882,19 +1882,21 @@ void WI_updateStats ()
|
|||
cnt_total_time += 3;
|
||||
}
|
||||
|
||||
if (!gameinfo.intermissioncounter || cnt_time >= plrs[me].stime / TICRATE)
|
||||
cnt_time = plrs[me].stime / TICRATE;
|
||||
int sec = Tics2Seconds(plrs[me].stime);
|
||||
if (!gameinfo.intermissioncounter || cnt_time >= sec)
|
||||
cnt_time = sec;
|
||||
|
||||
if (!gameinfo.intermissioncounter || cnt_total_time >= wbs->totaltime / TICRATE)
|
||||
cnt_total_time = wbs->totaltime / TICRATE;
|
||||
int tsec = Tics2Seconds(wbs->totaltime);
|
||||
if (!gameinfo.intermissioncounter || cnt_total_time >= tsec)
|
||||
cnt_total_time = tsec;
|
||||
|
||||
if (!gameinfo.intermissioncounter || cnt_par >= wbs->partime / TICRATE)
|
||||
{
|
||||
cnt_par = wbs->partime / TICRATE;
|
||||
|
||||
if (cnt_time >= plrs[me].stime / TICRATE)
|
||||
if (cnt_time >= sec)
|
||||
{
|
||||
cnt_total_time = wbs->totaltime / TICRATE;
|
||||
cnt_total_time = tsec;
|
||||
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE);
|
||||
sp_state++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue