From daac5489d9b38137f3a7413a6b757323c0f2a6c3 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Thu, 8 Sep 2016 21:46:12 +0200 Subject: [PATCH] Free console earlier --- src/Components/Modules/Console.cpp | 9 ++++++++- src/Components/Modules/Console.hpp | 2 ++ src/Components/Modules/Singleton.cpp | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 0cd17fa5..55f3fd26 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -483,6 +483,14 @@ namespace Components Console::SkipShutdown = true; } + void Console::FreeNativeConsole() + { + if (Flags::HasFlag("console") || ZoneBuilder::IsEnabled()) + { + FreeConsole(); + } + } + Console::Console() { // Console '%s: %s> ' string @@ -527,7 +535,6 @@ namespace Components } else if (Flags::HasFlag("console") || ZoneBuilder::IsEnabled()) // ZoneBuilder uses the game's console, until the native one is adapted. { - FreeConsole(); Utils::Hook::Nop(0x60BB58, 11); // Redirect input (]command) diff --git a/src/Components/Modules/Console.hpp b/src/Components/Modules/Console.hpp index fc38497e..49d7e1e4 100644 --- a/src/Components/Modules/Console.hpp +++ b/src/Components/Modules/Console.hpp @@ -15,6 +15,8 @@ namespace Components static void SetSkipShutdown(); + static void FreeNativeConsole(); + private: // Text-based console stuff static WINDOW* OutputWindow; diff --git a/src/Components/Modules/Singleton.cpp b/src/Components/Modules/Singleton.cpp index bb13be4f..1a50fa5b 100644 --- a/src/Components/Modules/Singleton.cpp +++ b/src/Components/Modules/Singleton.cpp @@ -17,6 +17,8 @@ namespace Components ExitProcess(0); } + Console::FreeNativeConsole(); + if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return; Singleton::FirstInstance = (CreateMutexA(NULL, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS);