[QuickPatch] Added G_Antilag dvar

This commit is contained in:
INeedBots 2020-12-22 22:15:48 -06:00
parent f81d667280
commit 28df9b651a
2 changed files with 65 additions and 0 deletions

View File

@ -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; Game::dvar_t* QuickPatch::sv_enableBounces;
__declspec(naked) void QuickPatch::BounceStub() __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"); 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(); 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 // Disallow invalid player names
Utils::Hook(0x401983, QuickPatch::InvalidNameStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x401983, QuickPatch::InvalidNameStub, HOOK_JUMP).install()->quick();

View File

@ -39,6 +39,10 @@ namespace Components
static void SetAspectRatioStub(); static void SetAspectRatioStub();
static void SetAspectRatio(); static void SetAspectRatio();
static Game::dvar_t* g_antilag;
static void ClientEventsFireWeaponStub();
static void ClientEventsFireWeaponMeleeStub();
static Game::dvar_t* g_playerCollision; static Game::dvar_t* g_playerCollision;
static void PlayerCollisionStub(); static void PlayerCollisionStub();
static Game::dvar_t* g_playerEjection; static Game::dvar_t* g_playerEjection;