summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/ChestEntity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-02 14:50:34 +0100
committerGitHub <noreply@github.com>2021-01-02 14:50:34 +0100
commit16aeb84cd35996a6b41f10cbc48a677eeccc911c (patch)
treeae877926559d59a534bbf3c22651e6df7ffe8d71 /src/BlockEntities/ChestEntity.cpp
parentFix version typo in CMakeLists.txt (#5098) (diff)
downloadcuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.gz
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.bz2
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.lz
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.xz
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.zst
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.zip
Diffstat (limited to 'src/BlockEntities/ChestEntity.cpp')
-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();
}
}