Skip to content

Commit 46ca24e

Browse files
committed
Refactor IsPassenger
1 parent db8c0d8 commit 46ca24e

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

Client/game_sa/CVehicleAudioSettingsEntrySA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ class CVehicleAudioSettingsEntrySA final : public CVehicleAudioSettingsEntry
4040
CVehicleAudioSettingsEntrySA(tVehicleAudioSettings* pSettings) { m_Settings = *pSettings; };
4141
~CVehicleAudioSettingsEntrySA() = default;
4242

43-
tVehicleAudioSettings* getInterface() { return &m_Settings; };
43+
const tVehicleAudioSettings& getInterface() const noexcept { return m_Settings; };
4444

4545
void Assign(const tVehicleAudioSettings& settings) noexcept { m_Settings = settings; }
46-
void Assign(const CVehicleAudioSettingsEntry* settings) noexcept { m_Settings = static_cast<const CVehicleAudioSettingsEntrySA*>(settings)->m_Settings; };
46+
void Assign(const CVehicleAudioSettingsEntry* settings) noexcept { m_Settings = static_cast<const CVehicleAudioSettingsEntrySA*>(settings)->getInterface(); };
4747

4848
eVehicleSoundType GetSoundType() const noexcept override { return m_Settings.m_eVehicleSoundType; };
4949
short GetEngineOnSoundBankID() const noexcept override { return m_Settings.m_nEngineOnSoundBankId; };

Client/game_sa/CVehicleSA.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -912,18 +912,8 @@ void CVehicleSA::SetEngineOn(bool bEngineOn)
912912

913913
bool CVehicleSA::IsPassenger(CPed* pPed)
914914
{
915-
DWORD dwThis = (DWORD)m_pInterface;
916-
DWORD dwFunc = FUNC_CVehicle_IsPassenger;
917-
bool bReturn = false;
918-
919-
_asm
920-
{
921-
mov ecx, dwThis
922-
push pPed
923-
call dwFunc
924-
mov bReturn, al
925-
}
926-
return bReturn;
915+
using FUNC_CVehicle_IsPassenger_t = bool(__thiscall*)(CVehicleSAInterface* self, CPedSAInterface* ped);
916+
return ((FUNC_CVehicle_IsPassenger_t)(FUNC_CVehicle_IsPassenger))(GetVehicleInterface(), pPed->GetPedInterface());
927917
}
928918

929919
CPed* CVehicleSA::GetDriver()

0 commit comments

Comments
 (0)