Skip to content

Commit 434457a

Browse files
author
G_Moris
committed
Update 6
1 parent ffd2ba7 commit 434457a

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

Client/game_sa/CHandlingManagerSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static bool IsVehicleModel(std::uint32_t model) noexcept
124124
{
125125
try
126126
{
127-
const auto* pModelInfo = pGame->GetModelInfo(model);
127+
const auto* const pModelInfo = pGame->GetModelInfo(model);
128128
return pModelInfo && pModelInfo->IsVehicle();
129129
}
130130
catch (...)

Client/game_sa/CModelInfoSA.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,12 @@ bool CModelInfoSA::IsVehicle() const
286286
if (m_dwModelID >= 20000)
287287
return false;
288288

289+
if (!IsAllocatedInArchive())
290+
return false;
291+
289292
// NOTE(botder): m_pInterface might be a nullptr here, we can't use it
290-
CBaseModelInfoSAInterface* model = ppModelInfo[m_dwModelID];
291-
return model != nullptr && reinterpret_cast<intptr_t>(model->VFTBL) == vftable_CVehicleModelInfo;
293+
CBaseModelInfoSAInterface* pModel = ppModelInfo[m_dwModelID];
294+
return pModel && reinterpret_cast<intptr_t>(pModel->VFTBL) == vftable_CVehicleModelInfo;
292295
}
293296

294297
bool CModelInfoSA::IsPlayerModel()
@@ -748,9 +751,16 @@ bool CModelInfoSA::IsValid()
748751
return true;
749752
}
750753

751-
bool CModelInfoSA::IsAllocatedInArchive()
754+
bool CModelInfoSA::IsAllocatedInArchive() const noexcept
752755
{
753-
return pGame->GetStreaming()->GetStreamingInfo(m_dwModelID)->sizeInBlocks > 0;
756+
try
757+
{
758+
return pGame->GetStreaming()->GetStreamingInfo(m_dwModelID)->sizeInBlocks > 0;
759+
}
760+
catch (...)
761+
{
762+
return false;
763+
}
754764
}
755765

756766
float CModelInfoSA::GetDistanceFromCentreOfMassToBaseOfModel()

Client/game_sa/CModelInfoSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class CModelInfoSA : public CModelInfo
374374
static void StaticResetFlags();
375375
CBoundingBox* GetBoundingBox();
376376
bool IsValid();
377-
bool IsAllocatedInArchive();
377+
bool IsAllocatedInArchive() const noexcept;
378378
float GetDistanceFromCentreOfMassToBaseOfModel();
379379
unsigned short GetTextureDictionaryID();
380380
void SetTextureDictionaryID(unsigned short usID);

Client/game_sa/CPoolsSA.cpp

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

89-
const auto* modelInfo = pGame->GetModelInfo(model);
90-
if (!modelInfo || !modelInfo->IsVehicle())
89+
const auto* const pModelInfo = pGame->GetModelInfo(model);
90+
if (!pModelInfo || !pModelInfo->IsVehicle())
9191
return nullptr;
9292

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

9595
std::unique_ptr<CVehicleSA> vehicle = nullptr;
9696
switch (vehicleClass)

Client/sdk/game/CModelInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class CModelInfo
166166
virtual void SetIdeFlag(eModelIdeFlag eFlag, bool bState) = 0;
167167
virtual CBoundingBox* GetBoundingBox() = 0;
168168
virtual bool IsValid() = 0;
169-
virtual bool IsAllocatedInArchive() = 0;
169+
virtual bool IsAllocatedInArchive() const noexcept = 0;
170170
virtual unsigned short GetTextureDictionaryID() = 0;
171171
virtual void SetTextureDictionaryID(unsigned short usTxdId) = 0;
172172
virtual void ResetTextureDictionaryID() = 0;

Server/mods/deathmatch/logic/CVehicle.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,12 +850,14 @@ void CVehicle::GetInitialDoorStates(SFixedArray<unsigned char, MAX_DOORS>& ucOut
850850

851851
void CVehicle::GenerateHandlingData() noexcept
852852
{
853+
const auto handlingManager = g_pGame->GetHandlingManager();
854+
853855
// Make a new CHandlingEntry
854856
if (!m_HandlingEntry)
855-
m_HandlingEntry = g_pGame->GetHandlingManager()->CreateHandlingData();
857+
m_HandlingEntry = handlingManager->CreateHandlingData();
856858

857859
// Apply the model handling info
858-
m_HandlingEntry->ApplyHandlingData(g_pGame->GetHandlingManager()->GetModelHandlingData(m_usModel));
860+
m_HandlingEntry->ApplyHandlingData(handlingManager->GetModelHandlingData(m_usModel));
859861

860862
m_bHandlingChanged = false;
861863
}

0 commit comments

Comments
 (0)