diff --git a/Client/game_sa/CAEVehicleAudioEntitySA.h b/Client/game_sa/CAEVehicleAudioEntitySA.h index c2ab9d2eae..23ae22941f 100644 --- a/Client/game_sa/CAEVehicleAudioEntitySA.h +++ b/Client/game_sa/CAEVehicleAudioEntitySA.h @@ -21,6 +21,8 @@ #define FUNC_CAEVehicleAudioEntity__ProcessAIProp 0x4FDFD0 #define FUNC_CAEVehicleAudioEntity__ProcessAIHeli 0x4FEE20 +class CVehicleSAInterface; + struct tVehicleSound { int m_dwIndex; @@ -51,9 +53,13 @@ static_assert(sizeof(CAETwinLoopSoundEntity) == 0xA8, "Invalid size for CAETwinL class CAEVehicleAudioEntitySAInterface : public CAEAudioEntity { public: - void AddAudioEvent(int eventId, float volume) + void AddAudioEvent(int eventId, float volume) { ((void(__thiscall*)(CAEVehicleAudioEntitySAInterface*, int, float))0x4F6420)(this, eventId, volume); } + bool TerminateAudio() { return ((bool(__thiscall*)(CAEVehicleAudioEntitySAInterface*))0x4FB8C0)(this); } + bool SoundJoin() { return ((bool(__thiscall*)(CAEVehicleAudioEntitySAInterface*))0x4F5700)(this); } + + int16_t InitAudio(CVehicleSAInterface* vehicle) { - ((void(__thiscall*)(CAEVehicleAudioEntitySAInterface*, int, float))0x4F6420)(this, eventId, volume); + return ((int16_t(__thiscall*)(CAEVehicleAudioEntitySAInterface*, CVehicleSAInterface*))0x4F7670)(this, vehicle); } short unk1; // +124 diff --git a/Client/game_sa/CVehicleSA.cpp b/Client/game_sa/CVehicleSA.cpp index 2b45872e29..dac1446ce5 100644 --- a/Client/game_sa/CVehicleSA.cpp +++ b/Client/game_sa/CVehicleSA.cpp @@ -2481,17 +2481,13 @@ bool CVehicleSA::SetWindowOpenFlagState(unsigned char ucWindow, bool bState) void CVehicleSA::ReinitAudio() { - typedef bool(__thiscall * Function_TerminateAudio)(CAEVehicleAudioEntitySAInterface * pAudio); - ((Function_TerminateAudio)(0x4FB8C0))(m_pVehicleAudioEntity->GetInterface()); + auto* audioInterface = m_pVehicleAudioEntity->GetInterface(); - typedef int16(__thiscall * Function_InitAudio)(CAEVehicleAudioEntitySAInterface * pAudio, CVehicleSAInterface * pVehicleInterface); - ((Function_InitAudio)(0x4F7670))(m_pVehicleAudioEntity->GetInterface(), GetVehicleInterface()); + audioInterface->TerminateAudio(); + audioInterface->InitAudio(GetVehicleInterface()); CPed* pLocalPlayer = pGame->GetPedContext(); if (IsPassenger(pLocalPlayer) || GetDriver() == pLocalPlayer) - { - typedef bool(__thiscall * Function_SoundJoin)(CAEVehicleAudioEntitySAInterface * pAudio); - ((Function_SoundJoin)(0x4F5700))(m_pVehicleAudioEntity->GetInterface()); - } + audioInterface->SoundJoin(); }