From d2f72b465cffd2f19485386395dbe54b0ae2760e Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sat, 4 Jun 2022 19:07:45 +0200 Subject: [PATCH] Better minicon patch --- src/Components/Modules/QuickPatch.cpp | 23 ++++++++++++----------- src/Components/Modules/QuickPatch.hpp | 2 ++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 8cb95b53..0f2f3f1f 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -229,6 +229,16 @@ namespace Components } } + Game::dvar_t* QuickPatch::Dvar_RegisterConMinicon(const char* dvarName, [[maybe_unused]] bool value, unsigned __int16 flags, const char* description) + { +#ifdef _DEBUG + constexpr auto value_ = true; +#else + constexpr auto value_ = false; +#endif + return Game::Dvar_RegisterBool(dvarName, value_, flags, description); + } + QuickPatch::QuickPatch() { // Filtering any mapents that is intended for Spec:Ops gamemode (CODO) and prevent them from spawning @@ -251,6 +261,8 @@ namespace Components Utils::Hook(0x51B13B, QuickPatch::Dvar_RegisterAspectRatioDvar, HOOK_CALL).install()->quick(); Utils::Hook(0x5063F3, QuickPatch::SetAspectRatioStub, HOOK_JUMP).install()->quick(); + Utils::Hook(0x4FA448, QuickPatch::Dvar_RegisterConMinicon, HOOK_CALL).install()->quick(); + // Make sure preDestroy is called when the game shuts down Scheduler::OnShutdown(Loader::PreDestroy); @@ -705,17 +717,6 @@ namespace Components // Disable cheat protection for dvars Utils::Hook::Set(0x647682, 0xEB); - - // Constantly draw the mini console - Utils::Hook::Set(0x412A45, 0xEB); - - Scheduler::OnFrame([]() - { - if (*reinterpret_cast(0x62E4BAC)) - { - Game::Con_DrawMiniConsole(0, 2, 4, (Game::CL_IsCgameInitialized() ? 1.0f : 0.4f)); - } - }, true); #else // Remove missing tag message Utils::Hook::Nop(0x4EBF1A, 5); diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index b9b03407..b5cc5d9f 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -27,5 +27,7 @@ namespace Components static void CL_KeyEvent_OnEscape(); static void CL_KeyEvent_ConsoleEscape_Stub(); + + static Game::dvar_t* Dvar_RegisterConMinicon(const char* dvarName, bool value, unsigned __int16 flags, const char* description); }; }