From 8e75c40cc3ee2680371e248358b6ab8e0b68081f Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 28 Nov 2018 13:28:07 +0100 Subject: [PATCH] revert LimitGameTicks changes since it's causing flickering in unpatched versions of cnc1 and ra1 --- inc/main.h | 2 +- src/main.c | 12 ++---------- src/surface.c | 6 ++---- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/inc/main.h b/inc/main.h index 8c14947..e936fd6 100644 --- a/inc/main.h +++ b/inc/main.h @@ -36,7 +36,7 @@ extern RECT WindowRect; extern BOOL ChildWindowExists; BOOL detect_cutscene(); -void LimitGameTicks(BOOL isBltOrFlip); +void LimitGameTicks(); DWORD WINAPI render_main(void); DWORD WINAPI render_soft_main(void); BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam); diff --git a/src/main.c b/src/main.c index f3af671..1f6ff92 100644 --- a/src/main.c +++ b/src/main.c @@ -158,26 +158,18 @@ BOOL detect_cutscene() return FALSE; } -void LimitGameTicks(BOOL isBltOrFlip) +void LimitGameTicks() { static DWORD nextGameTick; - static DWORD lastBltOrFlipTick; if (!nextGameTick) { nextGameTick = timeGetTime(); return; } - + nextGameTick += ddraw->ticklength; DWORD tickCount = timeGetTime(); - if (isBltOrFlip) - lastBltOrFlipTick = tickCount; - else if (lastBltOrFlipTick + (ddraw->ticklength * 2) >= tickCount) - return; - - nextGameTick += ddraw->ticklength; int sleepTime = nextGameTick - tickCount; - if (sleepTime <= 0 || sleepTime > ddraw->ticklength) nextGameTick = tickCount; else diff --git a/src/surface.c b/src/surface.c index 8fb9f98..e736012 100644 --- a/src/surface.c +++ b/src/surface.c @@ -445,7 +445,7 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR } if (ddraw->ticklength > 0) - LimitGameTicks(TRUE); + LimitGameTicks(); } return DD_OK; @@ -688,7 +688,7 @@ HRESULT __stdcall ddraw_surface_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWS */ if (ddraw->ticklength > 0) - LimitGameTicks(TRUE); + LimitGameTicks(); } return DD_OK; @@ -955,8 +955,6 @@ HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRe InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE); ReleaseSemaphore(ddraw->render.sem, 1, NULL); - if (ddraw->ticklength > 0) - LimitGameTicks(FALSE); } return DD_OK;