diff --git a/Client/game_sa/CBuildingsPoolSA.cpp b/Client/game_sa/CBuildingsPoolSA.cpp index 1d39cc9b44..50ae14bb3c 100644 --- a/Client/game_sa/CBuildingsPoolSA.cpp +++ b/Client/game_sa/CBuildingsPoolSA.cpp @@ -151,8 +151,8 @@ void CBuildingsPoolSA::RemoveAllBuildings() RemoveBuildingFromWorld(building); - if (building->Placeable.matrix) - ((void(__thiscall*)(void*))0x54F3B0)(building); + if (building->HasMatrix()) + building->RemoveMatrix(); pBuildsingsPool->Release(i); diff --git a/Client/game_sa/CEntitySA.h b/Client/game_sa/CEntitySA.h index 548cb657f6..b6f76563ca 100644 --- a/Client/game_sa/CEntitySA.h +++ b/Client/game_sa/CEntitySA.h @@ -242,6 +242,10 @@ class CEntitySAInterface using vtbl_DeleteRwObject = void(__thiscall*)(CEntitySAInterface * pEntity); ((vtbl_DeleteRwObject)this->vtbl->DeleteRwObject)(this); }; + + bool HasMatrix() const noexcept { return Placeable.matrix != nullptr; }; + + void RemoveMatrix() { ((void(__thiscall*)(void*))0x54F3B0)(this); } }; static_assert(sizeof(CEntitySAInterface) == 0x38, "Invalid size for CEntitySAInterface");