From 0b3dc0184b2322c610da0ebb4b69ff68900b6627 Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Wed, 29 May 2024 23:02:28 +0300 Subject: [PATCH] Fix SetBuildingPoolSize resets RemoveAllBuildings --- Client/game_sa/CGameSA.cpp | 13 +++++++++++-- Client/game_sa/CGameSA.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Client/game_sa/CGameSA.cpp b/Client/game_sa/CGameSA.cpp index e4029c7ecd..9a80012eb2 100644 --- a/Client/game_sa/CGameSA.cpp +++ b/Client/game_sa/CGameSA.cpp @@ -909,6 +909,7 @@ void CGameSA::RemoveAllBuildings() m_pPools->GetDummyPool().RemoveAllBuildingLods(); m_pPools->GetBuildingsPool().RemoveAllBuildings(); + m_isBuildingsRemoved = true; } void CGameSA::RestoreGameBuildings() @@ -917,15 +918,23 @@ void CGameSA::RestoreGameBuildings() m_pPools->GetDummyPool().RestoreAllBuildingsLods(); m_pIplStore->SetDynamicIplStreamingEnabled(true, [](CIplSAInterface* ipl) { return memcmp("barriers", ipl->name, 8) != 0; }); + m_isBuildingsRemoved = false; } bool CGameSA::SetBuildingPoolSize(size_t size) { - RemoveAllBuildings(); + const bool shouldRemoveBuilding = !m_isBuildingsRemoved; + if (shouldRemoveBuilding) + { + RemoveAllBuildings(); + } bool status = m_pPools->GetBuildingsPool().Resize(size); - RestoreGameBuildings(); + if (shouldRemoveBuilding) + { + RestoreGameBuildings(); + } return status; } diff --git a/Client/game_sa/CGameSA.h b/Client/game_sa/CGameSA.h index c668276656..df8a2e5b79 100644 --- a/Client/game_sa/CGameSA.h +++ b/Client/game_sa/CGameSA.h @@ -348,6 +348,7 @@ class CGameSA : public CGame bool m_isBurnFlippedCarsEnabled{true}; bool m_isFireballDestructEnabled{true}; bool m_isRoadSignsTextEnabled{true}; + bool m_isBuildingsRemoved{false}; static unsigned int& ClumpOffset;