Skip to content

Commit

Permalink
- Simplify i_time to make it more clear what is being calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Nov 12, 2017
1 parent 93e9c38 commit e0ae57d
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 157 deletions.
2 changes: 1 addition & 1 deletion src/c_bind.cpp
Expand Up @@ -744,7 +744,7 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds)
dclick = false;

// This used level.time which didn't work outside a level.
nowtime = I_MSTime();
nowtime = PresentTime.Milliseconds;
if (doublebinds != NULL && DClickTime[ev->data1] > nowtime && ev->type == EV_KeyDown)
{
// Key pressed for a double click
Expand Down
2 changes: 1 addition & 1 deletion src/c_console.cpp
Expand Up @@ -529,7 +529,7 @@ static void maybedrawnow (bool tick, bool force)
|| gamestate == GS_STARTUP))
{
static size_t lastprinttime = 0;
size_t nowtime = I_GetTime();
size_t nowtime = PresentTime.Milliseconds;

if (nowtime - lastprinttime > 1 || force)
{
Expand Down
10 changes: 5 additions & 5 deletions src/d_main.cpp
Expand Up @@ -281,7 +281,7 @@ void D_ProcessEvents (void)
{
M_SetDefaultMode ();
}
else if (testingmode <= I_GetTime())
else if (testingmode <= PresentTime.Tic)
{
M_RestoreMode ();
}
Expand Down Expand Up @@ -779,7 +779,7 @@ void D_Display ()


{
unsigned int nowtime = I_FPSTime();
unsigned int nowtime = PresentTime.Milliseconds;
TexMan.UpdateAnimations(nowtime);
R_UpdateSky(nowtime);
switch (gamestate)
Expand Down Expand Up @@ -945,15 +945,15 @@ void D_Display ()
I_FreezeTime(true);
screen->WipeEndScreen ();

wipestart = I_MSTime();
wipestart = PresentTime.Milliseconds;
NetUpdate(); // send out any new accumulation

do
{
do
{
I_WaitVBL(2);
nowtime = I_MSTime();
nowtime = PresentTime.Milliseconds;
diff = (nowtime - wipestart) * 40 / 1000; // Using 35 here feels too slow.
} while (diff < 1);
wipestart = nowtime;
Expand Down Expand Up @@ -1031,7 +1031,7 @@ void D_DoomLoop ()
lasttic = gametic;
I_StartFrame ();
}
I_SetFrameTime();
I_SetupFramePresentTime();

// process one or more tics
if (singletics)
Expand Down
29 changes: 14 additions & 15 deletions src/d_net.cpp
Expand Up @@ -532,15 +532,15 @@ void HSendPacket (int node, int len)
{
PacketStore store;
store.message = doomcom;
store.timer = I_GetTime() + ((net_fakelatency / 2) / (1000 / TICRATE));
store.timer = PresentTime.Tic + ((net_fakelatency / 2) / (1000 / TICRATE));
OutBuffer.Push(store);
}
else
I_NetCmd();

for (unsigned int i = 0; i < OutBuffer.Size(); i++)
{
if (OutBuffer[i].timer <= I_GetTime())
if (OutBuffer[i].timer <= PresentTime.Tic)
{
doomcom = OutBuffer[i].message;
I_NetCmd();
Expand Down Expand Up @@ -581,7 +581,7 @@ bool HGetPacket (void)
{
PacketStore store;
store.message = doomcom;
store.timer = I_GetTime() + ((net_fakelatency / 2) / (1000 / TICRATE));
store.timer = PresentTime.Tic + ((net_fakelatency / 2) / (1000 / TICRATE));
InBuffer.Push(store);
doomcom.remotenode = -1;
}
Expand All @@ -591,7 +591,7 @@ bool HGetPacket (void)
bool gotmessage = false;
for (unsigned int i = 0; i < InBuffer.Size(); i++)
{
if (InBuffer[i].timer <= I_GetTime())
if (InBuffer[i].timer <= PresentTime.Tic)
{
doomcom = InBuffer[i].message;
InBuffer.Delete(i);
Expand Down Expand Up @@ -783,7 +783,7 @@ void GetPackets (void)
// [RH] Get "ping" times - totally useless, since it's bound to the frequency
// packets go out at.
lastrecvtime[netconsole] = currrecvtime[netconsole];
currrecvtime[netconsole] = I_MSTime ();
currrecvtime[netconsole] = I_ClockTimeMS();

// check for exiting the game
if (netbuffer[0] & NCMD_EXIT)
Expand Down Expand Up @@ -957,7 +957,7 @@ void NetUpdate (void)
}

// check time
nowtime = I_GetTime ();
nowtime = PresentTime.Tic;
newtics = nowtime - gametime;
gametime = nowtime;

Expand Down Expand Up @@ -1827,12 +1827,10 @@ void TryRunTics (void)
// get real tics
if (doWait)
{
entertic = I_WaitForTic (oldentertics);
}
else
{
entertic = I_GetTime ();
I_WaitForTic(oldentertics);
}

entertic = PresentTime.Tic;
realtics = entertic - oldentertics;
oldentertics = entertic;

Expand Down Expand Up @@ -1914,7 +1912,8 @@ void TryRunTics (void)
Net_CheckLastReceived (counts);

// don't stay in here forever -- give the menu a chance to work
if (I_GetTime () - entertic >= 1)
I_SetupFramePresentTime();
if (PresentTime.Tic - entertic >= 1)
{
C_Ticker ();
M_Ticker ();
Expand All @@ -1929,7 +1928,7 @@ void TryRunTics (void)
hadlate = false;
for (i = 0; i < MAXPLAYERS; i++)
players[i].waiting = false;
lastglobalrecvtime = I_GetTime (); //Update the last time the game tic'd over
lastglobalrecvtime = PresentTime.Tic; //Update the last time the game tic'd over

// run the count tics
if (counts > 0)
Expand Down Expand Up @@ -1962,9 +1961,9 @@ void Net_CheckLastReceived (int counts)
{
// [Ed850] Check to see the last time a packet was received.
// If it's longer then 3 seconds, a node has likely stalled.
if (I_GetTime() - lastglobalrecvtime >= TICRATE * 3)
if (PresentTime.Tic - lastglobalrecvtime >= TICRATE * 3)
{
lastglobalrecvtime = I_GetTime(); //Bump the count
lastglobalrecvtime = PresentTime.Tic; //Bump the count

if (NetMode == NET_PeerToPeer || consoleplayer == Net_Arbitrator)
{
Expand Down
2 changes: 1 addition & 1 deletion src/dobject.cpp
Expand Up @@ -615,7 +615,7 @@ void DObject::CheckIfSerialized () const

DEFINE_ACTION_FUNCTION(DObject, MSTime)
{
ACTION_RETURN_INT(I_MSTime());
ACTION_RETURN_INT(PresentTime.Milliseconds);
}

void *DObject::ScriptVar(FName field, PType *type)
Expand Down
2 changes: 1 addition & 1 deletion src/g_game.cpp
Expand Up @@ -2889,7 +2889,7 @@ bool G_CheckDemoStatus (void)
int endtime = 0;

if (timingdemo)
endtime = I_GetTime () - starttime;
endtime = PresentTime.Tic - starttime;

C_RestoreCVars (); // [RH] Restore cvars demo might have changed
M_Free (demobuffer);
Expand Down
2 changes: 1 addition & 1 deletion src/g_level.cpp
Expand Up @@ -1021,7 +1021,7 @@ void G_DoLoadLevel (int position, bool autosave)

if (firstTime)
{
starttime = I_GetTime ();
starttime = PresentTime.Tic;
firstTime = false;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/gl/scene/gl_scene.cpp
Expand Up @@ -889,8 +889,15 @@ void FGLRenderer::RenderView (player_t* player, unsigned int nowtime)
ResetProfilingData();

// Get this before everything else
if (cl_capfps || r_NoInterpolate) r_viewpoint.TicFrac = 1.;
else r_viewpoint.TicFrac = I_GetTimeFrac (&r_viewpoint.FrameTime);
if (cl_capfps || r_NoInterpolate)
{
r_viewpoint.TicFrac = 1.;
}
else
{
r_viewpoint.FrameTime = PresentTime.Tic;
r_viewpoint.TicFrac = PresentTime.TicFrac;
}
gl_frameMS = nowtime;

P_FindParticleSubsectors ();
Expand Down
8 changes: 4 additions & 4 deletions src/gl/utility/gl_clock.cpp
Expand Up @@ -188,7 +188,7 @@ ADD_STAT(rendertimes)
{
static FString buff;
static int lasttime=0;
int t=I_FPSTime();
int t= I_ClockTimeMS();
if (t-lasttime>1000)
{
buff.Truncate(0);
Expand Down Expand Up @@ -226,7 +226,7 @@ void CheckBench()
{
// if we started the FPS counter ourselves or ran from the console
// we need to wait for it to stabilize before using it.
if (waitstart > 0 && I_MSTime() < waitstart + 5000) return;
if (waitstart > 0 && I_ClockTimeMS() < waitstart + 5000) return;

FString compose;

Expand Down Expand Up @@ -257,12 +257,12 @@ CCMD(bench)
if (vid_fps == 0)
{
vid_fps = 1;
waitstart = I_MSTime();
waitstart = I_ClockTimeMS();
switchfps = true;
}
else
{
if (ConsoleState == c_up) waitstart = I_MSTime();
if (ConsoleState == c_up) waitstart = I_ClockTimeMS();
switchfps = false;
}
C_HideConsole ();
Expand Down

0 comments on commit e0ae57d

Please sign in to comment.