From d89a7c2e3b8b4a675f222b50788a13d9b0817c0a Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Sun, 1 Sep 2024 18:00:07 +0300 Subject: [PATCH] Fix wrong destructor for buildings --- Client/game_sa/CBuildingsPoolSA.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Client/game_sa/CBuildingsPoolSA.cpp b/Client/game_sa/CBuildingsPoolSA.cpp index b8363f6507f..caa392c132e 100644 --- a/Client/game_sa/CBuildingsPoolSA.cpp +++ b/Client/game_sa/CBuildingsPoolSA.cpp @@ -101,7 +101,14 @@ void CBuildingsPoolSA::RemoveBuilding(CBuilding* pBuilding) // Remove plant pGame->GetPlantManager()->RemovePlant(pInterface); - RemoveBuildingFromWorld(pInterface); + // Remove shadow + pInterface->RemoveShadows(); + + // Remove building from world + pGame->GetWorld()->Remove(pInterface, CBuildingPool_Destructor); + + // Call virtual destructor + ((void*(__thiscall*)(void*, char))pInterface->vtbl->SCALAR_DELETING_DESTRUCTOR)(pInterface, 0); // Remove col reference auto modelInfo = pGame->GetModelInfo(pBuilding->GetModelIndex());