Skip to content

Commit

Permalink
Disable barriers after restore
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed Mar 4, 2024
1 parent 754b096 commit 22bff5f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ void CGameSA::RestoreGameBuildings()
{
m_pPools->GetBuildingsPool().RestoreAllBuildings();

m_pIplStore->SetDynamicIplStreamingEnabled(true);
m_pIplStore->SetDynamicIplStreamingEnabled(true, [](CIplSAInterface* ipl) { return memcmp("barriers", ipl->name, 8) != 0; });
}

// Ensure models have the default lod distances
Expand Down
45 changes: 42 additions & 3 deletions Client/game_sa/CIplStoreSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ void CIplStoreSA::UnloadAndDisableStreaming(int iplId)
((Function_EnableStreaming)(0x405890))(iplId);
}

void CIplStoreSA::EnableStreaming(int iplId)
{
auto ipl = (*m_ppIplPoolInterface)->GetObject(iplId);
ipl->bDisabledStreaming = false;

(*gIplQuadTree)->AddItem(ipl, &ipl->rect);
}

void CIplStoreSA::SetDynamicIplStreamingEnabled(bool state)
{
if (m_isStreamingEnbabled == state)
Expand All @@ -52,10 +60,41 @@ void CIplStoreSA::SetDynamicIplStreamingEnabled(bool state)
{
if (pPool->IsContains(i))
{
auto ipl = pPool->GetObject(i);
ipl->bDisabledStreaming = false;
EnableStreaming(i);
}
}
}

m_isStreamingEnbabled = state;
}

void CIplStoreSA::SetDynamicIplStreamingEnabled(bool state, std::function<bool(CIplSAInterface* ipl)> filer)
{
if (m_isStreamingEnbabled == state)
return;

// Ipl with 0 index is generic
// We don't unload this IPL

(*gIplQuadTree)->AddItem(ipl, &ipl->rect);
auto pPool = *m_ppIplPoolInterface;
if (!state)
{
for (int i = 1; i < pPool->m_nSize; i++)
{
if (pPool->IsContains(i) && filer(pPool->GetObject(i)))
{
UnloadAndDisableStreaming(i);
}
}
(*gIplQuadTree)->RemoveAllItems();
}
else
{
for (int i = 1; i < pPool->m_nSize; i++)
{
if (pPool->IsContains(i) && filer(pPool->GetObject(i)))
{
EnableStreaming(i);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion Client/game_sa/CIplStoreSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

#include "CIplSA.h"
#include "CPoolsSA.h"
#include <game/CIplStore.h>
#include <game/CIplStore.h>=
#include <functional>

class CIplStoreSA : public CIplStore
{
Expand All @@ -22,9 +23,11 @@ class CIplStoreSA : public CIplStore
~CIplStoreSA() = default;

void SetDynamicIplStreamingEnabled(bool state);
void SetDynamicIplStreamingEnabled(bool state, std::function<bool(CIplSAInterface *ipl)> filer);

private:
void UnloadAndDisableStreaming(int iplId);
void EnableStreaming(int iplId);

private:
CPoolSAInterface<CIplSAInterface>** m_ppIplPoolInterface;
Expand Down
1 change: 1 addition & 0 deletions Client/sdk/game/CIplStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ class CIplStore
{
public:
virtual void SetDynamicIplStreamingEnabled(bool state) = 0;
virtual void SetDynamicIplStreamingEnabled(bool state, std::function<bool(CIplSAInterface* ipl)> filer) = 0;
};

0 comments on commit 22bff5f

Please sign in to comment.