From 21419533308dfb8b375a9e5b1671c19ac4b1f879 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Wed, 9 Feb 2022 18:28:34 +0000 Subject: [PATCH] [:zap:Patch] Refactored another dvar patch --- src/Components/Modules/QuickPatch.cpp | 27 +++++++++------------------ src/Components/Modules/QuickPatch.hpp | 3 ++- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index eecc8dad..10a0d534 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -433,6 +433,12 @@ namespace Components } } + Game::dvar_t* QuickPatch::Dvar_RegisterUIBuildLocation(const char* dvarName, + float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description) + { + return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_FLAG_READONLY, description); + } + QuickPatch::QuickPatch() { // quit_hard @@ -527,16 +533,11 @@ namespace Components Utils::Hook::Set(0x60BD56, "IW4x (" VERSION ")"); // version string color - static float buildLocColor[] = { 1.0f, 1.0f, 1.0f, 0.8f }; - Utils::Hook::Set(0x43F710, buildLocColor); + static Game::vec4_t buildLocColor = { 1.0f, 1.0f, 1.0f, 0.8f }; + Utils::Hook::Set(0x43F710, buildLocColor); // Shift ui version string to the left (ui_buildlocation) - Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar - Utils::Hook::Nop(0x6310B8, 5); // Don't write the result - Dvar::OnInit([]() - { - *reinterpret_cast(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number"); - }); + Utils::Hook(0x6310A0, QuickPatch::Dvar_RegisterUIBuildLocation, HOOK_CALL).install()->quick(); // console title if (ZoneBuilder::IsEnabled()) @@ -763,11 +764,6 @@ namespace Components QuickPatch::UnlockStats(); }); - Command::Add("crash", [](Command::Params*) - { - throw new std::exception(); - }); - Command::Add("dumptechsets", [](Command::Params* param) { if (param->length() != 2) @@ -1000,11 +996,6 @@ namespace Components } } - QuickPatch::~QuickPatch() - { - - } - bool QuickPatch::unitTest() { uint32_t randIntCount = 4'000'000; diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index de070be5..2bc8a383 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -6,7 +6,6 @@ namespace Components { public: QuickPatch(); - ~QuickPatch(); bool unitTest() override; @@ -48,5 +47,7 @@ namespace Components static void CL_KeyEvent_OnEscape(); static void CL_KeyEvent_ConsoleEscape_Stub(); + + static Game::dvar_t* Dvar_RegisterUIBuildLocation(const char* dvarName, float x, float y, float min, float max, int flags, const char* description); }; }