Calculate game loop timing using fractional ticks

git-svn-id: https://svn.eduke32.com/eduke32@8572 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2020-01-29 11:38:06 +00:00 committed by Christoph Oelckers
parent af816fdf00
commit 8aee2f9489

View file

@ -5951,7 +5951,7 @@ MAIN_LOOP_RESTART:
ototalclock += TICSPERFRAME; ototalclock += TICSPERFRAME;
int const moveClock = (int)totalclock; auto const moveClock = totalclock;
if (((!GUICapture && (myplayer.gm & MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) if (((!GUICapture && (myplayer.gm & MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1))
&& (myplayer.gm & MODE_GAME)) && (myplayer.gm & MODE_GAME))
@ -5960,14 +5960,12 @@ MAIN_LOOP_RESTART:
G_DoMoveThings(); G_DoMoveThings();
} }
if (totalclock - moveClock >= (TICSPERFRAME>>1)) // computing a tic is taking too long.
{ // rather than tightly spinning here, go draw a frame since we're fucked anyway
// computing a tic takes longer than half a tic, so we're slowing if ((int)(totalclock - moveClock) >= (TICSPERFRAME >> 1))
// the game down. rather than tightly spinning here, go draw
// a frame since we're fucked anyway
break; break;
} }
} while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && totalclock >= ototalclock + TICSPERFRAME); while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && (int)(totalclock - ototalclock) >= TICSPERFRAME);
gameUpdate = true; gameUpdate = true;
g_gameUpdateTime = timerGetHiTicks() - gameUpdateStartTime; g_gameUpdateTime = timerGetHiTicks() - gameUpdateStartTime;