From b2ad5886e249a87eb9d4d1ecdd57b694a4d4ad04 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Tue, 3 Jun 2025 20:35:47 +0200 Subject: [PATCH 1/3] Use message box before window creation. --- .../GameEngine/Source/Common/System/Debug.cpp | 16 ++++++++-------- .../GameEngine/Source/Common/System/Debug.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/System/Debug.cpp b/Generals/Code/GameEngine/Source/Common/System/Debug.cpp index 46f23d4946..c49e3c91a8 100644 --- a/Generals/Code/GameEngine/Source/Common/System/Debug.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/Debug.cpp @@ -168,10 +168,10 @@ inline HWND getThreadHWND() // ---------------------------------------------------------------------------- -int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType ) +int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType, bool alwaysShowMessageBox ) { HWND threadHWND = getThreadHWND(); - if (!threadHWND) + if (!threadHWND && !alwaysShowMessageBox) return (uType & MB_ABORTRETRYIGNORE)?IDIGNORE:IDYES; return ::MessageBox(threadHWND, lpText, lpCaption, uType); @@ -270,7 +270,7 @@ static int doCrashBox(const char *buffer, Bool logResult) if (!ignoringAsserts()) { //result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3); - result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING); + result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING, true); } else { result = IDIGNORE; } @@ -423,7 +423,7 @@ void DebugLog(const char *format, ...) #endif if (theDebugFlags == 0) - MessageBoxWrapper("DebugLog - Debug not inited properly", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("DebugLog - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); format = prepBuffer(format, theBuffer); @@ -433,7 +433,7 @@ void DebugLog(const char *format, ...) va_end(arg); if (strlen(theBuffer) >= sizeof(theBuffer)) - MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL, true); whackFunnyCharacters(theBuffer); doLogOutput(theBuffer); @@ -475,7 +475,7 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); } format = prepBuffer(format, theCrashBuffer); @@ -493,7 +493,7 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("String too long for debug buffers", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("String too long for debug buffers", "", MB_OK|MB_TASKMODAL, true); } #ifdef DEBUG_LOGGING @@ -520,7 +520,7 @@ void DebugCrash(const char *format, ...) int yn; if (!ignoringAsserts()) { - yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL); + yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL, true); } else { diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp index f9090dfa94..da33e65fd8 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp @@ -169,10 +169,10 @@ inline HWND getThreadHWND() // ---------------------------------------------------------------------------- -int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType ) +int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType, bool alwaysShowMessageBox ) { HWND threadHWND = getThreadHWND(); - if (!threadHWND) + if (!threadHWND && !alwaysShowMessageBox) return (uType & MB_ABORTRETRYIGNORE)?IDIGNORE:IDYES; return ::MessageBox(threadHWND, lpText, lpCaption, uType); @@ -270,7 +270,7 @@ static int doCrashBox(const char *buffer, Bool logResult) int result; if (!ignoringAsserts()) { - result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3); + result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3, true); //result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING); } else { result = IDIGNORE; @@ -424,7 +424,7 @@ void DebugLog(const char *format, ...) #endif if (theDebugFlags == 0) - MessageBoxWrapper("DebugLog - Debug not inited properly", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("DebugLog - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); format = prepBuffer(format, theBuffer); @@ -434,7 +434,7 @@ void DebugLog(const char *format, ...) va_end(arg); if (strlen(theBuffer) >= sizeof(theBuffer)) - MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL, true); whackFunnyCharacters(theBuffer); doLogOutput(theBuffer); @@ -476,7 +476,7 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); } format = prepBuffer(format, theCrashBuffer); @@ -494,7 +494,7 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("String too long for debug buffers", "", MB_OK|MB_TASKMODAL); + MessageBoxWrapper("String too long for debug buffers", "", MB_OK|MB_TASKMODAL, true); } #ifdef DEBUG_LOGGING @@ -521,7 +521,7 @@ void DebugCrash(const char *format, ...) int yn; if (!ignoringAsserts()) { - yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL); + yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL, true); } else { From e0878ebf43f328085b7c0b4a0325a68cc173951c Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 5 Jun 2025 22:11:45 +0200 Subject: [PATCH 2/3] Changed from message box to debug log for improper debug initialization. --- Generals/Code/GameEngine/Source/Common/System/Debug.cpp | 8 ++++++-- GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/System/Debug.cpp b/Generals/Code/GameEngine/Source/Common/System/Debug.cpp index c49e3c91a8..af10213c38 100644 --- a/Generals/Code/GameEngine/Source/Common/System/Debug.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/Debug.cpp @@ -422,8 +422,10 @@ void DebugLog(const char *format, ...) ScopedCriticalSection scopedCriticalSection(TheDebugLogCriticalSection); #endif +#ifdef DEBUG_LOGGING if (theDebugFlags == 0) - MessageBoxWrapper("DebugLog - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); + doLogOutput("DebugCrash - Debug not inited properly"); +#endif format = prepBuffer(format, theBuffer); @@ -475,7 +477,9 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); +#ifdef DEBUG_LOGGING + doLogOutput("DebugCrash - Debug not inited properly"); +#endif } format = prepBuffer(format, theCrashBuffer); diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp index da33e65fd8..0af6296362 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp @@ -423,8 +423,10 @@ void DebugLog(const char *format, ...) ScopedCriticalSection scopedCriticalSection(TheDebugLogCriticalSection); #endif +#ifdef DEBUG_LOGGING if (theDebugFlags == 0) - MessageBoxWrapper("DebugLog - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); + doLogOutput("DebugCrash - Debug not inited properly"); +#endif format = prepBuffer(format, theBuffer); @@ -476,7 +478,9 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL, false); +#ifdef DEBUG_LOGGING + doLogOutput("DebugCrash - Debug not inited properly"); +#endif } format = prepBuffer(format, theCrashBuffer); From bc43a5eb482560b76dc69ccaee1a5a760fb9d8d2 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 5 Jun 2025 22:12:38 +0200 Subject: [PATCH 3/3] Removed boolean checks in MessageBoxWrapper. --- .../Code/GameEngine/Source/Common/System/Debug.cpp | 13 +++++-------- .../Code/GameEngine/Source/Common/System/Debug.cpp | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/System/Debug.cpp b/Generals/Code/GameEngine/Source/Common/System/Debug.cpp index af10213c38..391a690c24 100644 --- a/Generals/Code/GameEngine/Source/Common/System/Debug.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/Debug.cpp @@ -168,12 +168,9 @@ inline HWND getThreadHWND() // ---------------------------------------------------------------------------- -int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType, bool alwaysShowMessageBox ) +int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType ) { HWND threadHWND = getThreadHWND(); - if (!threadHWND && !alwaysShowMessageBox) - return (uType & MB_ABORTRETRYIGNORE)?IDIGNORE:IDYES; - return ::MessageBox(threadHWND, lpText, lpCaption, uType); } @@ -270,7 +267,7 @@ static int doCrashBox(const char *buffer, Bool logResult) if (!ignoringAsserts()) { //result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3); - result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING, true); + result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING); } else { result = IDIGNORE; } @@ -435,7 +432,7 @@ void DebugLog(const char *format, ...) va_end(arg); if (strlen(theBuffer) >= sizeof(theBuffer)) - MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL, true); + MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL); whackFunnyCharacters(theBuffer); doLogOutput(theBuffer); @@ -497,7 +494,7 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("String too long for debug buffers", "", MB_OK|MB_TASKMODAL, true); + MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL); } #ifdef DEBUG_LOGGING @@ -524,7 +521,7 @@ void DebugCrash(const char *format, ...) int yn; if (!ignoringAsserts()) { - yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL, true); + yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL); } else { diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp index 0af6296362..48f66f70b7 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp @@ -169,12 +169,9 @@ inline HWND getThreadHWND() // ---------------------------------------------------------------------------- -int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType, bool alwaysShowMessageBox ) +int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType ) { HWND threadHWND = getThreadHWND(); - if (!threadHWND && !alwaysShowMessageBox) - return (uType & MB_ABORTRETRYIGNORE)?IDIGNORE:IDYES; - return ::MessageBox(threadHWND, lpText, lpCaption, uType); } @@ -270,7 +267,7 @@ static int doCrashBox(const char *buffer, Bool logResult) int result; if (!ignoringAsserts()) { - result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3, true); + result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3); //result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING); } else { result = IDIGNORE; @@ -436,7 +433,7 @@ void DebugLog(const char *format, ...) va_end(arg); if (strlen(theBuffer) >= sizeof(theBuffer)) - MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL, true); + MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL); whackFunnyCharacters(theBuffer); doLogOutput(theBuffer); @@ -498,7 +495,7 @@ void DebugCrash(const char *format, ...) ShowWindow(ApplicationHWnd, SW_HIDE); } } - MessageBoxWrapper("String too long for debug buffers", "", MB_OK|MB_TASKMODAL, true); + MessageBoxWrapper("String too long for debug buffer", "", MB_OK|MB_TASKMODAL); } #ifdef DEBUG_LOGGING @@ -525,7 +522,7 @@ void DebugCrash(const char *format, ...) int yn; if (!ignoringAsserts()) { - yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL, true); + yn = MessageBoxWrapper("Ignore this crash from now on?", "", MB_YESNO|MB_TASKMODAL); } else {