From 7cd2cfe8f3f9cf8971b44aa67a4d5906c4f00d88 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 26 Feb 2022 21:42:44 +0100 Subject: [PATCH] Macro for native console window --- src/client/component/console.cpp | 32 +++++++++++++++++++------------- src/client/game/symbols.hpp | 1 - 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/client/component/console.cpp b/src/client/component/console.cpp index 7534d83a..dd9b7e1e 100644 --- a/src/client/component/console.cpp +++ b/src/client/component/console.cpp @@ -30,7 +30,9 @@ namespace console if (process == GetCurrentProcessId() || IsDebuggerPresent()) { +#ifndef NATIVE_CONSOLE ShowWindow(con_window, SW_HIDE); +#endif } } @@ -66,12 +68,14 @@ namespace console { hide_console(); +#ifdef NATIVE_CONSOLE + setvbuf(stdout, nullptr, _IONBF, 0); + setvbuf(stderr, nullptr, _IONBF, 0); +#else (void)_pipe(this->handles_, 1024, _O_TEXT); (void)_dup2(this->handles_[1], 1); (void)_dup2(this->handles_[1], 2); - - //setvbuf(stdout, nullptr, _IONBF, 0); - //setvbuf(stderr, nullptr, _IONBF, 0); +#endif } void post_start() override @@ -79,9 +83,9 @@ namespace console this->terminate_runner_ = false; this->console_runner_ = utils::thread::create_named_thread("Console IO", [this] - { - this->runner(); - }); + { + this->runner(); + }); } void pre_destroy() override @@ -105,9 +109,9 @@ namespace console _close(this->handles_[1]); messages.access([&](message_queue& msgs) - { - msgs = {}; - }); + { + msgs = {}; + }); } void post_unpack() override @@ -133,7 +137,9 @@ namespace console { if (game::environment::is_dedi() || !utils::flags::has_flag("noconsole")) { +#ifndef NATIVE_CONSOLE game::Sys_ShowConsole(); +#endif } if (!game::environment::is_dedi()) @@ -181,10 +187,10 @@ namespace console { messages.access([&](message_queue& msgs) - { - message_queue_copy = std::move(msgs); - msgs = {}; - }); + { + message_queue_copy = std::move(msgs); + msgs = {}; + }); } while (!message_queue_copy.empty()) diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 8ebf02aa..abed3d9e 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -166,7 +166,6 @@ namespace game * Variables **************************************************************/ - WEAK symbol sv_cmd_args{0, 0x14946BA20}; WEAK symbol command_whitelist{0x141079A60, 0x14120C360};