|
| 1 | +/***************************************************************************** |
| 2 | + * |
| 3 | + * PROJECT: Multi Theft Auto |
| 4 | + * LICENSE: See LICENSE in the top level directory |
| 5 | + * FILE: multiplayer_sa/CMultiplayerSA_ProjectileCollisionFix.cpp |
| 6 | + * |
| 7 | + * Multi Theft Auto is available from https://www.multitheftauto.com/ |
| 8 | + * |
| 9 | + *****************************************************************************/ |
| 10 | + |
| 11 | +#include "StdInc.h" |
| 12 | +#include "../game_sa/CColModelSA.h" |
| 13 | + |
| 14 | +static CColModelSAInterface colModelGrenade; |
| 15 | + |
| 16 | +static void InitializeGrenadeColModel() |
| 17 | +{ |
| 18 | + // CColModel::CColModel |
| 19 | + ((CColModelSAInterface*(__thiscall*)(CColModelSAInterface*))(0x40FB60))(&colModelGrenade); |
| 20 | + |
| 21 | + colModelGrenade.m_bounds.m_vecMin = CVector(-0.25f, -0.25f, -0.25f); |
| 22 | + colModelGrenade.m_bounds.m_vecMax = CVector(0.25f, 0.25f, 0.25f); |
| 23 | + |
| 24 | + colModelGrenade.m_sphere.m_center = CVector(0, 0, 0); |
| 25 | + colModelGrenade.m_sphere.m_radius = 0.25f; |
| 26 | + |
| 27 | + // CColModel::AllocateData |
| 28 | + ((void(__thiscall*)(CColModelSAInterface*, int, int, int, int, int, int))(0x40F870))(&colModelGrenade, 1, 0, 0, 0, 0, 0); |
| 29 | + |
| 30 | + // CColSphere::Set |
| 31 | + ((void(__thiscall*)(CColSphereSA*, float, CVector&, unsigned char, char, unsigned char))(0x40FD10))( |
| 32 | + &colModelGrenade.m_data->m_spheres[0], |
| 33 | + colModelGrenade.m_sphere.m_radius * 0.75f, |
| 34 | + colModelGrenade.m_sphere.m_center, |
| 35 | + 56, 0, 255); |
| 36 | +} |
| 37 | + |
| 38 | +#define HOOKPOS_CTempColModels__Initialise 0x5BB87D |
| 39 | +#define HOOKSIZE_CTempColModels__Initialise 0x6 |
| 40 | +static const unsigned int RETURN_CTempColModels__Initialise = 0x5BB883; |
| 41 | +static void _declspec(naked) HOOK_CTempColModels__Initialise() |
| 42 | +{ |
| 43 | + _asm { |
| 44 | + mov ds:[0x968FE4], edx |
| 45 | + |
| 46 | + call InitializeGrenadeColModel |
| 47 | + |
| 48 | + jmp RETURN_CTempColModels__Initialise |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +#define HOOKPOS_CFileLoader__LoadWeaponObject 0x5B401E |
| 53 | +#define HOOKSIZE_CFileLoader__LoadWeaponObject 0x5 |
| 54 | +static const unsigned int RETURN_CFileLoader__LoadWeaponObject = 0x5B4023; |
| 55 | +static void _declspec(naked) HOOK_CFileLoader__LoadWeaponObject() |
| 56 | +{ |
| 57 | + _asm { |
| 58 | + mov eax, [esp+0x8] |
| 59 | + cmp eax, 342 |
| 60 | + je grenade |
| 61 | + cmp eax, 343 |
| 62 | + je grenade |
| 63 | + cmp eax, 344 |
| 64 | + je grenade |
| 65 | + cmp eax, 363 |
| 66 | + je grenade |
| 67 | + |
| 68 | + push 0x968FD0 |
| 69 | + jmp RETURN_CFileLoader__LoadWeaponObject |
| 70 | + |
| 71 | + grenade: |
| 72 | + push offset colModelGrenade |
| 73 | + jmp RETURN_CFileLoader__LoadWeaponObject |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +void CMultiplayerSA::InitHooks_ProjectileCollisionFix() |
| 78 | +{ |
| 79 | + EZHookInstall(CTempColModels__Initialise); |
| 80 | + EZHookInstall(CFileLoader__LoadWeaponObject); |
| 81 | + |
| 82 | + MemCpy((void*)0x7383FF, "\xE9\x5E\x01\x00\x00", 5); |
| 83 | + MemSet((void*)0x738404, 0x90, 0x9C); |
| 84 | +} |
0 commit comments