From a3e69cae1599a857a11a36a7fa94a96c95650223 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Fri, 3 Dec 2021 20:35:58 +0000 Subject: [PATCH] Console --- src/component/console.cpp | 54 +++++++++++++++++++++++++++++++++++++++ src/game/symbols.hpp | 4 ++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/component/console.cpp diff --git a/src/component/console.cpp b/src/component/console.cpp new file mode 100644 index 0000000..500cb3d --- /dev/null +++ b/src/component/console.cpp @@ -0,0 +1,54 @@ +#include + +#include + +#include "command.hpp" + +namespace console +{ + namespace + { + std::thread thread; + std::thread::id async_thread_id; + + LRESULT __stdcall sys_start_console(HWND, UINT, WPARAM, LPARAM) + { + game::Sys_ShowConsole(); + return 0; + } + + void console_unlock() + { + const auto callBack = SetWindowLongA(*game::g_wv_hWnd, + GWL_WNDPROC, reinterpret_cast(sys_start_console)); + + SendMessage(*game::g_wv_hWnd, WM_QUIT, 0, 0); + SetWindowLongA(*game::g_wv_hWnd, GWL_WNDPROC, callBack); + } + + void show_console() + { + if (*game::s_wcd_hWnd) + { + ShowWindow(*game::s_wcd_hWnd, SW_SHOW); + } + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + thread = std::thread([]() + { + console_unlock(); + show_console(); + }); + + async_thread_id = thread.get_id(); + } + }; +} + +REGISTER_COMPONENT(console::component) diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index acb290f..de8989a 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -6,6 +6,8 @@ namespace game { // Functions WEAK symbol Sys_ShowConsole{0x515CD0}; + WEAK symbol Sys_CreateConsole{0x51B770}; + WEAK symbol Sys_Error{0x434000}; WEAK symbol Com_Error{0x4A6660}; WEAK symbol ConcatArgs{0x539060}; WEAK symbol Cbuf_AddText{0x4C1030}; @@ -56,5 +58,5 @@ namespace game WEAK symbol localClientConnection{0xB3D360}; WEAK symbol g_wv_hWnd{0x5A86AF0}; WEAK symbol s_wcd_hWnd{0x5A86330}; - WEAK symbol serverId{0x0FF5058}; + WEAK symbol serverId{0xFF5058}; }