Skip to content

Commit

Permalink
Revert "Make engineRestreamWorld more aggressive (PR #3685)" (Fixes #…
Browse files Browse the repository at this point in the history
…3913)

This reverts commit bae4ca9.
  • Loading branch information
botder committed Dec 30, 2024
1 parent c7644f2 commit 4f30dc0
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 48 deletions.
27 changes: 0 additions & 27 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,33 +1102,6 @@ bool CGameSA::SetBuildingPoolSize(size_t size)
return status;
}

void CGameSA::UnloadUnusedModels()
{
// Unload DFF's
// CJ should not be unloaded
const std::size_t baseIdForTxd = GetBaseIDforTXD();
for (std::size_t id = 1; id < baseIdForTxd; id++)
{
CStreamingInfo* streamingInfo = m_pStreaming->GetStreamingInfo(id);
if (streamingInfo->loadState != eModelLoadState::LOADSTATE_NOT_LOADED && streamingInfo->sizeInBlocks > 0)
{
CModelInfoSA& model = ModelInfo[id];
if (model.GetRefCount() == 0)
model.UnloadUnused();
};
}
// Unload TXD
for (std::size_t id = baseIdForTxd; id < GetBaseIDforCOL(); id++)
{
CStreamingInfo* streamingInfo = m_pStreaming->GetStreamingInfo(id);
std::size_t refsCount = GetPools()->GetTxdPool().GetRefsCount(id - baseIdForTxd);
if (streamingInfo->loadState != eModelLoadState::LOADSTATE_NOT_LOADED && streamingInfo->sizeInBlocks > 0 && refsCount == 0)
{
GetStreaming()->RemoveModel(id);
}
}
}

// Ensure models have the default lod distances
void CGameSA::ResetModelLodDistances()
{
Expand Down
2 changes: 0 additions & 2 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ class CGameSA : public CGame

bool SetBuildingPoolSize(size_t size);

void UnloadUnusedModels();

private:
std::unique_ptr<CPools> m_Pools;
CPlayerInfo* m_pPlayerInfo;
Expand Down
7 changes: 5 additions & 2 deletions Client/game_sa/CModelInfoSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ void CModelInfoSA::Remove()

bool CModelInfoSA::UnloadUnused()
{
m_pInterface = ppModelInfo[m_dwModelID];

if (m_pInterface->usNumberOfRefs == 0 && !m_pCustomClump && !m_pCustomColModel)
{
pGame->GetStreaming()->RemoveModel(m_dwModelID);
Expand Down Expand Up @@ -1096,6 +1094,11 @@ void CModelInfoSA::ModelAddRef(EModelRequestType requestType, const char* szTag)
m_dwReferences++;
}

int CModelInfoSA::GetRefCount()
{
return static_cast<int>(m_dwReferences);
}

void CModelInfoSA::RemoveRef(bool bRemoveExtraGTARef)
{
// Decrement the references
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CModelInfoSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class CModelInfoSA : public CModelInfo
static void StaticResetAlphaTransparencies();

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

Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CPoolSAInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CPoolSAInterface
return !IsEmpty(index);
}

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

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

Expand Down
9 changes: 0 additions & 9 deletions Client/game_sa/CTxdPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,3 @@ std::uint16_t CTxdPoolSA::GetFreeTextureDictonarySlot()
{
return (*m_ppTxdPoolInterface)->GetFreeSlot();
}

std::uint16_t CTxdPoolSA::GetRefsCount(std::uint16_t slot) const
{
CTextureDictonarySAInterface* pTxd = (*m_ppTxdPoolInterface)->GetObject(slot);
if (!pTxd)
return -1;

return pTxd->usUsagesCount;
}
1 change: 0 additions & 1 deletion Client/game_sa/CTxdPoolSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CTxdPoolSA final : public CTxdPool
bool IsFreeTextureDictonarySlot(std::uint32_t uiTxdId);

std::uint16_t GetFreeTextureDictonarySlot();
std::uint16_t GetRefsCount(std::uint16_t slot) const;

private:
CPoolSAInterface<CTextureDictonarySAInterface>** m_ppTxdPoolInterface;
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6764,8 +6764,6 @@ void CClientGame::RestreamWorld()

g_pGame->GetStreaming()->RemoveBigBuildings();
g_pGame->GetStreaming()->ReinitStreaming();

g_pGame->UnloadUnusedModels();
}

void CClientGame::ReinitMarkers()
Expand Down
1 change: 0 additions & 1 deletion Client/sdk/game/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,4 @@ class __declspec(novtable) CGame

virtual bool SetBuildingPoolSize(size_t size) = 0;

virtual void UnloadUnusedModels() = 0;
};
2 changes: 1 addition & 1 deletion Client/sdk/game/CModelInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class CModelInfo

virtual void ModelAddRef(EModelRequestType requestType, const char* szTag /* = NULL*/) = 0;
virtual void RemoveRef(bool bRemoveExtraGTARef = false) = 0;
virtual int GetRefCount() const = 0;
virtual int GetRefCount() = 0;
virtual bool ForceUnload() = 0;
virtual bool UnloadUnused() = 0;
virtual void DeallocateModel() = 0;
Expand Down
1 change: 0 additions & 1 deletion Client/sdk/game/CTxdPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ class CTxdPool
virtual bool IsFreeTextureDictonarySlot(std::uint32_t uiTxdID) = 0;

virtual std::uint16_t GetFreeTextureDictonarySlot() = 0;
virtual std::uint16_t GetRefsCount(std::uint16_t slot) const = 0;
};

0 comments on commit 4f30dc0

Please sign in to comment.