From b24712f2b667a2c95d12da34d9e7691f854e27b8 Mon Sep 17 00:00:00 2001 From: Overhaul Date: Wed, 25 Jul 2007 04:44:58 +0000 Subject: [PATCH] Fix sticky keys due to loading screens Fix infinite loop/hang after an assertion failure git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1113 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Standard Gaming Platform/input.cpp | 10 ++++++++-- Standard Gaming Platform/video.cpp | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Standard Gaming Platform/input.cpp b/Standard Gaming Platform/input.cpp index 8dbea79f6..800f04068 100644 --- a/Standard Gaming Platform/input.cpp +++ b/Standard Gaming Platform/input.cpp @@ -1613,9 +1613,15 @@ void DequeueAllKeyBoardEvents() //dequeue all the events waiting in the windows queue - while( PeekMessage( &KeyMessage, ghWindow, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE ) ); + //Give them proper processing like the old window hook method used to. + while( PeekMessage( &KeyMessage, ghWindow, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE ) ) + { + TranslateMessage( &KeyMessage); + DispatchMessage( &KeyMessage); + } - //Deque all the events waiting in the SGP queue + //Now deque all the events waiting in the SGP queue + //Including those that were just posted in the code above while (DequeueEvent(&InputEvent) == TRUE) { //dont do anything diff --git a/Standard Gaming Platform/video.cpp b/Standard Gaming Platform/video.cpp index 2cf3b1874..65c0e4bb5 100644 --- a/Standard Gaming Platform/video.cpp +++ b/Standard Gaming Platform/video.cpp @@ -1743,6 +1743,12 @@ void RefreshScreen(void *DummyVariable) ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, 0, 0, gpFrameBuffer, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY); if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) { + // Prevent the assertion error lockup + if (ReturnCode == DDERR_INVALIDRECT) + { + break; + } + DirectXAttempt ( ReturnCode, __LINE__, __FILE__ ); if (ReturnCode == DDERR_SURFACELOST) @@ -2133,6 +2139,12 @@ void RefreshScreen(void *DummyVariable) ReturnCode = IDirectDrawSurface2_SGPBltFast(gMouseCursorBackground[CURRENT_MOUSE_DATA].pSurface, gMouseCursorBackground[CURRENT_MOUSE_DATA].usLeft, gMouseCursorBackground[CURRENT_MOUSE_DATA].usTop, gpBackBuffer, &Region, DDBLTFAST_NOCOLORKEY); if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) { + // Prevent the assertion failure lockup + if (ReturnCode == DDERR_INVALIDRECT) + { + break; + } + DirectXAttempt ( ReturnCode, __LINE__, __FILE__ ); } @@ -2156,6 +2168,12 @@ void RefreshScreen(void *DummyVariable) ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseXPos, gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseYPos, gpMouseCursor, &Region, DDBLTFAST_SRCCOLORKEY); if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) { + // Prevent the assertion failure lockup + if (ReturnCode == DDERR_INVALIDRECT) + { + break; + } + DirectXAttempt ( ReturnCode, __LINE__, __FILE__ ); }