Skip to content

[GEN][ZH] Make Debug MessageBoxWrapper show message box before game window creation #1000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Generals/Code/GameEngine/Source/Common/System/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ inline HWND getThreadHWND()
int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType )
{
HWND threadHWND = getThreadHWND();
if (!threadHWND)
return (uType & MB_ABORTRETRYIGNORE)?IDIGNORE:IDYES;

return ::MessageBox(threadHWND, lpText, lpCaption, uType);
}

Expand Down Expand Up @@ -422,8 +419,10 @@ void DebugLog(const char *format, ...)
ScopedCriticalSection scopedCriticalSection(TheDebugLogCriticalSection);
#endif

#ifdef DEBUG_LOGGING
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This #ifdef looks redundant. The whole function already is in the same #ifdef condition.

if (theDebugFlags == 0)
MessageBoxWrapper("DebugLog - Debug not inited properly", "", MB_OK|MB_TASKMODAL);
doLogOutput("DebugCrash - Debug not inited properly");
#endif

format = prepBuffer(format, theBuffer);

Expand Down Expand Up @@ -475,7 +474,9 @@ void DebugCrash(const char *format, ...)
ShowWindow(ApplicationHWnd, SW_HIDE);
}
}
MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL);
#ifdef DEBUG_LOGGING
doLogOutput("DebugCrash - Debug not inited properly");
#endif
}

format = prepBuffer(format, theCrashBuffer);
Expand All @@ -493,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 buffer", "", MB_OK|MB_TASKMODAL);
}

#ifdef DEBUG_LOGGING
Expand Down
13 changes: 7 additions & 6 deletions GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ inline HWND getThreadHWND()
int MessageBoxWrapper( LPCSTR lpText, LPCSTR lpCaption, UINT uType )
{
HWND threadHWND = getThreadHWND();
if (!threadHWND)
return (uType & MB_ABORTRETRYIGNORE)?IDIGNORE:IDYES;

return ::MessageBox(threadHWND, lpText, lpCaption, uType);
}

Expand Down Expand Up @@ -423,8 +420,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);
doLogOutput("DebugCrash - Debug not inited properly");
#endif

format = prepBuffer(format, theBuffer);

Expand Down Expand Up @@ -476,7 +475,9 @@ void DebugCrash(const char *format, ...)
ShowWindow(ApplicationHWnd, SW_HIDE);
}
}
MessageBoxWrapper("DebugCrash - Debug not inited properly", "", MB_OK|MB_TASKMODAL);
#ifdef DEBUG_LOGGING
doLogOutput("DebugCrash - Debug not inited properly");
#endif
}

format = prepBuffer(format, theCrashBuffer);
Expand All @@ -494,7 +495,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 buffer", "", MB_OK|MB_TASKMODAL);
}

#ifdef DEBUG_LOGGING
Expand Down
Loading