Skip to content

Commit f901042

Browse files
author
G_Moris
committed
Update 7
1 parent 3d0b407 commit f901042

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

Client/game_sa/CHandlingManagerSA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ static bool IsVehicleModel(std::uint32_t model) noexcept
124124
{
125125
try
126126
{
127-
const auto* const pModelInfo = pGame->GetModelInfo(model);
128-
return pModelInfo && pModelInfo->IsVehicle();
127+
const auto* const modelInfo = pGame->GetModelInfo(model);
128+
return modelInfo && modelInfo->IsVehicle();
129129
}
130130
catch (...)
131131
{

Client/game_sa/CModelInfoSA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ bool CModelInfoSA::IsVehicle() const
290290
return false;
291291

292292
// NOTE(botder): m_pInterface might be a nullptr here, we can't use it
293-
CBaseModelInfoSAInterface* pModel = ppModelInfo[m_dwModelID];
294-
return pModel && reinterpret_cast<intptr_t>(pModel->VFTBL) == vftable_CVehicleModelInfo;
293+
CBaseModelInfoSAInterface* model = ppModelInfo[m_dwModelID];
294+
return model && reinterpret_cast<intptr_t>(model->VFTBL) == vftable_CVehicleModelInfo;
295295
}
296296

297297
bool CModelInfoSA::IsPlayerModel()

Client/game_sa/CPoolsSA.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ CVehicle* CPoolsSA::AddVehicle(CClientVehicle* pClientVehicle, std::uint16_t mod
8686
if (!pInterface)
8787
return nullptr;
8888

89-
const auto* const pModelInfo = pGame->GetModelInfo(model);
90-
if (!pModelInfo || !pModelInfo->IsVehicle())
89+
// Valid model?
90+
const auto* const modelInfo = pGame->GetModelInfo(model);
91+
if (!modelInfo || !modelInfo->IsVehicle())
9192
return nullptr;
9293

93-
auto vehicleClass = static_cast<VehicleClass>(pModelInfo->GetVehicleType());
94+
auto vehicleClass = static_cast<VehicleClass>(modelInfo->GetVehicleType());
9495

9596
std::unique_ptr<CVehicleSA> vehicle = nullptr;
9697
switch (vehicleClass)
@@ -585,16 +586,21 @@ static void CreateMissionTrain(const CVector& vecPos, bool bDirection, std::uint
585586
}
586587
}
587588

588-
CVehicle* CPoolsSA::AddTrain(CClientVehicle* pClientVehicle, const CVector& vecPosition, std::vector<DWORD> Models, bool bDirection,
589+
CVehicle* CPoolsSA::AddTrain(CClientVehicle* pClientVehicle, const CVector& vecPosition, std::vector<DWORD> models, bool bDirection,
589590
std::uint8_t ucTrackId) noexcept
590591
{
591592
// clean the existing array
592593
MemSetFast((void*)VAR_TrainModelArray, 0, 32 * sizeof(DWORD));
593594

594595
// now load the models we're going to use and add them to the array
595596
std::size_t count = 0;
596-
for (const auto model : Models)
597+
for (const auto model : models)
597598
{
599+
// Valid model?
600+
const auto* const modelInfo = pGame->GetModelInfo(model);
601+
if (!modelInfo || !modelInfo->IsVehicle())
602+
return nullptr;
603+
598604
if (model == 449 || model == 537 || model == 538 || model == 569 || model == 590 || model == 570)
599605
{
600606
MemPutFast<DWORD>(VAR_TrainModelArray + count * 4, model);

Client/game_sa/CPoolsSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CPoolsSA : public CPools
7676
uint GetModelIdFromClump(RpClump* pRpClump);
7777

7878
// Others
79-
CVehicle* AddTrain(CClientVehicle* pClientVehicle, const CVector& vecPosition, std::vector<DWORD> Models, bool bDirection,
79+
CVehicle* AddTrain(CClientVehicle* pClientVehicle, const CVector& vecPosition, std::vector<DWORD> models, bool bDirection,
8080
std::uint8_t ucTrackId = 255) noexcept;
8181

8282
DWORD GetPedPoolIndex(std::uint8_t* pInterface);

Client/sdk/game/CPools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class CPools
9292
virtual unsigned long GetPedCount() = 0;
9393

9494
// Others
95-
virtual CVehicle* AddTrain(class CClientVehicle* pClientVehicle, const CVector& vecPosition, std::vector<DWORD> Models, bool iDirection,
95+
virtual CVehicle* AddTrain(class CClientVehicle* pClientVehicle, const CVector& vecPosition, std::vector<DWORD> models, bool iDirection,
9696
std::uint8_t ucTrackId = 255) noexcept = 0;
9797

9898
virtual CEntity* GetEntity(DWORD* pGameInterface) = 0;

0 commit comments

Comments
 (0)