From f44d2bea1bd2deb7ee44de5ed690d54d5af4dc08 Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Sun, 16 Jan 2022 18:30:05 +0200 Subject: [PATCH] Move Windows console init to the beginning of main This is done to capture all potential messages to the debug console. --- src/main.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e30a9969..c8a8fb50 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -228,6 +228,20 @@ int main(int argc, char *argv[]) { } } +#if defined(__WIN32__) + // Create a debug console in debug mode + if (conf.editor.debug) { + if (setupWindowsConsole()) { + reopenWindowsStreams(); + } else { + char buf[200]; + snprintf(buf, sizeof(buf), "Error allocating console: %lu", + GetLastError()); + showInitError(std::string(buf)); + } + } +#endif + conf.readGameINI(); #ifdef MKXPZ_STEAM @@ -293,18 +307,6 @@ int main(int argc, char *argv[]) { showInitError( std::string(buf)); // Not an error worth ending the program over } - - // Create a debug console in debug mode - if (conf.editor.debug) { - if (setupWindowsConsole()) { - reopenWindowsStreams(); - } else { - char buf[200]; - snprintf(buf, sizeof(buf), "Error allocating console: %lu", - GetLastError()); - showInitError(std::string(buf)); - } - } #endif SDL_Window *win;