Fix potential destruction crashes (#5095)
* Fix potential destruction crashes * Fix destructors accessing destroyted objects * Fix cPlayer not destroying windows (Destroyed never called) * Tentatively fixes #4608, fixes #3236, fixes #3262 - Remove cEntity::Destroyed() and replace with cEntity::OnRemoveFromWorld() * Add missing call to OnRemoveFromWorld
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
|
||||
cBrewingstandEntity::cBrewingstandEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World):
|
||||
Super(a_BlockType, a_BlockMeta, a_Pos, ContentsWidth, ContentsHeight, a_World),
|
||||
m_IsDestroyed(false),
|
||||
m_IsBrewing(false),
|
||||
m_TimeBrewed(0),
|
||||
m_RemainingFuel(0)
|
||||
@@ -25,30 +24,6 @@ cBrewingstandEntity::cBrewingstandEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
|
||||
|
||||
|
||||
|
||||
cBrewingstandEntity::~cBrewingstandEntity()
|
||||
{
|
||||
// Tell window its owner is destroyed
|
||||
cWindow * Window = GetWindow();
|
||||
if (Window != nullptr)
|
||||
{
|
||||
Window->OwnerDestroyed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBrewingstandEntity::Destroy()
|
||||
{
|
||||
m_IsDestroyed = true;
|
||||
Super::Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBrewingstandEntity::CopyFrom(const cBlockEntity & a_Src)
|
||||
{
|
||||
Super::CopyFrom(a_Src);
|
||||
@@ -70,6 +45,20 @@ void cBrewingstandEntity::CopyFrom(const cBlockEntity & a_Src)
|
||||
|
||||
|
||||
|
||||
void cBrewingstandEntity::OnRemoveFromWorld()
|
||||
{
|
||||
const auto Window = GetWindow();
|
||||
if (Window != nullptr)
|
||||
{
|
||||
// Tell window its owner is destroyed:
|
||||
Window->OwnerDestroyed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBrewingstandEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// Nothing needs to be sent
|
||||
@@ -206,11 +195,6 @@ void cBrewingstandEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
|
||||
{
|
||||
Super::OnSlotChanged(a_ItemGrid, a_SlotNum);
|
||||
|
||||
if (m_IsDestroyed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT(a_ItemGrid == &m_Contents);
|
||||
|
||||
// Check for fuel
|
||||
|
||||
Reference in New Issue
Block a user