Skip to content

Commit

Permalink
Refactor IsPassenger
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed Feb 3, 2025
1 parent db8c0d8 commit 46ca24e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Client/game_sa/CVehicleAudioSettingsEntrySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class CVehicleAudioSettingsEntrySA final : public CVehicleAudioSettingsEntry
CVehicleAudioSettingsEntrySA(tVehicleAudioSettings* pSettings) { m_Settings = *pSettings; };
~CVehicleAudioSettingsEntrySA() = default;

tVehicleAudioSettings* getInterface() { return &m_Settings; };
const tVehicleAudioSettings& getInterface() const noexcept { return m_Settings; };

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

eVehicleSoundType GetSoundType() const noexcept override { return m_Settings.m_eVehicleSoundType; };
short GetEngineOnSoundBankID() const noexcept override { return m_Settings.m_nEngineOnSoundBankId; };
Expand Down
14 changes: 2 additions & 12 deletions Client/game_sa/CVehicleSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,18 +912,8 @@ void CVehicleSA::SetEngineOn(bool bEngineOn)

bool CVehicleSA::IsPassenger(CPed* pPed)
{
DWORD dwThis = (DWORD)m_pInterface;
DWORD dwFunc = FUNC_CVehicle_IsPassenger;
bool bReturn = false;

_asm
{
mov ecx, dwThis
push pPed
call dwFunc
mov bReturn, al
}
return bReturn;
using FUNC_CVehicle_IsPassenger_t = bool(__thiscall*)(CVehicleSAInterface* self, CPedSAInterface* ped);
return ((FUNC_CVehicle_IsPassenger_t)(FUNC_CVehicle_IsPassenger))(GetVehicleInterface(), pPed->GetPedInterface());
}

CPed* CVehicleSA::GetDriver()
Expand Down

0 comments on commit 46ca24e

Please sign in to comment.