- All Games: Remove remaining use of `totalclock` and associated timing code.

This commit is contained in:
Mitchell Richters 2020-08-26 09:19:21 +10:00
parent c207437a57
commit b883204f6a
11 changed files with 5 additions and 41 deletions

View File

@ -737,7 +737,6 @@ void GameInterface::app_init()
WeaponInit();
LoadSaveSetup();
LoadSavedInfo();
timerInit(120);
Printf(PRINT_NONOTIFY, "Initializing network users\n");
netInitialize(true);

View File

@ -364,8 +364,6 @@ EXTERN struct validmode_t validmode[MAXVALIDMODES];
EXTERN int32_t Numsprites;
EXTERN int16_t numsectors, numwalls;
EXTERN int32_t display_mirror;
EXTERN ClockTicks totalclock;
static inline int32_t BGetTime(void) { return (int32_t) totalclock; }
EXTERN int32_t randomseed;
EXTERN int16_t sintable[2048];
@ -596,12 +594,9 @@ TILE VARIABLES:
NUMTILES - the number of tiles found TILES.DAT.
TIMING VARIABLES:
TOTALCLOCK - When the engine is initialized, TOTALCLOCK is set to zero.
From then on, it is incremented 120 times a second by 1. That
means that the number of seconds elapsed is totalclock / 120.
NUMFRAMES - The number of times the draw3dscreen function was called
since the engine was initialized. This helps to determine frame
rate. (Frame rate = numframes * 120 / totalclock.)
rate. (Frame rate = numframes * 120 / I_GetBuildTime().)
OTHER VARIABLES:

View File

@ -8,8 +8,6 @@
// for compatibility
#define timerUninit()
int timerInit(int const tickspersecond);
void timerUpdateClock(void);
double timerGetHiTicks(void);
uint32_t timerGetTicks(void);

View File

@ -1127,7 +1127,6 @@ int32_t engineInit(void)
searchit = 0; searchstat = -1;
totalclock = 0;
g_visibility = 512;
parallaxvisibility = 512;

View File

@ -20,25 +20,3 @@ uint32_t timerGetTicks(void) { return duration_cast<milliseconds>(steady_cloc
// Returns the time since an unspecified starting time in milliseconds.
// (May be not monotonic for certain configurations.)
double timerGetHiTicks(void) { return duration<double, nano>(steady_clock::now().time_since_epoch()).count() / 1000000.0; }
int timerInit(int const tickspersecond)
{
timerticspersec = tickspersecond;
timerlastsample = steady_clock::now();
return 0;
}
void timerUpdateClock(void)
{
auto time = steady_clock::now();
auto elapsedTime = time - timerlastsample;
uint64_t numerator = (elapsedTime.count() * (uint64_t) timerticspersec * steady_clock::period::num);
uint64_t freq = steady_clock::period::den;
int n = numerator / freq;
if (n <= 0) return;
totalclock += n;
timerlastsample += n*nanoseconds(1000000000/timerticspersec);
}

View File

@ -914,8 +914,6 @@ void app_loop()
{
try
{
timerUpdateClock();
TickSubsystems();
twod->SetSize(screen->GetWidth(), screen->GetHeight());
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());

View File

@ -242,8 +242,8 @@ void S_SerializeSounds(FSerializer& arc)
}
arc.EndArray();
}
// totalclock runs on 120 fps, we need to allow a small delay here.
soundEngine->SetRestartTime((int)totalclock + 6);
// Build runs at 120 fps, we need to allow a small delay here.
soundEngine->SetRestartTime(I_GetBuildTime() + 6);
}
GSnd->Sync(false);
GSnd->UpdateSounds();

View File

@ -548,8 +548,6 @@ void ExitGame()
void InitTimer()
{
htimer = 1;
timerInit(kTimerTicks);
}
static const char* actions[] =

View File

@ -353,7 +353,7 @@ void S_Update(void)
}
listener.ListenerObject = ud.camerasprite == -1 ? nullptr : &sprite[ud.camerasprite];
soundEngine->SetListener(listener);
soundEngine->UpdateSounds(totalclock);
soundEngine->UpdateSounds(gameclock);
}

View File

@ -245,7 +245,6 @@ void GameInterface::app_init()
paletteSetColorTable(DREALMSPAL, pal.Data(), true, true);
}
timerInit(120);
InitPalette();
// sets numplayers, connecthead, connectpoint2, myconnectindex

View File

@ -604,7 +604,7 @@ void DoUpdateSounds(void)
soundEngine->SetListener(listener);
UpdateAmbients();
soundEngine->UpdateSounds(totalclock);
soundEngine->UpdateSounds(I_GetBuildTime());
}
//==========================================================================