Skip to content

Commit fa1f0e5

Browse files
authored
Allow unload model with custom col (#2866)
1 parent 2acf0cd commit fa1f0e5

File tree

2 files changed

+3
-42
lines changed

2 files changed

+3
-42
lines changed

Client/game_sa/CModelInfoSA.cpp

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ CModelInfoSA::CModelInfoSA()
6060
m_pOriginalColModelInterface = NULL;
6161
m_pCustomClump = NULL;
6262
m_pCustomColModel = NULL;
63-
m_bAddedRefForCollision = false;
6463
}
6564

6665
CBaseModelInfoSAInterface* CModelInfoSA::GetInterface()
@@ -391,36 +390,15 @@ void CModelInfoSA::Remove()
391390

392391
m_pInterface = ppModelInfo[m_dwModelID];
393392

394-
// Remove ref added for collision
395-
if (m_bAddedRefForCollision)
396-
{
397-
m_bAddedRefForCollision = false;
398-
if (m_pInterface->usNumberOfRefs > 0)
399-
m_pInterface->usNumberOfRefs--;
400-
}
401-
402393
// Remove our reference
403394
if (m_pInterface->usNumberOfRefs > 0)
404395
m_pInterface->usNumberOfRefs--;
405396

406397
// No references left?
407-
if (m_pInterface->usNumberOfRefs == 0)
398+
if (m_pInterface->usNumberOfRefs == 0 && !m_pCustomClump && !m_pCustomColModel)
408399
{
409-
// We have a custom model?
410-
if (m_pCustomClump)
411-
{
412-
// Mark us as unloaded. We manage the clump unloading.
413-
// BYTE *ModelLoaded = (BYTE*)ARRAY_ModelLoaded;
414-
// ModelLoaded[(m_dwModelID+m_dwModelID*4)<<2] = 0;
415-
}
416-
else
417-
{
418-
// Make our collision model original again before we unload.
419-
RestoreColModel();
420-
421-
// Remove the model.
422-
pGame->GetStreaming()->RemoveModel(m_dwModelID);
423-
}
400+
// Remove the model.
401+
pGame->GetStreaming()->RemoveModel(m_dwModelID);
424402
}
425403
}
426404

@@ -1244,15 +1222,6 @@ void CModelInfoSA::SetColModel(CColModel* pColModel)
12441222
// Grab the interfaces
12451223
CColModelSAInterface* pColModelInterface = pColModel->GetInterface();
12461224

1247-
if (!m_bAddedRefForCollision)
1248-
{
1249-
// Prevent this model from unloading while we have custom collision
1250-
ModelAddRef(BLOCKING, "for collision");
1251-
m_bAddedRefForCollision = true;
1252-
}
1253-
1254-
// Should always be loaded at this point
1255-
12561225
// Skip setting if already done
12571226
if (m_pCustomColModel == pColModel)
12581227
return;
@@ -1328,13 +1297,6 @@ void CModelInfoSA::RestoreColModel()
13281297
m_pCustomColModel = nullptr;
13291298
m_pOriginalColModelInterface = nullptr;
13301299
m_originalFlags = 0;
1331-
1332-
// Remove ref added for collision
1333-
if (m_bAddedRefForCollision)
1334-
{
1335-
m_bAddedRefForCollision = false;
1336-
RemoveRef();
1337-
}
13381300
}
13391301

13401302
void CModelInfoSA::MakeCustomModel()

Client/game_sa/CModelInfoSA.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ class CModelInfoSA : public CModelInfo
307307
static std::map<CTimeInfoSAInterface*, CTimeInfoSAInterface*> ms_ModelDefaultModelTimeInfo;
308308
static std::unordered_map<DWORD, unsigned short> ms_OriginalObjectPropertiesGroups;
309309
static std::unordered_map<DWORD, std::pair<float, float>> ms_VehicleModelDefaultWheelSizes;
310-
bool m_bAddedRefForCollision;
311310
SVehicleSupportedUpgrades m_ModelSupportedUpgrades;
312311

313312
public:

0 commit comments

Comments
 (0)