diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 16168eab5..0655e80a8 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -120,7 +120,7 @@ int32_t hud_showmapname = 1; int32_t g_levelTextTime = 0; int32_t r_maxfps = 60; -uint32_t g_frameDelay = 17; +uint64_t g_frameDelay = 17; #if defined(RENDERTYPEWIN) && defined(USE_OPENGL) extern char forcegl; @@ -6077,7 +6077,8 @@ void G_MaybeAllocPlayer(int32_t pnum) int G_FPSLimit(void) { - static uint32_t nextRender = 0, frameWaiting = 0; + static uint64_t nextPageTicks = 0; + static int frameWaiting = 0; if (frameWaiting) { @@ -6085,14 +6086,14 @@ int G_FPSLimit(void) nextpage(); } - uint32_t frameTime = getticks(); + uint64_t const frameTicks = getu64ticks(); - if (r_maxfps == 0 || frameTime >= nextRender) + if (r_maxfps == 0 || frameTicks >= nextPageTicks) { - if (frameTime > nextRender + g_frameDelay) - nextRender = frameTime; + if (frameTicks >= nextPageTicks + g_frameDelay) + nextPageTicks = frameTicks; - nextRender += g_frameDelay; + nextPageTicks += g_frameDelay; frameWaiting++; return 1; diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 4f1a0db89..a3c55d99a 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -290,7 +290,7 @@ extern int32_t MAXCACHE1DSIZE; extern palette_t CrosshairColors; extern palette_t DefaultCrosshairColors; -extern uint32_t g_frameDelay; +extern uint64_t g_frameDelay; int32_t A_CheckInventorySprite(spritetype *s); int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr, diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index aab62b062..88ec9d97d 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -2945,7 +2945,7 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption) } else if (entry == &ME_VIDEOSETUP_FRAMELIMIT) { - g_frameDelay = newOption ? Blrintf(1000.f/(float) newOption) : 0; + g_frameDelay = newOption ? (getu64tickspersec()/newOption) : 0; } switch (g_currentMenu) diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index d23cab55d..869425e83 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -1424,7 +1424,7 @@ static int32_t osdcmd_cvar_set_game(osdfuncparm_t const * const parm) else if (!Bstrcasecmp(parm->name, "r_maxfps")) { if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000); - g_frameDelay = r_maxfps ? Blrintf(1000.f/(float)r_maxfps) : 0; + g_frameDelay = r_maxfps ? (getu64tickspersec()/r_maxfps) : 0; } else if (!Bstrcasecmp(parm->name, "r_ambientlight")) {