From 3e8f2796535502a0be38ad902fc3f2b2d1aa92c3 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 17 Nov 2019 08:48:42 +0000 Subject: [PATCH] Fix FPS limiting on SDL1 Was previously crashing with division-by-zero as refreshRate was not set --- SourceX/miniwin/misc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index a6a9f0007..cbd899d0d 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -173,6 +173,10 @@ bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) ErrSdl(); } +#ifdef USE_SDL1 + refreshDelay = 16; // rougly 60hz +#endif + if (upscale) { #ifdef USE_SDL1 SDL_Log("upscaling not supported with USE_SDL1"); @@ -192,9 +196,7 @@ bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) } #endif } else { -#ifdef USE_SDL1 - refreshDelay = 16; // rougly 60hz -#else +#ifndef USE_SDL1 SDL_DisplayMode mode; SDL_GetDisplayMode(0, 0, &mode); refreshDelay = 1000 / mode.refresh_rate;