Fix frame pacing when game lags behind

The frame timestamp should've been made at the start of the frame, not the end.
This commit is contained in:
Sally Coolatta 2022-04-27 17:02:35 -04:00 committed by Eidolon
parent 833777d773
commit 9b4e485686
2 changed files with 9 additions and 2 deletions

View file

@ -755,6 +755,8 @@ void D_SRB2Loop(void)
for (;;)
{
frameEnd = I_GetFrameTime();
if (lastwipetic)
{
oldentertics = lastwipetic;
@ -890,7 +892,6 @@ void D_SRB2Loop(void)
LUA_Step();
// Fully completed frame made.
frameEnd = I_GetFrameTime();
if (!singletics && !dedicated)
{
I_FrameCapSleep(frameEnd);

View file

@ -2157,8 +2157,14 @@ static void UpdateElapsedTics(void)
tic_t I_GetTime(void)
{
float f = 0.0f;
UpdateElapsedTics();
return (tic_t) floor(elapsed_tics);
// This needs kept in a separate variable before converting
// to tic_t, due to stupid -Wbad-function-cast error.
f = floor(elapsed_tics);
return (tic_t)f;
}
float I_GetTimeFrac(void)