From 66a164a9a75a2d48763520aab3aeb8eeda85c92d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 1 Jul 2015 10:40:16 +0200 Subject: Added neighbor specification in the OnNeighborChanged() block callback. Fixes the OnNeighborChanged endless recursion with large melon / pumpkin fields. Fixes #2213. --- src/Blocks/BlockFarmland.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Blocks/BlockFarmland.h') diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 23a7392da..8d43632ff 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -65,13 +65,22 @@ public: } } - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override + + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_WhichNeighbor) override { + // Don't care about any neighbor but the one above us (fix recursion loop in #2213): + if (a_WhichNeighbor != BLOCK_FACE_YP) + { + return; + } + + // Don't care about anything if we're at the top of the world: if (a_BlockY >= cChunkDef::Height) { return; } + // Check whether we should revert to dirt: BLOCKTYPE UpperBlock = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ); if (cBlockInfo::FullyOccupiesVoxel(UpperBlock)) { @@ -79,11 +88,13 @@ public: } } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta } + bool IsWaterInNear(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) { if (a_Chunk.GetWorld()->IsWeatherWetAt(a_RelX, a_RelZ)) -- cgit v1.2.3