Merge pull request #344 from diamante0018/develop

[Weapon] Fix null pointer
This commit is contained in:
Dss0 2022-06-30 22:34:55 +02:00 committed by GitHub
commit 562cac3a99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
};