Skip to content

Commit a4b4fad

Browse files
Synchronize changes from 1.6 master branch [ci skip]
4f30dc0 Revert "Make engineRestreamWorld more aggressive (PR #3685)" (Fixes #3913)
2 parents 93e31ca + 4f30dc0 commit a4b4fad

File tree

11 files changed

+8
-48
lines changed

11 files changed

+8
-48
lines changed

Client/game_sa/CGameSA.cpp

-27
Original file line numberDiff line numberDiff line change
@@ -1102,33 +1102,6 @@ bool CGameSA::SetBuildingPoolSize(size_t size)
11021102
return status;
11031103
}
11041104

1105-
void CGameSA::UnloadUnusedModels()
1106-
{
1107-
// Unload DFF's
1108-
// CJ should not be unloaded
1109-
const std::size_t baseIdForTxd = GetBaseIDforTXD();
1110-
for (std::size_t id = 1; id < baseIdForTxd; id++)
1111-
{
1112-
CStreamingInfo* streamingInfo = m_pStreaming->GetStreamingInfo(id);
1113-
if (streamingInfo->loadState != eModelLoadState::LOADSTATE_NOT_LOADED && streamingInfo->sizeInBlocks > 0)
1114-
{
1115-
CModelInfoSA& model = ModelInfo[id];
1116-
if (model.GetRefCount() == 0)
1117-
model.UnloadUnused();
1118-
};
1119-
}
1120-
// Unload TXD
1121-
for (std::size_t id = baseIdForTxd; id < GetBaseIDforCOL(); id++)
1122-
{
1123-
CStreamingInfo* streamingInfo = m_pStreaming->GetStreamingInfo(id);
1124-
std::size_t refsCount = GetPools()->GetTxdPool().GetRefsCount(id - baseIdForTxd);
1125-
if (streamingInfo->loadState != eModelLoadState::LOADSTATE_NOT_LOADED && streamingInfo->sizeInBlocks > 0 && refsCount == 0)
1126-
{
1127-
GetStreaming()->RemoveModel(id);
1128-
}
1129-
}
1130-
}
1131-
11321105
// Ensure models have the default lod distances
11331106
void CGameSA::ResetModelLodDistances()
11341107
{

Client/game_sa/CGameSA.h

-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ class CGameSA : public CGame
312312

313313
bool SetBuildingPoolSize(size_t size);
314314

315-
void UnloadUnusedModels();
316-
317315
private:
318316
std::unique_ptr<CPools> m_Pools;
319317
CPlayerInfo* m_pPlayerInfo;

Client/game_sa/CModelInfoSA.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,6 @@ void CModelInfoSA::Remove()
452452

453453
bool CModelInfoSA::UnloadUnused()
454454
{
455-
m_pInterface = ppModelInfo[m_dwModelID];
456-
457455
if (m_pInterface->usNumberOfRefs == 0 && !m_pCustomClump && !m_pCustomColModel)
458456
{
459457
pGame->GetStreaming()->RemoveModel(m_dwModelID);
@@ -1096,6 +1094,11 @@ void CModelInfoSA::ModelAddRef(EModelRequestType requestType, const char* szTag)
10961094
m_dwReferences++;
10971095
}
10981096

1097+
int CModelInfoSA::GetRefCount()
1098+
{
1099+
return static_cast<int>(m_dwReferences);
1100+
}
1101+
10991102
void CModelInfoSA::RemoveRef(bool bRemoveExtraGTARef)
11001103
{
11011104
// Decrement the references

Client/game_sa/CModelInfoSA.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class CModelInfoSA : public CModelInfo
397397
static void StaticResetAlphaTransparencies();
398398

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

Client/game_sa/CPoolSAInterface.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class CPoolSAInterface
122122
return !IsEmpty(index);
123123
}
124124

125-
B* GetObject(std::int32_t objectIndex) const { return &m_pObjects[objectIndex]; }
125+
B* GetObject(std::int32_t objectIndex) { return &m_pObjects[objectIndex]; }
126126

127127
uint GetObjectIndex(B* pObject) { return ((DWORD)pObject - (DWORD)m_pObjects) / sizeof(B); }
128128

Client/game_sa/CTxdPoolSA.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,3 @@ std::uint16_t CTxdPoolSA::GetFreeTextureDictonarySlot()
5555
{
5656
return (*m_ppTxdPoolInterface)->GetFreeSlot();
5757
}
58-
59-
std::uint16_t CTxdPoolSA::GetRefsCount(std::uint16_t slot) const
60-
{
61-
CTextureDictonarySAInterface* pTxd = (*m_ppTxdPoolInterface)->GetObject(slot);
62-
if (!pTxd)
63-
return -1;
64-
65-
return pTxd->usUsagesCount;
66-
}

Client/game_sa/CTxdPoolSA.h

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class CTxdPoolSA final : public CTxdPool
2525
bool IsFreeTextureDictonarySlot(std::uint32_t uiTxdId);
2626

2727
std::uint16_t GetFreeTextureDictonarySlot();
28-
std::uint16_t GetRefsCount(std::uint16_t slot) const;
2928

3029
private:
3130
CPoolSAInterface<CTextureDictonarySAInterface>** m_ppTxdPoolInterface;

Client/mods/deathmatch/logic/CClientGame.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -6764,8 +6764,6 @@ void CClientGame::RestreamWorld()
67646764

67656765
g_pGame->GetStreaming()->RemoveBigBuildings();
67666766
g_pGame->GetStreaming()->ReinitStreaming();
6767-
6768-
g_pGame->UnloadUnusedModels();
67696767
}
67706768

67716769
void CClientGame::ReinitMarkers()

Client/sdk/game/CGame.h

-1
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,4 @@ class __declspec(novtable) CGame
278278

279279
virtual bool SetBuildingPoolSize(size_t size) = 0;
280280

281-
virtual void UnloadUnusedModels() = 0;
282281
};

Client/sdk/game/CModelInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class CModelInfo
181181

182182
virtual void ModelAddRef(EModelRequestType requestType, const char* szTag /* = NULL*/) = 0;
183183
virtual void RemoveRef(bool bRemoveExtraGTARef = false) = 0;
184-
virtual int GetRefCount() const = 0;
184+
virtual int GetRefCount() = 0;
185185
virtual bool ForceUnload() = 0;
186186
virtual bool UnloadUnused() = 0;
187187
virtual void DeallocateModel() = 0;

Client/sdk/game/CTxdPool.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ class CTxdPool
1919
virtual bool IsFreeTextureDictonarySlot(std::uint32_t uiTxdID) = 0;
2020

2121
virtual std::uint16_t GetFreeTextureDictonarySlot() = 0;
22-
virtual std::uint16_t GetRefsCount(std::uint16_t slot) const = 0;
2322
};

0 commit comments

Comments
 (0)