From f97aee59c835f659f6a8e1777b2917258830d96b Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 9 Dec 2017 02:56:12 +0000 Subject: [PATCH] Address issue where timers will no longer update after several hours of runtime git-svn-id: https://svn.eduke32.com/eduke32@6543 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/winbits.h | 2 ++ source/build/src/engine.cpp | 4 +--- source/build/src/sdlayer.cpp | 26 +++++++++----------------- source/build/src/winbits.cpp | 3 ++- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/source/build/include/winbits.h b/source/build/include/winbits.h index 9f15f2cb7..6518e8e36 100644 --- a/source/build/include/winbits.h +++ b/source/build/include/winbits.h @@ -14,8 +14,10 @@ extern BOOL CheckWinVersion(void); extern void win_allowtaskswitching(int32_t onf); extern int32_t win_checkinstance(void); +#if defined(RENDERTYPEWIN) || SDL_MAJOR_VERSION==1 extern int32_t win_inittimer(void); extern uint64_t win_getu64ticks(void); +#endif extern void win_open(void); extern void win_init(void); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 2ce56e453..8945dd07c 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -7160,8 +7160,6 @@ static int32_t loadtables(void) initksqrt(); - initdivtables(); - for (i=0; i<2048; i++) reciptable[i] = divscale30(2048, i+2048); @@ -7600,8 +7598,8 @@ static uspritetype tsprite_s[MAXSPRITESONSCREEN]; int32_t preinitengine(void) { + initdivtables(); if (initsystem()) Bexit(9); - makeasmwriteable(); #ifdef DYNALLOC_ARRAYS diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index d9593033e..76bd2b827 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1005,12 +1005,10 @@ int32_t inittimer(int32_t tickspersecond) // initprintf("Initializing timer\n"); -#ifdef _WIN32 - { - int32_t t = win_inittimer(); - if (t < 0) - return t; - } +#if defined(_WIN32) && SDL_MAJOR_VERSION==1 + int32_t t = win_inittimer(); + if (t < 0) + return t; #endif timerfreq = 1000; @@ -1029,14 +1027,10 @@ int32_t inittimer(int32_t tickspersecond) // void uninittimer(void) { - if (!timerfreq) return; - timerfreq=0; - -#ifdef _WIN32 +#if defined(_WIN32) && SDL_MAJOR_VERSION==1 win_timerfreq=0; #endif - msperu64tick = 0; } @@ -1045,12 +1039,10 @@ void uninittimer(void) // void sampletimer(void) { - uint32_t i; - int32_t n; - if (!timerfreq) return; - i = SDL_GetTicks(); - n = tabledivide32(i * timerticspersec, timerfreq) - timerlastsample; + + int64_t i = SDL_GetTicks(); + int32_t n = tabledivide64(i * timerticspersec, timerfreq) - timerlastsample; if (n <= 0) return; @@ -1073,7 +1065,7 @@ uint32_t getticks(void) // high-resolution timers for profiling -#if SDL_MAJOR_VERSION!=1 +#if SDL_MAJOR_VERSION != 1 uint64_t getu64ticks(void) { return SDL_GetPerformanceCounter(); diff --git a/source/build/src/winbits.cpp b/source/build/src/winbits.cpp index 7d97159e7..956e7ca99 100644 --- a/source/build/src/winbits.cpp +++ b/source/build/src/winbits.cpp @@ -150,6 +150,7 @@ int32_t win_checkinstance(void) // // high-resolution timers for profiling // +#if defined(RENDERTYPEWIN) || SDL_MAJOR_VERSION==1 int32_t win_inittimer(void) { int64_t t; @@ -176,7 +177,7 @@ uint64_t win_getu64ticks(void) QueryPerformanceCounter((LARGE_INTEGER *)&i); return i; } - +#endif static void ToggleDesktopComposition(BOOL compEnable)