Skip to content

Commit 7daa694

Browse files
authored
Fix bad destructor for buildings (#3690)
This fixes random crashes/regressions after `engineSetPoolCapacity`
1 parent 48f94d8 commit 7daa694

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Client/game_sa/CBuildingsPoolSA.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ void CBuildingsPoolSA::RemoveBuilding(CBuilding* pBuilding)
101101
// Remove plant
102102
pGame->GetPlantManager()->RemovePlant(pInterface);
103103

104-
RemoveBuildingFromWorld(pInterface);
104+
// Remove shadow
105+
pInterface->RemoveShadows();
106+
107+
// Remove building from world
108+
pGame->GetWorld()->Remove(pInterface, CBuildingPool_Destructor);
109+
110+
// Call virtual destructor
111+
((void*(__thiscall*)(void*, char))pInterface->vtbl->SCALAR_DELETING_DESTRUCTOR)(pInterface, 0);
105112

106113
// Remove col reference
107114
auto modelInfo = pGame->GetModelInfo(pBuilding->GetModelIndex());

0 commit comments

Comments
 (0)