summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/ChestEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/ChestEntity.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index 8c8e75b25..e225cf96e 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -32,31 +32,31 @@ cChestEntity::cChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector
-cChestEntity::~cChestEntity()
+void cChestEntity::CopyFrom(const cBlockEntity & a_Src)
{
- if (m_Neighbour != nullptr)
- {
- // Neighbour may share a window with us, force the window shut
- m_Neighbour->DestroyWindow();
- m_Neighbour->m_Neighbour = nullptr;
- }
+ Super::CopyFrom(a_Src);
+ auto & src = static_cast<const cChestEntity &>(a_Src);
+ m_Contents.CopyFrom(src.m_Contents);
- DestroyWindow();
+ // Reset the neighbor and player count, there's no sense in copying these:
+ m_Neighbour = nullptr;
+ m_NumActivePlayers = 0;
}
-void cChestEntity::CopyFrom(const cBlockEntity & a_Src)
+void cChestEntity::OnRemoveFromWorld()
{
- Super::CopyFrom(a_Src);
- auto & src = static_cast<const cChestEntity &>(a_Src);
- m_Contents.CopyFrom(src.m_Contents);
+ if (m_Neighbour != nullptr)
+ {
+ // Neighbour may share a window with us, force the window shut:
+ m_Neighbour->DestroyWindow();
+ m_Neighbour->m_Neighbour = nullptr;
+ }
- // Reset the neighbor and player count, there's no sense in copying these:
- m_Neighbour = nullptr;
- m_NumActivePlayers = 0;
+ DestroyWindow();
}
@@ -199,11 +199,10 @@ void cChestEntity::OpenNewWindow(void)
void cChestEntity::DestroyWindow()
{
- cWindow * Window = GetWindow();
+ const auto Window = GetWindow();
if (Window != nullptr)
{
Window->OwnerDestroyed();
- CloseWindow();
}
}