diff options
Diffstat (limited to '')
-rw-r--r-- | src/Chunk.cpp | 59 | ||||
-rw-r--r-- | src/Chunk.h | 19 | ||||
-rw-r--r-- | src/ChunkMap.cpp | 17 | ||||
-rw-r--r-- | src/ChunkMap.h | 3 |
4 files changed, 17 insertions, 81 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 1c06ed3b3..e4a4dd661 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1159,23 +1159,6 @@ bool cChunk::UnboundedRelFastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, -void cChunk::UnboundedQueueTickBlock(Vector3i a_RelPos) -{ - if (!cChunkDef::IsValidHeight(a_RelPos.y)) - { - return; - } - auto chunk = GetRelNeighborChunkAdjustCoords(a_RelPos); - if ((chunk != nullptr) && chunk->IsValid()) - { - chunk->QueueTickBlock(a_RelPos); - } -} - - - - - int cChunk::GetHeight(int a_X, int a_Z) { ASSERT((a_X >= 0) && (a_X < Width) && (a_Z >= 0) && (a_Z < Width)); @@ -1283,10 +1266,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: - m_ToTickBlocks.push_back(a_RelPos); QueueTickBlockNeighbors(a_RelPos); - // TODO: use relative coordinates, cChunk reference // Wake up the simulators for this block: GetWorld()->GetSimulatorManager()->WakeUp(*this, a_RelPos); @@ -1332,38 +1313,26 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo -void cChunk::QueueTickBlock(Vector3i a_RelPos) +void cChunk::QueueTickBlockNeighbors(Vector3i a_Position) { - ASSERT(IsValidRelPos(a_RelPos)); + m_ToTickBlocks.push(a_Position); - if (!IsValid()) + for (const auto & Offset : cSimulator::AdjacentOffsets) { - return; - } - - m_ToTickBlocks.push_back(a_RelPos); -} - - - + auto Relative = a_Position + Offset; + if (!cChunkDef::IsValidHeight(Relative.y)) + { + continue; + } -void cChunk::QueueTickBlockNeighbors(Vector3i a_RelPos) -{ - // Contains our direct adjacents - static const Vector3i Offsets[] = - { - { 1, 0, 0 }, - { -1, 0, 0 }, - { 0, 1, 0 }, - { 0, -1, 0 }, - { 0, 0, 1 }, - { 0, 0, -1 }, - }; + auto Chunk = GetRelNeighborChunkAdjustCoords(Relative); + if ((Chunk == nullptr) || !Chunk->IsValid()) + { + continue; + } - for (const auto & Offset : Offsets) - { - UnboundedQueueTickBlock(a_RelPos + Offset); + Chunk->m_ToTickBlocks.push(Relative); } } diff --git a/src/Chunk.h b/src/Chunk.h index 884682962..0965f1997 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -158,18 +158,9 @@ public: void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense - /** Queues block for ticking (m_ToTickQueue) */ - void QueueTickBlock(Vector3i a_RelPos); - - /** OBSOLETE, use the Vector3i-based overload instead. - Queues block for ticking (m_ToTickQueue) */ - void QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ) - { - return QueueTickBlock({a_RelX, a_RelY, a_RelZ}); - } - - /** Queues all 6 neighbors of the specified block for ticking (m_ToTickQueue). If any are outside the chunk, relays the checking to the proper neighboring chunk */ - void QueueTickBlockNeighbors(Vector3i a_RelPos); + /** Queues the position itself, and all 6 neighbors of the specified position for ticking (m_ToTickQueue). + If any are outside the chunk, relays the checking to the proper neighboring chunk. */ + void QueueTickBlockNeighbors(Vector3i a_Position); void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc. void FastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true) @@ -525,10 +516,6 @@ public: return UnboundedRelFastSetBlock({a_RelX, a_RelY, a_RelZ}, a_BlockType, a_BlockMeta); } - /** Same as QueueTickBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s in such a case) - Ignores unsuccessful attempts */ - void UnboundedQueueTickBlock(Vector3i a_RelPos); - // Per-chunk simulator data: diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 6b1ece612..9b5106f36 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2191,23 +2191,6 @@ void cChunkMap::ChunkValidated(void) -void cChunkMap::QueueTickBlock(Vector3i a_AbsPos) -{ - auto chunkCoords = cChunkDef::BlockToChunk(a_AbsPos); - auto relPos = cChunkDef::AbsoluteToRelative(a_AbsPos, chunkCoords); - - cCSLock Lock(m_CSChunks); - cChunkPtr Chunk = GetChunkNoLoad(chunkCoords); - if (Chunk != nullptr) - { - Chunk->QueueTickBlock(relPos); - } -} - - - - - void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked) { cCSLock Lock(m_CSChunks); diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 7096e3d70..685651728 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -401,9 +401,6 @@ public: void ChunkValidated(void); // Called by chunks that have become valid - /** Queues the specified block for ticking (block update) */ - void QueueTickBlock(Vector3i a_AbsPos); - /** Returns the CS for locking the chunkmap; only cWorld::cLock may use this function! */ cCriticalSection & GetCS(void) { return m_CSChunks; } |