Move Windows console init to the beginning of main

This is done to capture all potential messages to the debug console.
This commit is contained in:
Joni Savolainen 2022-01-16 18:30:05 +02:00
parent 8348f06d17
commit f44d2bea1b

View file

@ -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;