VC: Make drive-by one shot sounds owned by the driver instead of the car

This commit is contained in:
Silent 2019-12-25 17:40:59 +01:00
parent f3f9004322
commit 4679873c3a
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
5 changed files with 39 additions and 1 deletions

View File

@ -1130,6 +1130,19 @@ void Patch_VC_Common()
static const float MULT_6 = 6.0f;
Patch( extraMult6, &MULT_6 );
}
// Make drive-by one shot sounds owned by the driver instead of the car
// Fixes incorrect weapon sound being used for drive-by
{
auto getDriverOneShot = pattern( "FF 35 ? ? ? ? 6A 37 50 E8 ? ? ? ? 83 7E 08 00" ).get_one();
// nop
// mov ecx, ebx
// call CVehicle::GetOneShotOwnerID
Patch( getDriverOneShot.get<void>( -8 ), { 0x90, 0x89, 0xD9 } );
InjectHook( getDriverOneShot.get<void>( -5 ), &CVehicle::GetOneShotOwnerID_SilentPatch, PATCH_CALL );
}
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

View File

@ -220,6 +220,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="VehicleVC.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc" />

View File

@ -92,6 +92,9 @@
<ClCompile Include="..\SilentPatch\SVF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VehicleVC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -0,0 +1,15 @@
#include "StdAfx.h"
#include "VehicleVC.h"
int32_t CVehicle::GetOneShotOwnerID_SilentPatch() const
{
if ( m_pDriver != nullptr )
{
// TODO: Define this as a proper CPhysical
uintptr_t ptr = reinterpret_cast<uintptr_t>(m_pDriver);
return *reinterpret_cast<int32_t*>( ptr + 0x64 );
}
// Fallback
return m_audioEntityId;
}

View File

@ -21,8 +21,12 @@ protected:
CMatrix m_matrix;
uint8_t __pad4[16];
uint16_t m_modelIndex; // TODO: THE FLA
void* m_pFirstReference;
int32_t m_audioEntityId; // TODO: This should really be CPhysical
uint8_t __pad5[320];
void* m_pDriver;
uint8_t __pad1[414];
uint8_t __pad1[80];
uint8_t m_BombOnBoard : 3;
uint8_t __pad2[17];
class CEntity* m_pBombOwner;
@ -44,6 +48,8 @@ public:
{ m_BombOnBoard = bombOnBoard; }
void SetBombOwner( class CEntity* owner )
{ m_pBombOwner = owner; }
int32_t GetOneShotOwnerID_SilentPatch() const;
};
class CAutomobile : public CVehicle