From 28df9b651a4faf1c1ea57ac89d79a79b86c1fc2a Mon Sep 17 00:00:00 2001 From: INeedBots Date: Tue, 22 Dec 2020 22:15:48 -0600 Subject: [PATCH] [QuickPatch] Added G_Antilag dvar --- src/Components/Modules/QuickPatch.cpp | 61 +++++++++++++++++++++++++++ src/Components/Modules/QuickPatch.hpp | 4 ++ 2 files changed, 65 insertions(+) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 58b9bf64..b79bcdd0 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -183,6 +183,63 @@ namespace Components } } + Game::dvar_t* QuickPatch::g_antilag; + + __declspec(naked) void QuickPatch::ClientEventsFireWeaponStub() + { + __asm + { + // check g_antilag dvar value + mov eax, g_antilag; + cmp byte ptr[eax + 16], 1; + + // do antilag if 1 + je fireWeapon + + // do not do antilag if 0 + mov eax, 0x1A83554 // level.time + mov ecx, [eax] + + fireWeapon: + push edx + push ecx + push edi + mov eax, 0x4A4D50 // FireWeapon + call eax + add esp, 0Ch + pop edi + pop ecx + retn + } + } + + __declspec(naked) void QuickPatch::ClientEventsFireWeaponMeleeStub() + { + __asm + { + // check g_antilag dvar value + mov eax, g_antilag; + cmp byte ptr[eax + 16], 1; + + // do antilag if 1 + je fireWeaponMelee + + // do not do antilag if 0 + mov eax, 0x1A83554 // level.time + mov edx, [eax] + + fireWeaponMelee: + push edx + push edi + mov eax, 0x4F2470 // FireWeaponMelee + call eax + add esp, 8 + pop edi + pop ecx + retn + } + } + Game::dvar_t* QuickPatch::sv_enableBounces; __declspec(naked) void QuickPatch::BounceStub() { @@ -397,6 +454,10 @@ namespace Components g_playerEjection = Game::Dvar_RegisterBool("g_playerEjection", true, Game::DVAR_FLAG_REPLICATED, "Flag whether player ejection is on or off"); Utils::Hook(0x5D814A, QuickPatch::PlayerEjectionStub, HOOK_JUMP).install()->quick(); + g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_FLAG_REPLICATED, "Perform antilag"); + Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick(); + Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMeleeStub, HOOK_JUMP).install()->quick(); + // Disallow invalid player names Utils::Hook(0x401983, QuickPatch::InvalidNameStub, HOOK_JUMP).install()->quick(); diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index 9a9ef6e4..37402355 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -39,6 +39,10 @@ namespace Components static void SetAspectRatioStub(); static void SetAspectRatio(); + static Game::dvar_t* g_antilag; + static void ClientEventsFireWeaponStub(); + static void ClientEventsFireWeaponMeleeStub(); + static Game::dvar_t* g_playerCollision; static void PlayerCollisionStub(); static Game::dvar_t* g_playerEjection;