Skip to content

Commit 3af8182

Browse files
committed
Fix SA crash @ 0x002A65EF (0x006A65EF)
CAutomobile::SetupSuspensionLines()
1 parent 50b3a37 commit 3af8182

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Client/game_sa/CPoolsSA.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#include "CBmxSA.h"
1515
#include "CBoatSA.h"
1616
#include "CBuildingSA.h"
17+
#include "CColModelSA.h"
1718
#include "CGameSA.h"
1819
#include "CHeliSA.h"
20+
#include "CModelInfoSA.h"
1921
#include "CMonsterTruckSA.h"
2022
#include "CPlaneSA.h"
2123
#include "CPlayerPedSA.h"
@@ -79,6 +81,34 @@ CVehicle* CPoolsSA::AddVehicle(CClientVehicle* pClientVehicle, std::uint16_t mod
7981
if (m_vehiclePool.ulCount >= MAX_VEHICLES)
8082
return nullptr;
8183

84+
// Ensure collision model is fully loaded to prevent crash at 0x002a65ef in SetupSuspensionLines
85+
CModelInfoSA* pModelInfo = static_cast<CModelInfoSA*>(pGame->GetModelInfo(model));
86+
if (!pModelInfo || !pModelInfo->GetInterface())
87+
return nullptr;
88+
89+
CBaseModelInfoSAInterface* pModelInterface = pModelInfo->GetInterface();
90+
91+
if (!pModelInterface->pColModel)
92+
{
93+
// Collision model pointer is NULL - try loading
94+
pGame->GetStreaming()->LoadAllRequestedModels(false, "CPoolsSA::AddVehicle");
95+
96+
// Re-check after loading - still NULL means loading failed
97+
if (!pModelInterface->pColModel)
98+
return nullptr;
99+
}
100+
101+
// Check if collision data (m_pColData) is loaded
102+
if (!pModelInterface->pColModel->m_data)
103+
{
104+
// Collision data not loaded - force load
105+
pGame->GetStreaming()->LoadAllRequestedModels(false, "CPoolsSA::AddVehicle");
106+
107+
// Re-check after loading - still not loaded means loading failed
108+
if (!pModelInterface->pColModel->m_data)
109+
return nullptr;
110+
}
111+
82112
MemSetFast((void*)VAR_CVehicle_Variation1, variation, 1);
83113
MemSetFast((void*)VAR_CVehicle_Variation2, variation2, 1);
84114

0 commit comments

Comments
 (0)