Skip to content

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed Jun 12, 2024
1 parent e7f4945 commit ba5b3e5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Client/game_sa/CBuildingRemovalSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,22 @@ void CBuildingRemovalSA::RemoveWorldBuildingFromLists(CEntitySAInterface* pInter
m_pRemovedEntities[(DWORD)pInterface] = false;
m_pAddedEntities[(DWORD)pInterface] = false;
}

void CBuildingRemovalSA::DropCaches()
{
m_pRemovedEntities.clear();
m_pAddedEntities.clear();

for (auto& it : *m_pBinaryBuildings)
{
delete it.second;
}

for (auto& it : *m_pDataBuildings)
{
delete it.second;
}

m_pBinaryBuildings->clear();
m_pDataBuildings->clear();
}
1 change: 1 addition & 0 deletions Client/game_sa/CBuildingRemovalSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CBuildingRemovalSA : public CBuildingRemoval
bool IsObjectRemoved(CEntitySAInterface* pInterface) override;
bool IsDataModelRemoved(uint16_t usModelID) override;
bool IsEntityRemoved(CEntitySAInterface* pInterface) override;
void DropCaches();

private:
std::multimap<uint16_t, SBuildingRemoval*>* m_pBuildingRemovals;
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ bool CGameSA::SetBuildingPoolSize(size_t size)
RemoveAllBuildings();
}

((CBuildingRemovalSA*)GetBuildingRemoval())->DropCaches();
bool status = m_pPools->GetBuildingsPool().Resize(size);

if (shouldRemoveBuilding)
Expand Down

0 comments on commit ba5b3e5

Please sign in to comment.