From 5aff963d0d212ba33d7de0fcfdc477b672e19fa2 Mon Sep 17 00:00:00 2001 From: Tore Date: Wed, 24 May 2023 21:18:03 +0200 Subject: [PATCH] Changed to the same method RA uses and thus avoids the call to PostMessage with SDL enabled --- tiberiandawn/startup.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tiberiandawn/startup.cpp b/tiberiandawn/startup.cpp index aba247fe..211589c1 100644 --- a/tiberiandawn/startup.cpp +++ b/tiberiandawn/startup.cpp @@ -208,7 +208,7 @@ int main(int argc, char** argv) printf("Zuwenig Hauptspeicher verf?gbar.\n"); #else #ifdef FRENCH - printf("M�moire vive (RAM) insuffisante.\n"); + printf("M‚moire vive (RAM) insuffisante.\n"); #else printf("Insufficient RAM available.\n"); #endif @@ -467,7 +467,6 @@ int main(int argc, char** argv) Memory_Error_Exit = Print_Error_Exit; CCDebugString("C&C95 - About to exit.\n"); - ReadyToQuit = 1; #if defined(SDL_BUILD) Reset_Video_Mode(); @@ -475,8 +474,23 @@ int main(int argc, char** argv) Sound_End(); -#if defined(_WIN32) - PostMessageA(MainWindow, WM_DESTROY, 0, 0); + /* + ** Flag that this is a clean shutdown (not killed with Ctrl-Alt-Del) + */ + ReadyToQuit = 1; + + /* + ** Post a message to our message handler to tell it to clean up. + */ +#if defined(_WIN32) && !defined(SDL_BUILD) + PostMessage(MainWindow, WM_DESTROY, 0, 0); + + /* + ** Wait until the message handler has dealt with the message + */ + do { + Keyboard->Check(); + } while (ReadyToQuit == 1); #endif CCDebugString("C&C95 - Returned from final message loop.\n"); @@ -596,3 +610,4 @@ void Read_Setup_Options(RawFileClass* config_file) VideoBackBufferAllowed = ini.Get_Bool("Options", "VideoBackBuffer", true); AllowHardwareBlitFills = ini.Get_Bool("Options", "HardwareFills", true); } +