From 6bdd130aab51b630918ed664c4389cf33bcb2e06 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 29 Jul 2020 19:30:38 +0100 Subject: OnBroken/OnPlaced are for entity actions * Call OnPlaced/OnBroken in PlaceBlock/DigBlock - Remove unused Placing/Breaking handlers * Have the blockhandler's Check handle neighbour updating, instead of QueueTickBlockNeighbors --- src/Chunk.cpp | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 2140bf7f1..21261e828 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -820,7 +820,7 @@ void cChunk::CheckBlocks() while (Count != 0) { - Vector3i Pos = m_ToTickBlocks.front(); + const auto Pos = m_ToTickBlocks.front(); m_ToTickBlocks.pop(); Count--; @@ -1263,8 +1263,8 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo { FastSetBlock(a_RelPos, a_BlockType, a_BlockMeta); - // Tick this block and its neighbors: - QueueTickBlockNeighbors(a_RelPos); + // Tick this block's neighbors via cBlockHandler::Check: + m_ToTickBlocks.push(a_RelPos); // Wake up the simulators for this block: GetWorld()->GetSimulatorManager()->WakeUp(*this, a_RelPos); @@ -1311,33 +1311,6 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo -void cChunk::QueueTickBlockNeighbors(Vector3i a_Position) -{ - m_ToTickBlocks.push(a_Position); - - for (const auto & Offset : cSimulator::AdjacentOffsets) - { - auto Relative = a_Position + Offset; - - if (!cChunkDef::IsValidHeight(Relative.y)) - { - continue; - } - - auto Chunk = GetRelNeighborChunkAdjustCoords(Relative); - if ((Chunk == nullptr) || !Chunk->IsValid()) - { - continue; - } - - Chunk->m_ToTickBlocks.push(Relative); - } -} - - - - - void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients) { ASSERT(!((a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width))); -- cgit v1.2.3