From 8aee2f948999f3816f057480db4e2ad17e4ef840 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 29 Jan 2020 11:38:06 +0000 Subject: [PATCH] Calculate game loop timing using fractional ticks git-svn-id: https://svn.eduke32.com/eduke32@8572 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/game.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index dd9c61efb..57e4f3465 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -5951,7 +5951,7 @@ MAIN_LOOP_RESTART: 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)) && (myplayer.gm & MODE_GAME)) @@ -5960,14 +5960,12 @@ MAIN_LOOP_RESTART: G_DoMoveThings(); } - if (totalclock - moveClock >= (TICSPERFRAME>>1)) - { - // computing a tic takes longer than half a tic, so we're slowing - // the game down. rather than tightly spinning here, go draw - // a frame since we're fucked anyway + // computing a tic is taking too long. + // rather than tightly spinning here, go draw a frame since we're fucked anyway + if ((int)(totalclock - moveClock) >= (TICSPERFRAME >> 1)) 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; g_gameUpdateTime = timerGetHiTicks() - gameUpdateStartTime;