From 36be4a89f8bedca7a7b369289562cf71041a3db6 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Sat, 3 Jun 2017 20:17:53 +0100 Subject: Fixed double chests (#3741) Normal and trapped chests next to each other don't open a double chest window. Slot changes in the secondary chest are broadcast. Placing a chest in +x of another updates the original chest's metadata. --- src/BlockEntities/ChestEntity.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/BlockEntities/ChestEntity.h') diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index dfd5ca0d0..96d904248 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -39,7 +39,7 @@ public: virtual void SendTo(cClientHandle & a_Client) override; virtual bool UsedBy(cPlayer * a_Player) override; - /** Search horizontally adjacent blocks for neighbouring chests and links them together. */ + /** Search horizontally adjacent blocks for neighbouring chests of the same type and links them together. */ void ScanNeighbours(); /** Opens a new chest window where this is the primary chest and any neighbour is the secondary. */ @@ -72,9 +72,19 @@ private: ASSERT(a_Grid == &m_Contents); if (m_World != nullptr) { - if (GetWindow() != nullptr) + cWindow * Window = GetWindow(); + if ( + (Window == nullptr) && + (m_Neighbour != nullptr) + ) { - GetWindow()->BroadcastWholeWindow(); + // Neighbour might own the window + Window = m_Neighbour->GetWindow(); + } + + if (Window != nullptr) + { + Window->BroadcastWholeWindow(); } m_World->MarkChunkDirty(GetChunkX(), GetChunkZ()); -- cgit v1.2.3