summaryrefslogtreecommitdiffstats
path: root/src/Simulator/DelayedFluidSimulator.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-29 02:18:59 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-08-02 16:52:06 +0200
commit225c2fa9f6bc2ebffcc9160090482e6833a220ce (patch)
treeb72a5b27b49e38fe160da580a6f659a1a9d93308 /src/Simulator/DelayedFluidSimulator.cpp
parentAdd WakeUp/AddBlock distinction (diff)
downloadcuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.gz
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.bz2
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.lz
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.xz
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.zst
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.zip
Diffstat (limited to '')
-rw-r--r--src/Simulator/DelayedFluidSimulator.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp
index af9007548..b27e34e5f 100644
--- a/src/Simulator/DelayedFluidSimulator.cpp
+++ b/src/Simulator/DelayedFluidSimulator.cpp
@@ -78,27 +78,15 @@ cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Flu
-void cDelayedFluidSimulator::AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
+void cDelayedFluidSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
{
- int RelX = a_Block.x - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_Block.z - a_Chunk->GetPosZ() * cChunkDef::Width;
- BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_Block.y, RelZ);
- if (BlockType != m_FluidBlock)
- {
- return;
- }
-
- auto ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
- cDelayedFluidSimulatorChunkData * ChunkData = static_cast<cDelayedFluidSimulatorChunkData *>(ChunkDataRaw);
- cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
-
- // Add, if not already present:
- if (!Slot.Add(RelX, a_Block.y, RelZ))
+ if (!cChunkDef::IsValidHeight(a_Position.y))
{
+ // Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
return;
}
- ++m_TotalBlocks;
+ Super::WakeUp(a_Chunk, a_Position, a_Block);
}
@@ -146,13 +134,22 @@ void cDelayedFluidSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a
-void cDelayedFluidSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
+void cDelayedFluidSimulator::AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
{
- if (!cChunkDef::IsValidHeight(a_Position.y))
+ if (a_Block != m_FluidBlock)
{
- // Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
return;
}
- Super::WakeUp(a_Chunk, a_Position, a_Block);
+ auto ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk.GetWaterSimulatorData() : a_Chunk.GetLavaSimulatorData();
+ cDelayedFluidSimulatorChunkData * ChunkData = static_cast<cDelayedFluidSimulatorChunkData *>(ChunkDataRaw);
+ cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
+
+ // Add, if not already present:
+ if (!Slot.Add(a_Position.x, a_Position.y, a_Position.z))
+ {
+ return;
+ }
+
+ ++m_TotalBlocks;
}