summaryrefslogtreecommitdiffstats
path: root/src/Chunk.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-29 19:51:07 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-08-02 16:52:06 +0200
commit71ffa76847f2c685958cafb01b0d3a684648f189 (patch)
tree918a5367f7c5273cf01f1d090ebcb610bf4833fc /src/Chunk.cpp
parentAlways use relative coordinates in AddBlock (diff)
downloadcuberite-71ffa76847f2c685958cafb01b0d3a684648f189.tar
cuberite-71ffa76847f2c685958cafb01b0d3a684648f189.tar.gz
cuberite-71ffa76847f2c685958cafb01b0d3a684648f189.tar.bz2
cuberite-71ffa76847f2c685958cafb01b0d3a684648f189.tar.lz
cuberite-71ffa76847f2c685958cafb01b0d3a684648f189.tar.xz
cuberite-71ffa76847f2c685958cafb01b0d3a684648f189.tar.zst
cuberite-71ffa76847f2c685958cafb01b0d3a684648f189.zip
Diffstat (limited to '')
-rw-r--r--src/Chunk.cpp59
1 files changed, 14 insertions, 45 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);
}
}