[Weapon] Fix null pointer (Prank gone wrong)

This commit is contained in:
Diavolo 2022-06-30 22:24:40 +02:00
parent 83c4482c3f
commit d191e90e1f
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
2 changed files with 48 additions and 0 deletions

View File

@ -448,6 +448,48 @@ namespace Components
}
}
void __declspec(naked) Weapon::CG_UpdatePrimaryForAltModeWeapon_Stub()
{
__asm
{
mov eax, 0x440EB0 // BG_GetWeaponDef
call eax
add esp, 0x4
test eax, eax
jz null
// Game code
push 0x59E349
retn
null:
mov al, 1
ret
}
}
void __declspec(naked) Weapon::CG_SelectWeaponIndex_Stub()
{
__asm
{
mov eax, 0x440EB0 // BG_GetWeaponDef
call eax
add esp, 0x4
test eax, eax
jz null
// Game code
push 0x48BB2D
retn
null:
push 0x48BB1F // Exit function
ret
}
}
void __declspec(naked) Weapon::WeaponEntCanBeGrabbed_Stub()
{
using namespace Game;
@ -525,6 +567,9 @@ namespace Components
//Utils::Hook::Nop(0x452C1D, 2);
//Utils::Hook::Nop(0x452C24, 5);
Utils::Hook(0x59E341, CG_UpdatePrimaryForAltModeWeapon_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);

View File

@ -26,6 +26,9 @@ namespace Components
static int ParseWeaponConfigStrings();
static int ClearConfigStrings(void* dest, int value, int size);
static void CG_UpdatePrimaryForAltModeWeapon_Stub();
static void CG_SelectWeaponIndex_Stub();
static void WeaponEntCanBeGrabbed_Stub();
static void AddScriptMethods();
};