Skip to content

Commit d182514

Browse files
Synchronize changes from 1.6 master branch [ci skip]
a55ad43 Make engineRestreamWorld more aggressive (#3602)
2 parents 515789c + a55ad43 commit d182514

File tree

7 files changed

+22
-7
lines changed

7 files changed

+22
-7
lines changed

Client/game_sa/CGameSA.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,21 @@ bool CGameSA::SetBuildingPoolSize(size_t size)
10531053
return status;
10541054
}
10551055

1056+
void CGameSA::UnloadUnusedModels()
1057+
{
1058+
for (size_t id = 0; id < GetBaseIDforCOL(); id++)
1059+
{
1060+
CStreamingInfo* streamingInfo = m_pStreaming->GetStreamingInfo(id);
1061+
if (streamingInfo->loadState != 0 && streamingInfo->sizeInBlocks > 0)
1062+
{
1063+
if (ModelInfo[id].GetRefCount() == 0)
1064+
{
1065+
m_pStreaming->RemoveModel(id);
1066+
}
1067+
};
1068+
}
1069+
}
1070+
10561071
// Ensure models have the default lod distances
10571072
void CGameSA::ResetModelLodDistances()
10581073
{

Client/game_sa/CGameSA.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ class CGameSA : public CGame
308308

309309
bool SetBuildingPoolSize(size_t size);
310310

311+
void UnloadUnusedModels();
312+
311313
private:
312314
CPools* m_pPools;
313315
CPlayerInfo* m_pPlayerInfo;

Client/game_sa/CModelInfoSA.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,11 +1067,6 @@ void CModelInfoSA::ModelAddRef(EModelRequestType requestType, const char* szTag)
10671067
m_dwReferences++;
10681068
}
10691069

1070-
int CModelInfoSA::GetRefCount()
1071-
{
1072-
return static_cast<int>(m_dwReferences);
1073-
}
1074-
10751070
void CModelInfoSA::RemoveRef(bool bRemoveExtraGTARef)
10761071
{
10771072
// Decrement the references

Client/game_sa/CModelInfoSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class CModelInfoSA : public CModelInfo
396396
static void StaticResetAlphaTransparencies();
397397

398398
void ModelAddRef(EModelRequestType requestType, const char* szTag);
399-
int GetRefCount();
399+
int GetRefCount() const override { return static_cast<int>(m_dwReferences); };
400400
void RemoveRef(bool bRemoveExtraGTARef = false);
401401
bool ForceUnload();
402402

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6829,6 +6829,8 @@ void CClientGame::RestreamWorld(bool removeBigBuildings)
68296829
g_pGame->GetStreaming()->RemoveBigBuildings();
68306830

68316831
g_pGame->GetStreaming()->ReinitStreaming();
6832+
6833+
g_pGame->UnloadUnusedModels();
68326834
}
68336835

68346836
void CClientGame::ReinitMarkers()

Client/sdk/game/CGame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,5 @@ class __declspec(novtable) CGame
273273

274274
virtual bool SetBuildingPoolSize(size_t size) = 0;
275275

276+
virtual void UnloadUnusedModels() = 0;
276277
};

Client/sdk/game/CModelInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class CModelInfo
177177

178178
virtual void ModelAddRef(EModelRequestType requestType, const char* szTag /* = NULL*/) = 0;
179179
virtual void RemoveRef(bool bRemoveExtraGTARef = false) = 0;
180-
virtual int GetRefCount() = 0;
180+
virtual int GetRefCount() const = 0;
181181
virtual bool ForceUnload() = 0;
182182
virtual void DeallocateModel() = 0;
183183

0 commit comments

Comments
 (0)