|
14 | 14 | #include "CBmxSA.h" |
15 | 15 | #include "CBoatSA.h" |
16 | 16 | #include "CBuildingSA.h" |
| 17 | +#include "CColModelSA.h" |
17 | 18 | #include "CGameSA.h" |
18 | 19 | #include "CHeliSA.h" |
| 20 | +#include "CModelInfoSA.h" |
19 | 21 | #include "CMonsterTruckSA.h" |
20 | 22 | #include "CPlaneSA.h" |
21 | 23 | #include "CPlayerPedSA.h" |
@@ -79,6 +81,34 @@ CVehicle* CPoolsSA::AddVehicle(CClientVehicle* pClientVehicle, std::uint16_t mod |
79 | 81 | if (m_vehiclePool.ulCount >= MAX_VEHICLES) |
80 | 82 | return nullptr; |
81 | 83 |
|
| 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 | + |
82 | 112 | MemSetFast((void*)VAR_CVehicle_Variation1, variation, 1); |
83 | 113 | MemSetFast((void*)VAR_CVehicle_Variation2, variation2, 1); |
84 | 114 |
|
|
0 commit comments