summaryrefslogtreecommitdiffstats
path: root/src/Simulator/Simulator.cpp
diff options
context:
space:
mode:
authorLane Kolbly <lane@rscheme.org>2017-08-17 15:48:38 +0200
committerMattes D <github@xoft.cz>2017-08-17 15:48:38 +0200
commit7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9 (patch)
tree59128a57d87d7826de450a71e060bd869e837a4a /src/Simulator/Simulator.cpp
parentUpdated docs to mention InfoDump for creating README.md, etc. (#3895) (diff)
downloadcuberite-7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9.tar
cuberite-7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9.tar.gz
cuberite-7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9.tar.bz2
cuberite-7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9.tar.lz
cuberite-7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9.tar.xz
cuberite-7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9.tar.zst
cuberite-7bdbfad1bbabb84e650261ad31d2d9b47f8b12a9.zip
Diffstat (limited to '')
-rw-r--r--src/Simulator/Simulator.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/Simulator/Simulator.cpp b/src/Simulator/Simulator.cpp
index 7d3ce7851..9dbdd6a07 100644
--- a/src/Simulator/Simulator.cpp
+++ b/src/Simulator/Simulator.cpp
@@ -18,20 +18,20 @@
-void cSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
+void cSimulator::WakeUp(Vector3i a_Block, cChunk * a_Chunk)
{
- AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
- AddBlock(a_BlockX - 1, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 1, a_BlockZ));
- AddBlock(a_BlockX + 1, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 1, a_BlockZ));
- AddBlock(a_BlockX, a_BlockY, a_BlockZ - 1, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 1));
- AddBlock(a_BlockX, a_BlockY, a_BlockZ + 1, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ + 1));
- if (a_BlockY > 0)
+ AddBlock(a_Block, a_Chunk);
+ AddBlock(a_Block + Vector3i(-1, 0, 0), a_Chunk->GetNeighborChunk(a_Block.x - 1, a_Block.z));
+ AddBlock(a_Block + Vector3i( 1, 0, 0), a_Chunk->GetNeighborChunk(a_Block.x + 1, a_Block.z));
+ AddBlock(a_Block + Vector3i(0, 0, -1), a_Chunk->GetNeighborChunk(a_Block.x, a_Block.z - 1));
+ AddBlock(a_Block + Vector3i(0, 0, 1), a_Chunk->GetNeighborChunk(a_Block.x, a_Block.z + 1));
+ if (a_Block.y > 0)
{
- AddBlock(a_BlockX, a_BlockY - 1, a_BlockZ, a_Chunk);
+ AddBlock(a_Block + Vector3i(0, -1, 0), a_Chunk);
}
- if (a_BlockY < cChunkDef::Height - 1)
+ if (a_Block.y < cChunkDef::Height - 1)
{
- AddBlock(a_BlockX, a_BlockY + 1, a_BlockZ, a_Chunk);
+ AddBlock(a_Block + Vector3i(0, 1, 0), a_Chunk);
}
}
@@ -47,12 +47,11 @@ void cSimulator::WakeUpArea(const cCuboid & a_Area)
area.ClampY(0, cChunkDef::Height - 1);
// Add all blocks, in a per-chunk manner:
- int chunkStartX, chunkStartZ, chunkEndX, chunkEndZ;
- cChunkDef::BlockToChunk(area.p1.x, area.p1.z, chunkStartX, chunkStartZ);
- cChunkDef::BlockToChunk(area.p2.x, area.p2.z, chunkEndX, chunkEndZ);
- for (int cz = chunkStartZ; cz <= chunkEndZ; ++cz)
+ cChunkCoords ChunkStart = cChunkDef::BlockToChunk(area.p1);
+ cChunkCoords ChunkEnd = cChunkDef::BlockToChunk(area.p2);
+ for (int cz = ChunkStart.m_ChunkZ; cz <= ChunkEnd.m_ChunkZ; ++cz)
{
- for (int cx = chunkStartX; cx <= chunkEndX; ++cx)
+ for (int cx = ChunkStart.m_ChunkX; cx <= ChunkEnd.m_ChunkX; ++cx)
{
m_World.DoWithChunk(cx, cz, [this, &area](cChunk & a_CBChunk) -> bool
{
@@ -73,7 +72,7 @@ void cSimulator::WakeUpArea(const cCuboid & a_Area)
{
for (int x = startX; x <= endX; ++x)
{
- AddBlock(x, y, z, &a_CBChunk);
+ AddBlock({x, y, z}, &a_CBChunk);
} // for x
} // for z
} // for y