[Weapon]: Move fix here (#627)

This commit is contained in:
Edo 2022-12-06 14:42:09 +00:00 committed by GitHub
parent fb68e59e08
commit 3f06eb8eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 24 deletions

View File

@ -47,20 +47,6 @@ namespace Components
} }
} }
__declspec(naked) void QuickPatch::JavelinResetHook_Stub()
{
__asm
{
mov eax, 577A10h;
call eax;
pop edi;
mov dword ptr [esi+34h], 0;
pop esi;
pop ebx;
retn;
}
}
Game::dvar_t* QuickPatch::g_antilag; Game::dvar_t* QuickPatch::g_antilag;
__declspec(naked) void QuickPatch::ClientEventsFireWeapon_Stub() __declspec(naked) void QuickPatch::ClientEventsFireWeapon_Stub()
{ {
@ -315,9 +301,6 @@ namespace Components
Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeapon_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeapon_Stub, HOOK_JUMP).install()->quick();
Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMelee_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMelee_Stub, HOOK_JUMP).install()->quick();
// Javelin fix
Utils::Hook(0x578F52, QuickPatch::JavelinResetHook_Stub, HOOK_JUMP).install()->quick();
// Add ultrawide support // Add ultrawide support
Utils::Hook(0x51B13B, QuickPatch::Dvar_RegisterAspectRatioDvar, HOOK_CALL).install()->quick(); Utils::Hook(0x51B13B, QuickPatch::Dvar_RegisterAspectRatioDvar, HOOK_CALL).install()->quick();
Utils::Hook(0x5063F3, QuickPatch::SetAspectRatio_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5063F3, QuickPatch::SetAspectRatio_Stub, HOOK_JUMP).install()->quick();

View File

@ -12,8 +12,6 @@ namespace Components
static void UnlockStats(); static void UnlockStats();
private: private:
static void JavelinResetHook_Stub();
static Dvar::Var r_customAspectRatio; static Dvar::Var r_customAspectRatio;
static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description); static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description);
static void SetAspectRatio_Stub(); static void SetAspectRatio_Stub();

View File

@ -3,6 +3,8 @@
namespace Components namespace Components
{ {
const Game::dvar_t* Weapon::BGWeaponOffHandFix;
Game::WeaponCompleteDef* Weapon::LoadWeaponCompleteDef(const char* name) Game::WeaponCompleteDef* Weapon::LoadWeaponCompleteDef(const char* name)
{ {
if (auto* rawWeaponFile = Game::BG_LoadWeaponCompleteDefInternal("mp", name)) if (auto* rawWeaponFile = Game::BG_LoadWeaponCompleteDefInternal("mp", name))
@ -481,7 +483,7 @@ namespace Components
// Game code // Game code
push 0x48BB2D push 0x48BB2D
retn ret
null: null:
push 0x48BB1F // Exit function push 0x48BB1F // Exit function
@ -499,7 +501,7 @@ namespace Components
jz touched jz touched
push 0x56E82C push 0x56E82C
retn ret
touched: touched:
test dword ptr [edi + 0x2BC], PWF_DISABLE_WEAPON_PICKUP test dword ptr [edi + 0x2BC], PWF_DISABLE_WEAPON_PICKUP
@ -515,7 +517,32 @@ namespace Components
continue_func: continue_func:
push 0x56E84C push 0x56E84C
retn ret
}
}
__declspec(naked) void Weapon::JavelinResetHook_Stub()
{
static DWORD PM_Weapon_OffHandEnd_t = 0x577A10;
__asm
{
call PM_Weapon_OffHandEnd_t
push eax
mov eax, BGWeaponOffHandFix
cmp byte ptr [eax + 0x10], 1
pop eax
jne safeReturn
mov dword ptr [esi + 0x34], 0 // playerState_s.grenadeTimeLeft
safeReturn:
pop edi
pop esi
pop ebx
ret
} }
} }
@ -565,9 +592,14 @@ namespace Components
Utils::Hook(0x59E341, CG_UpdatePrimaryForAltModeWeapon_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x59E341, CG_UpdatePrimaryForAltModeWeapon_Stub, HOOK_JUMP).install()->quick();
Utils::Hook(0x48BB25, CG_SelectWeaponIndex_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x48BB25, CG_SelectWeaponIndex_Stub, HOOK_JUMP).install()->quick();
AddScriptMethods();
AssertOffset(Game::playerState_s, Game::playerState_s::weapCommon.weapFlags, 0x2BC); AssertOffset(Game::playerState_s, Game::playerState_s::weapCommon.weapFlags, 0x2BC);
Utils::Hook(0x56E825, WeaponEntCanBeGrabbed_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x56E825, WeaponEntCanBeGrabbed_Stub, HOOK_JUMP).install()->quick();
// Javelin fix (PM_Weapon_OffHandEnd)
AssertOffset(Game::playerState_s, grenadeTimeLeft, 0x34);
BGWeaponOffHandFix = Game::Dvar_RegisterBool("bg_weaponOffHandFix", true, Game::DVAR_CODINFO, "Reset grenadeTimeLeft after using off hand weapon");
Utils::Hook(0x578F52, JavelinResetHook_Stub, HOOK_JUMP).install()->quick();
AddScriptMethods();
} }
} }

View File

@ -13,6 +13,8 @@ namespace Components
Weapon(); Weapon();
private: private:
static const Game::dvar_t* BGWeaponOffHandFix;
static Game::WeaponCompleteDef* LoadWeaponCompleteDef(const char* name); static Game::WeaponCompleteDef* LoadWeaponCompleteDef(const char* name);
static void PatchLimit(); static void PatchLimit();
static void* LoadNoneWeaponHook(); static void* LoadNoneWeaponHook();
@ -29,6 +31,8 @@ namespace Components
static void CG_UpdatePrimaryForAltModeWeapon_Stub(); static void CG_UpdatePrimaryForAltModeWeapon_Stub();
static void CG_SelectWeaponIndex_Stub(); static void CG_SelectWeaponIndex_Stub();
static void JavelinResetHook_Stub();
static void WeaponEntCanBeGrabbed_Stub(); static void WeaponEntCanBeGrabbed_Stub();
static void AddScriptMethods(); static void AddScriptMethods();
}; };