From 39776dc56981e2ca53fcb2e0705a80f832b666cb Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Fri, 12 Feb 2021 05:31:14 +0000 Subject: [PATCH] Fix: guiBaseJA2Clock overflow (by MH17) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8932 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Utils/Timer Control.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Utils/Timer Control.cpp b/Utils/Timer Control.cpp index b2506326..830d0196 100644 --- a/Utils/Timer Control.cpp +++ b/Utils/Timer Control.cpp @@ -139,6 +139,8 @@ extern INT32 giFlashContractBaseTime; extern UINT32 guiFlashCursorBaseTime; extern INT32 giPotCharPathBaseTime; +// sevenfm: display overflow detection +extern void MapScreenMessage(UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...); typedef void (*TIMER_NOTIFY_CALLBACK) ( INT32 timer, PTR state ); struct TIMER_NOTIFY_ITEM @@ -203,8 +205,21 @@ void CALLBACK TimeProc( UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2 if ( !gfPauseClock ) { + UINT32 uiOldClock = guiBaseJA2Clock; + guiBaseJA2Clock += BASETIMESLICE; + // detect overflow + if (uiOldClock > guiBaseJA2Clock) + { + MapScreenMessage(162, 0, L"guiBaseJA2Clock overflow detected!"); + for (gCNT = 0; gCNT < TOTAL_SOLDIERS; gCNT++) + { + if (MercPtrs[gCNT]) + MercPtrs[gCNT]->ResetSoldierChangeStatTimer(); + } + } + for ( gCNT = 0; gCNT < NUMTIMERS; gCNT++ ) { timerDone |= UpdateCounter( gCNT, iTimeLeft );