diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-29 02:18:59 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-02 16:52:06 +0200 |
commit | 225c2fa9f6bc2ebffcc9160090482e6833a220ce (patch) | |
tree | b72a5b27b49e38fe160da580a6f659a1a9d93308 /src/Simulator/DelayedFluidSimulator.cpp | |
parent | Add WakeUp/AddBlock distinction (diff) | |
download | cuberite-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 'src/Simulator/DelayedFluidSimulator.cpp')
-rw-r--r-- | src/Simulator/DelayedFluidSimulator.cpp | 37 |
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; } |