summaryrefslogtreecommitdiffstats
path: root/source/Simulator
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Simulator/DelayedFluidSimulator.cpp316
-rw-r--r--source/Simulator/DelayedFluidSimulator.h164
-rw-r--r--source/Simulator/FloodyFluidSimulator.cpp668
-rw-r--r--source/Simulator/FloodyFluidSimulator.h106
-rw-r--r--source/Simulator/NoopFluidSimulator.h72
-rw-r--r--source/Simulator/VaporizeFluidSimulator.cpp106
-rw-r--r--source/Simulator/VaporizeFluidSimulator.h68
7 files changed, 750 insertions, 750 deletions
diff --git a/source/Simulator/DelayedFluidSimulator.cpp b/source/Simulator/DelayedFluidSimulator.cpp
index 6cc982e3d..a4645ca09 100644
--- a/source/Simulator/DelayedFluidSimulator.cpp
+++ b/source/Simulator/DelayedFluidSimulator.cpp
@@ -1,158 +1,158 @@
-
-// DelayedFluidSimulator.cpp
-
-// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
-// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
-
-#include "Globals.h"
-
-#include "DelayedFluidSimulator.h"
-#include "../World.h"
-#include "../Chunk.h"
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cDelayedFluidSimulatorChunkData::cSlot
-
-bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
-{
- ASSERT(a_RelZ >= 0);
- ASSERT(a_RelZ < ARRAYCOUNT(m_Blocks));
-
- cCoordWithIntVector & Blocks = m_Blocks[a_RelZ];
- int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
- for (cCoordWithIntVector::const_iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
- {
- if (itr->Data == Index)
- {
- // Already present
- return false;
- }
- } // for itr - Blocks[]
- Blocks.push_back(cCoordWithInt(a_RelX, a_RelY, a_RelZ, Index));
- return true;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cDelayedFluidSimulatorChunkData:
-
-cDelayedFluidSimulatorChunkData::cDelayedFluidSimulatorChunkData(int a_TickDelay) :
- m_Slots(new cSlot[a_TickDelay])
-{
-}
-
-
-
-
-
-cDelayedFluidSimulatorChunkData::~cDelayedFluidSimulatorChunkData()
-{
- delete[] m_Slots;
- m_Slots = NULL;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cDelayedFluidSimulator:
-
-cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay) :
- super(a_World, a_Fluid, a_StationaryFluid),
- m_TickDelay(a_TickDelay),
- m_AddSlotNum(a_TickDelay - 1),
- m_SimSlotNum(0),
- m_TotalBlocks(0)
-{
-}
-
-
-
-
-
-void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
-{
- if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
- {
- // Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
- return;
- }
-
- if ((a_Chunk == NULL) || !a_Chunk->IsValid())
- {
- return;
- }
-
- int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
- BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
- if (BlockType != m_FluidBlock)
- {
- return;
- }
-
- void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
- cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
- cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
-
- // Add, if not already present:
- if (!Slot.Add(RelX, a_BlockY, RelZ))
- {
- return;
- }
-
- ++m_TotalBlocks;
-}
-
-
-
-
-
-void cDelayedFluidSimulator::Simulate(float a_Dt)
-{
- m_AddSlotNum = m_SimSlotNum;
- m_SimSlotNum += 1;
- if (m_SimSlotNum >= m_TickDelay)
- {
- m_SimSlotNum = 0;
- }
-}
-
-
-
-
-
-void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
-{
- void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
- cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
- cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum];
-
- // Simulate all the blocks in the scheduled slot:
- for (int i = 0; i < ARRAYCOUNT(Slot.m_Blocks); i++)
- {
- cCoordWithIntVector & Blocks = Slot.m_Blocks[i];
- if (Blocks.empty())
- {
- continue;
- }
- for (cCoordWithIntVector::iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
- {
- SimulateBlock(a_Chunk, itr->x, itr->y, itr->z);
- }
- m_TotalBlocks -= Blocks.size();
- Blocks.clear();
- }
-}
-
-
-
-
+
+// DelayedFluidSimulator.cpp
+
+// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
+// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
+
+#include "Globals.h"
+
+#include "DelayedFluidSimulator.h"
+#include "../World.h"
+#include "../Chunk.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cDelayedFluidSimulatorChunkData::cSlot
+
+bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
+{
+ ASSERT(a_RelZ >= 0);
+ ASSERT(a_RelZ < ARRAYCOUNT(m_Blocks));
+
+ cCoordWithIntVector & Blocks = m_Blocks[a_RelZ];
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
+ for (cCoordWithIntVector::const_iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
+ {
+ if (itr->Data == Index)
+ {
+ // Already present
+ return false;
+ }
+ } // for itr - Blocks[]
+ Blocks.push_back(cCoordWithInt(a_RelX, a_RelY, a_RelZ, Index));
+ return true;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cDelayedFluidSimulatorChunkData:
+
+cDelayedFluidSimulatorChunkData::cDelayedFluidSimulatorChunkData(int a_TickDelay) :
+ m_Slots(new cSlot[a_TickDelay])
+{
+}
+
+
+
+
+
+cDelayedFluidSimulatorChunkData::~cDelayedFluidSimulatorChunkData()
+{
+ delete[] m_Slots;
+ m_Slots = NULL;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cDelayedFluidSimulator:
+
+cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay) :
+ super(a_World, a_Fluid, a_StationaryFluid),
+ m_TickDelay(a_TickDelay),
+ m_AddSlotNum(a_TickDelay - 1),
+ m_SimSlotNum(0),
+ m_TotalBlocks(0)
+{
+}
+
+
+
+
+
+void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
+{
+ if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
+ {
+ // Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
+ return;
+ }
+
+ if ((a_Chunk == NULL) || !a_Chunk->IsValid())
+ {
+ return;
+ }
+
+ int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
+ BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
+ if (BlockType != m_FluidBlock)
+ {
+ return;
+ }
+
+ void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
+ cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
+ cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
+
+ // Add, if not already present:
+ if (!Slot.Add(RelX, a_BlockY, RelZ))
+ {
+ return;
+ }
+
+ ++m_TotalBlocks;
+}
+
+
+
+
+
+void cDelayedFluidSimulator::Simulate(float a_Dt)
+{
+ m_AddSlotNum = m_SimSlotNum;
+ m_SimSlotNum += 1;
+ if (m_SimSlotNum >= m_TickDelay)
+ {
+ m_SimSlotNum = 0;
+ }
+}
+
+
+
+
+
+void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
+{
+ void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
+ cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
+ cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum];
+
+ // Simulate all the blocks in the scheduled slot:
+ for (int i = 0; i < ARRAYCOUNT(Slot.m_Blocks); i++)
+ {
+ cCoordWithIntVector & Blocks = Slot.m_Blocks[i];
+ if (Blocks.empty())
+ {
+ continue;
+ }
+ for (cCoordWithIntVector::iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
+ {
+ SimulateBlock(a_Chunk, itr->x, itr->y, itr->z);
+ }
+ m_TotalBlocks -= Blocks.size();
+ Blocks.clear();
+ }
+}
+
+
+
+
diff --git a/source/Simulator/DelayedFluidSimulator.h b/source/Simulator/DelayedFluidSimulator.h
index 6f7433877..c81500741 100644
--- a/source/Simulator/DelayedFluidSimulator.h
+++ b/source/Simulator/DelayedFluidSimulator.h
@@ -1,82 +1,82 @@
-
-// DelayedFluidSimulator.h
-
-// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
-// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
-
-
-
-
-#pragma once
-
-#include "FluidSimulator.h"
-
-
-
-
-
-class cDelayedFluidSimulatorChunkData :
- public cFluidSimulatorData
-{
-public:
- class cSlot
- {
- public:
- /// Returns true if the specified block is stored
- bool HasBlock(int a_RelX, int a_RelY, int a_RelZ);
-
- /// Adds the specified block unless already present; returns true if added, false if the block was already present
- bool Add(int a_RelX, int a_RelY, int a_RelZ);
-
- /** Array of block containers, each item stores blocks for one Z coord
- Int param is the block index (for faster duplicate comparison in Add())
- */
- cCoordWithIntVector m_Blocks[16];
- } ;
-
- cDelayedFluidSimulatorChunkData(int a_TickDelay);
- virtual ~cDelayedFluidSimulatorChunkData();
-
- /// Slots, one for each delay tick, each containing the blocks to simulate
- cSlot * m_Slots;
-} ;
-
-
-
-
-
-class cDelayedFluidSimulator :
- public cFluidSimulator
-{
- typedef cFluidSimulator super;
-
-public:
- cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay);
-
- // cSimulator overrides:
- virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
- virtual void Simulate(float a_Dt) override;
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
- virtual cFluidSimulatorData * CreateChunkData(void) override { return new cDelayedFluidSimulatorChunkData(m_TickDelay); }
-
-protected:
-
- int m_TickDelay; // Count of the m_Slots array in each ChunkData
- int m_AddSlotNum; // Index into m_Slots[] where to add new blocks in each ChunkData
- int m_SimSlotNum; // Index into m_Slots[] where to simulate blocks in each ChunkData
-
- int m_TotalBlocks; // Statistics only: the total number of blocks currently queued
-
- /*
- Slots:
- | 0 | 1 | ... | m_AddSlotNum | m_SimSlotNum | ... | m_TickDelay - 1 |
- adding blocks here ^ | ^ simulating here
- */
-
- /// Called from SimulateChunk() to simulate each block in one slot of blocks. Descendants override this method to provide custom simulation.
- virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) = 0;
-} ;
-
-
-
-
+
+// DelayedFluidSimulator.h
+
+// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
+// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
+
+
+
+
+#pragma once
+
+#include "FluidSimulator.h"
+
+
+
+
+
+class cDelayedFluidSimulatorChunkData :
+ public cFluidSimulatorData
+{
+public:
+ class cSlot
+ {
+ public:
+ /// Returns true if the specified block is stored
+ bool HasBlock(int a_RelX, int a_RelY, int a_RelZ);
+
+ /// Adds the specified block unless already present; returns true if added, false if the block was already present
+ bool Add(int a_RelX, int a_RelY, int a_RelZ);
+
+ /** Array of block containers, each item stores blocks for one Z coord
+ Int param is the block index (for faster duplicate comparison in Add())
+ */
+ cCoordWithIntVector m_Blocks[16];
+ } ;
+
+ cDelayedFluidSimulatorChunkData(int a_TickDelay);
+ virtual ~cDelayedFluidSimulatorChunkData();
+
+ /// Slots, one for each delay tick, each containing the blocks to simulate
+ cSlot * m_Slots;
+} ;
+
+
+
+
+
+class cDelayedFluidSimulator :
+ public cFluidSimulator
+{
+ typedef cFluidSimulator super;
+
+public:
+ cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay);
+
+ // cSimulator overrides:
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
+ virtual void Simulate(float a_Dt) override;
+ virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
+ virtual cFluidSimulatorData * CreateChunkData(void) override { return new cDelayedFluidSimulatorChunkData(m_TickDelay); }
+
+protected:
+
+ int m_TickDelay; // Count of the m_Slots array in each ChunkData
+ int m_AddSlotNum; // Index into m_Slots[] where to add new blocks in each ChunkData
+ int m_SimSlotNum; // Index into m_Slots[] where to simulate blocks in each ChunkData
+
+ int m_TotalBlocks; // Statistics only: the total number of blocks currently queued
+
+ /*
+ Slots:
+ | 0 | 1 | ... | m_AddSlotNum | m_SimSlotNum | ... | m_TickDelay - 1 |
+ adding blocks here ^ | ^ simulating here
+ */
+
+ /// Called from SimulateChunk() to simulate each block in one slot of blocks. Descendants override this method to provide custom simulation.
+ virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) = 0;
+} ;
+
+
+
+
diff --git a/source/Simulator/FloodyFluidSimulator.cpp b/source/Simulator/FloodyFluidSimulator.cpp
index f2cc068e8..9374bbab3 100644
--- a/source/Simulator/FloodyFluidSimulator.cpp
+++ b/source/Simulator/FloodyFluidSimulator.cpp
@@ -1,334 +1,334 @@
-
-// FloodyFluidSimulator.cpp
-
-// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
-// http://forum.mc-server.org/showthread.php?tid=565
-
-#include "Globals.h"
-
-#include "FloodyFluidSimulator.h"
-#include "../World.h"
-#include "../Chunk.h"
-#include "../BlockArea.h"
-#include "../Blocks/BlockHandler.h"
-
-
-
-
-
-// Enable or disable detailed logging
-#if 0
- #define FLOG LOGD
-#else
- #define FLOG(...)
-#endif
-
-
-
-
-
-cFloodyFluidSimulator::cFloodyFluidSimulator(
- cWorld & a_World,
- BLOCKTYPE a_Fluid,
- BLOCKTYPE a_StationaryFluid,
- NIBBLETYPE a_Falloff,
- int a_TickDelay,
- int a_NumNeighborsForSource
-) :
- super(a_World, a_Fluid, a_StationaryFluid, a_TickDelay),
- m_Falloff(a_Falloff),
- m_NumNeighborsForSource(a_NumNeighborsForSource)
-{
-}
-
-
-
-
-
-void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
-{
- FLOG("Simulating block {%d, %d, %d}: block %d, meta %d",
- a_Chunk->GetPosX() * cChunkDef::Width + a_RelX, a_RelY, a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ,
- a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ),
- a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ)
- );
-
- NIBBLETYPE MyMeta = a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ);
- if (!IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ)))
- {
- // Can happen - if a block is scheduled for simulating and gets replaced in the meantime.
- FLOG(" BadBlockType exit");
- return;
- }
-
- if (MyMeta != 0)
- {
- // Source blocks aren't checked for tributaries, others are.
- if (CheckTributaries(a_Chunk, a_RelX, a_RelY, a_RelZ, MyMeta))
- {
- // Has no tributary, has been decreased (in CheckTributaries()),
- // no more processing needed (neighbors have been scheduled by the decrease)
- FLOG(" CheckTributaries exit");
- return;
- }
- }
-
- // New meta for the spreading to neighbors:
- // If this is a source block or was falling, the new meta is just the falloff
- // Otherwise it is the current meta plus falloff (may be larger than max height, will be checked later)
- NIBBLETYPE NewMeta = ((MyMeta == 0) || ((MyMeta & 0x08) != 0)) ? m_Falloff : (MyMeta + m_Falloff);
- bool SpreadFurther = true;
- if (a_RelY > 0)
- {
- BLOCKTYPE Below = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ);
- if (IsPassableForFluid(Below) || IsBlockLava(Below) || IsBlockWater(Below))
- {
- // Spread only down, possibly washing away what's there or turning lava to stone / cobble / obsidian:
- SpreadToNeighbor(a_Chunk, a_RelX, a_RelY - 1, a_RelZ, 8);
- SpreadFurther = false;
- }
- // If source creation is on, check for it here:
- else if (
- (m_NumNeighborsForSource > 0) && // Source creation is on
- (MyMeta == m_Falloff) && // Only exactly one block away from a source (fast bail-out)
- !IsPassableForFluid(Below) && // Only exactly 1 block deep
- CheckNeighborsForSource(a_Chunk, a_RelX, a_RelY, a_RelZ) // Did we create a source?
- )
- {
- // We created a source, no more spreading is to be done now
- // Also has been re-scheduled for ticking in the next wave, so no marking is needed
- return;
- }
- }
-
- if (SpreadFurther && (NewMeta < 8))
- {
- // Spread to the neighbors:
- SpreadToNeighbor(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, NewMeta);
- SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, NewMeta);
- SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ - 1, NewMeta);
- SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ + 1, NewMeta);
- }
-
- // Mark as processed:
- a_Chunk->FastSetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, MyMeta);
-}
-
-
-
-
-
-bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta)
-{
- // If we have a section above, check if there's fluid above this block that would feed it:
- if (a_RelY < cChunkDef::Height - 1)
- {
- if (IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY + 1, a_RelZ)))
- {
- // This block is fed from above, no more processing needed
- FLOG(" Fed from above");
- return false;
- }
- }
-
- // Not fed from above, check if there's a feed from the side (but not if it's a downward-flowing block):
- if (a_MyMeta != 8)
- {
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- static const Vector3i Coords[] =
- {
- Vector3i( 1, 0, 0),
- Vector3i(-1, 0, 0),
- Vector3i( 0, 0, 1),
- Vector3i( 0, 0, -1),
- } ;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- if (!a_Chunk->UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta))
- {
- continue;
- }
- if (IsAllowedBlock(BlockType) && IsHigherMeta(BlockMeta, a_MyMeta))
- {
- // This block is fed, no more processing needed
- FLOG(" Fed from {%d, %d, %d}, type %d, meta %d",
- a_Chunk->GetPosX() * cChunkDef::Width + a_RelX + Coords[i].x,
- a_RelY,
- a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ + Coords[i].z,
- BlockType, BlockMeta
- );
- return false;
- }
- } // for i - Coords[]
- } // if not fed from above
-
- // Block is not fed, decrease by m_Falloff levels:
- if (a_MyMeta >= 8)
- {
- FLOG(" Not fed and downwards, turning into non-downwards meta %d", m_Falloff);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, m_Falloff);
- }
- else
- {
- a_MyMeta += m_Falloff;
- if (a_MyMeta < 8)
- {
- FLOG(" Not fed, decreasing from %d to %d", a_MyMeta - m_Falloff, a_MyMeta);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, a_MyMeta);
- }
- else
- {
- FLOG(" Not fed, meta %d, erasing altogether", a_MyMeta);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
- }
- }
- return true;
-}
-
-
-
-
-
-void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
-{
- ASSERT(a_NewMeta <= 8); // Invalid meta values
- ASSERT(a_NewMeta > 0); // Source blocks aren't spread
-
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_NearChunk->UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta))
- {
- // Chunk not available
- return;
- }
-
- if (IsAllowedBlock(BlockType))
- {
- if ((BlockMeta == a_NewMeta) || IsHigherMeta(BlockMeta, a_NewMeta))
- {
- // Don't spread there, there's already a higher or same level there
- return;
- }
- }
-
- // Check water - lava interaction:
- if (m_FluidBlock == E_BLOCK_LAVA)
- {
- if (IsBlockWater(BlockType))
- {
- // Lava flowing into water, change to stone / cobblestone based on direction:
- BLOCKTYPE NewBlock = (a_NewMeta == 8) ? E_BLOCK_STONE : E_BLOCK_COBBLESTONE;
- FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone",
- a_RelX, a_RelY, a_RelZ,
- ItemTypeToString(NewBlock).c_str()
- );
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
-
- // TODO: Sound effect
-
- return;
- }
- }
- else if (m_FluidBlock == E_BLOCK_WATER)
- {
- if (IsBlockLava(BlockType))
- {
- // Water flowing into lava, change to cobblestone / obsidian based on dest block:
- BLOCKTYPE NewBlock = (BlockMeta == 0) ? E_BLOCK_OBSIDIAN : E_BLOCK_COBBLESTONE;
- FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s",
- a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
- );
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
-
- // TODO: Sound effect
-
- return;
- }
- }
- else
- {
- ASSERT(!"Unknown fluid!");
- }
-
- if (!IsPassableForFluid(BlockType))
- {
- // Can't spread there
- return;
- }
-
- // Wash away the block there, if possible:
- if (CanWashAway(BlockType))
- {
- cBlockHandler * Handler = BlockHandler(BlockType);
- if (Handler->DoesDropOnUnsuitable())
- {
- Handler->DropBlock(
- &m_World, NULL,
- a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
- a_RelY,
- a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ
- );
- }
- } // if (CanWashAway)
-
- // Spread:
- FLOG(" Spreading to {%d, %d, %d} with meta %d",
- a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
- a_RelY,
- a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ,
- a_NewMeta
- );
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
-}
-
-
-
-
-
-bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
-{
- FLOG(" Checking neighbors for source creation");
-
- static const Vector3i NeighborCoords[] =
- {
- Vector3i(-1, 0, 0),
- Vector3i( 1, 0, 0),
- Vector3i( 0, 0, -1),
- Vector3i( 0, 0, 1),
- } ;
-
- int NumNeeded = m_NumNeighborsForSource;
- for (int i = 0; i < ARRAYCOUNT(NeighborCoords); i++)
- {
- int x = a_RelX + NeighborCoords[i].x;
- int y = a_RelY + NeighborCoords[i].y;
- int z = a_RelZ + NeighborCoords[i].z;
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_Chunk->UnboundedRelGetBlock(x, y, z, BlockType, BlockMeta))
- {
- // Neighbor not available, skip it
- continue;
- }
- // FLOG(" Neighbor at {%d, %d, %d}: %s", x, y, z, ItemToFullString(cItem(BlockType, 1, BlockMeta)).c_str());
- if ((BlockMeta == 0) && IsAnyFluidBlock(BlockType))
- {
- NumNeeded--;
- // FLOG(" Found a neighbor source at {%d, %d, %d}, NumNeeded := %d", x, y, z, NumNeeded);
- if (NumNeeded == 0)
- {
- // Found enough, turn into a source and bail out
- // FLOG(" Found enough neighbor sources, turning into a source");
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, 0);
- return true;
- }
- }
- }
- // FLOG(" Not enough neighbors for turning into a source, NumNeeded = %d", NumNeeded);
- return false;
-}
-
-
-
-
+
+// FloodyFluidSimulator.cpp
+
+// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
+// http://forum.mc-server.org/showthread.php?tid=565
+
+#include "Globals.h"
+
+#include "FloodyFluidSimulator.h"
+#include "../World.h"
+#include "../Chunk.h"
+#include "../BlockArea.h"
+#include "../Blocks/BlockHandler.h"
+
+
+
+
+
+// Enable or disable detailed logging
+#if 0
+ #define FLOG LOGD
+#else
+ #define FLOG(...)
+#endif
+
+
+
+
+
+cFloodyFluidSimulator::cFloodyFluidSimulator(
+ cWorld & a_World,
+ BLOCKTYPE a_Fluid,
+ BLOCKTYPE a_StationaryFluid,
+ NIBBLETYPE a_Falloff,
+ int a_TickDelay,
+ int a_NumNeighborsForSource
+) :
+ super(a_World, a_Fluid, a_StationaryFluid, a_TickDelay),
+ m_Falloff(a_Falloff),
+ m_NumNeighborsForSource(a_NumNeighborsForSource)
+{
+}
+
+
+
+
+
+void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
+{
+ FLOG("Simulating block {%d, %d, %d}: block %d, meta %d",
+ a_Chunk->GetPosX() * cChunkDef::Width + a_RelX, a_RelY, a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ,
+ a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ),
+ a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ)
+ );
+
+ NIBBLETYPE MyMeta = a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ);
+ if (!IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ)))
+ {
+ // Can happen - if a block is scheduled for simulating and gets replaced in the meantime.
+ FLOG(" BadBlockType exit");
+ return;
+ }
+
+ if (MyMeta != 0)
+ {
+ // Source blocks aren't checked for tributaries, others are.
+ if (CheckTributaries(a_Chunk, a_RelX, a_RelY, a_RelZ, MyMeta))
+ {
+ // Has no tributary, has been decreased (in CheckTributaries()),
+ // no more processing needed (neighbors have been scheduled by the decrease)
+ FLOG(" CheckTributaries exit");
+ return;
+ }
+ }
+
+ // New meta for the spreading to neighbors:
+ // If this is a source block or was falling, the new meta is just the falloff
+ // Otherwise it is the current meta plus falloff (may be larger than max height, will be checked later)
+ NIBBLETYPE NewMeta = ((MyMeta == 0) || ((MyMeta & 0x08) != 0)) ? m_Falloff : (MyMeta + m_Falloff);
+ bool SpreadFurther = true;
+ if (a_RelY > 0)
+ {
+ BLOCKTYPE Below = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ);
+ if (IsPassableForFluid(Below) || IsBlockLava(Below) || IsBlockWater(Below))
+ {
+ // Spread only down, possibly washing away what's there or turning lava to stone / cobble / obsidian:
+ SpreadToNeighbor(a_Chunk, a_RelX, a_RelY - 1, a_RelZ, 8);
+ SpreadFurther = false;
+ }
+ // If source creation is on, check for it here:
+ else if (
+ (m_NumNeighborsForSource > 0) && // Source creation is on
+ (MyMeta == m_Falloff) && // Only exactly one block away from a source (fast bail-out)
+ !IsPassableForFluid(Below) && // Only exactly 1 block deep
+ CheckNeighborsForSource(a_Chunk, a_RelX, a_RelY, a_RelZ) // Did we create a source?
+ )
+ {
+ // We created a source, no more spreading is to be done now
+ // Also has been re-scheduled for ticking in the next wave, so no marking is needed
+ return;
+ }
+ }
+
+ if (SpreadFurther && (NewMeta < 8))
+ {
+ // Spread to the neighbors:
+ SpreadToNeighbor(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, NewMeta);
+ SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, NewMeta);
+ SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ - 1, NewMeta);
+ SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ + 1, NewMeta);
+ }
+
+ // Mark as processed:
+ a_Chunk->FastSetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, MyMeta);
+}
+
+
+
+
+
+bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta)
+{
+ // If we have a section above, check if there's fluid above this block that would feed it:
+ if (a_RelY < cChunkDef::Height - 1)
+ {
+ if (IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY + 1, a_RelZ)))
+ {
+ // This block is fed from above, no more processing needed
+ FLOG(" Fed from above");
+ return false;
+ }
+ }
+
+ // Not fed from above, check if there's a feed from the side (but not if it's a downward-flowing block):
+ if (a_MyMeta != 8)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ static const Vector3i Coords[] =
+ {
+ Vector3i( 1, 0, 0),
+ Vector3i(-1, 0, 0),
+ Vector3i( 0, 0, 1),
+ Vector3i( 0, 0, -1),
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ if (!a_Chunk->UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta))
+ {
+ continue;
+ }
+ if (IsAllowedBlock(BlockType) && IsHigherMeta(BlockMeta, a_MyMeta))
+ {
+ // This block is fed, no more processing needed
+ FLOG(" Fed from {%d, %d, %d}, type %d, meta %d",
+ a_Chunk->GetPosX() * cChunkDef::Width + a_RelX + Coords[i].x,
+ a_RelY,
+ a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ + Coords[i].z,
+ BlockType, BlockMeta
+ );
+ return false;
+ }
+ } // for i - Coords[]
+ } // if not fed from above
+
+ // Block is not fed, decrease by m_Falloff levels:
+ if (a_MyMeta >= 8)
+ {
+ FLOG(" Not fed and downwards, turning into non-downwards meta %d", m_Falloff);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, m_Falloff);
+ }
+ else
+ {
+ a_MyMeta += m_Falloff;
+ if (a_MyMeta < 8)
+ {
+ FLOG(" Not fed, decreasing from %d to %d", a_MyMeta - m_Falloff, a_MyMeta);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, a_MyMeta);
+ }
+ else
+ {
+ FLOG(" Not fed, meta %d, erasing altogether", a_MyMeta);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ }
+ }
+ return true;
+}
+
+
+
+
+
+void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
+{
+ ASSERT(a_NewMeta <= 8); // Invalid meta values
+ ASSERT(a_NewMeta > 0); // Source blocks aren't spread
+
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (!a_NearChunk->UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta))
+ {
+ // Chunk not available
+ return;
+ }
+
+ if (IsAllowedBlock(BlockType))
+ {
+ if ((BlockMeta == a_NewMeta) || IsHigherMeta(BlockMeta, a_NewMeta))
+ {
+ // Don't spread there, there's already a higher or same level there
+ return;
+ }
+ }
+
+ // Check water - lava interaction:
+ if (m_FluidBlock == E_BLOCK_LAVA)
+ {
+ if (IsBlockWater(BlockType))
+ {
+ // Lava flowing into water, change to stone / cobblestone based on direction:
+ BLOCKTYPE NewBlock = (a_NewMeta == 8) ? E_BLOCK_STONE : E_BLOCK_COBBLESTONE;
+ FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone",
+ a_RelX, a_RelY, a_RelZ,
+ ItemTypeToString(NewBlock).c_str()
+ );
+ a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+
+ // TODO: Sound effect
+
+ return;
+ }
+ }
+ else if (m_FluidBlock == E_BLOCK_WATER)
+ {
+ if (IsBlockLava(BlockType))
+ {
+ // Water flowing into lava, change to cobblestone / obsidian based on dest block:
+ BLOCKTYPE NewBlock = (BlockMeta == 0) ? E_BLOCK_OBSIDIAN : E_BLOCK_COBBLESTONE;
+ FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s",
+ a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
+ );
+ a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+
+ // TODO: Sound effect
+
+ return;
+ }
+ }
+ else
+ {
+ ASSERT(!"Unknown fluid!");
+ }
+
+ if (!IsPassableForFluid(BlockType))
+ {
+ // Can't spread there
+ return;
+ }
+
+ // Wash away the block there, if possible:
+ if (CanWashAway(BlockType))
+ {
+ cBlockHandler * Handler = BlockHandler(BlockType);
+ if (Handler->DoesDropOnUnsuitable())
+ {
+ Handler->DropBlock(
+ &m_World, NULL,
+ a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
+ a_RelY,
+ a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ
+ );
+ }
+ } // if (CanWashAway)
+
+ // Spread:
+ FLOG(" Spreading to {%d, %d, %d} with meta %d",
+ a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
+ a_RelY,
+ a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ,
+ a_NewMeta
+ );
+ a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
+}
+
+
+
+
+
+bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
+{
+ FLOG(" Checking neighbors for source creation");
+
+ static const Vector3i NeighborCoords[] =
+ {
+ Vector3i(-1, 0, 0),
+ Vector3i( 1, 0, 0),
+ Vector3i( 0, 0, -1),
+ Vector3i( 0, 0, 1),
+ } ;
+
+ int NumNeeded = m_NumNeighborsForSource;
+ for (int i = 0; i < ARRAYCOUNT(NeighborCoords); i++)
+ {
+ int x = a_RelX + NeighborCoords[i].x;
+ int y = a_RelY + NeighborCoords[i].y;
+ int z = a_RelZ + NeighborCoords[i].z;
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (!a_Chunk->UnboundedRelGetBlock(x, y, z, BlockType, BlockMeta))
+ {
+ // Neighbor not available, skip it
+ continue;
+ }
+ // FLOG(" Neighbor at {%d, %d, %d}: %s", x, y, z, ItemToFullString(cItem(BlockType, 1, BlockMeta)).c_str());
+ if ((BlockMeta == 0) && IsAnyFluidBlock(BlockType))
+ {
+ NumNeeded--;
+ // FLOG(" Found a neighbor source at {%d, %d, %d}, NumNeeded := %d", x, y, z, NumNeeded);
+ if (NumNeeded == 0)
+ {
+ // Found enough, turn into a source and bail out
+ // FLOG(" Found enough neighbor sources, turning into a source");
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, 0);
+ return true;
+ }
+ }
+ }
+ // FLOG(" Not enough neighbors for turning into a source, NumNeeded = %d", NumNeeded);
+ return false;
+}
+
+
+
+
diff --git a/source/Simulator/FloodyFluidSimulator.h b/source/Simulator/FloodyFluidSimulator.h
index e6ce38d61..c4af2e246 100644
--- a/source/Simulator/FloodyFluidSimulator.h
+++ b/source/Simulator/FloodyFluidSimulator.h
@@ -1,53 +1,53 @@
-
-// FloodyFluidSimulator.h
-
-// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
-// http://forum.mc-server.org/showthread.php?tid=565
-
-
-
-
-
-#pragma once
-
-#include "DelayedFluidSimulator.h"
-
-
-
-
-
-// fwd:
-class cBlockArea;
-
-
-
-
-
-class cFloodyFluidSimulator :
- public cDelayedFluidSimulator
-{
- typedef cDelayedFluidSimulator super;
-
-public:
- cFloodyFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, NIBBLETYPE a_Falloff, int a_TickDelay, int a_NumNeighborsForSource);
-
-protected:
- NIBBLETYPE m_Falloff;
- int m_NumNeighborsForSource;
-
- // cDelayedFluidSimulator overrides:
- virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override;
-
- /// Checks tributaries, if not fed, decreases the block's level and returns true
- bool CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta);
-
- /// Spreads into the specified block, if the blocktype there allows. a_Area is for checking.
- void SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta);
-
- /// Checks if there are enough neighbors to create a source at the coords specified; turns into source and returns true if so
- bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
-} ;
-
-
-
-
+
+// FloodyFluidSimulator.h
+
+// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
+// http://forum.mc-server.org/showthread.php?tid=565
+
+
+
+
+
+#pragma once
+
+#include "DelayedFluidSimulator.h"
+
+
+
+
+
+// fwd:
+class cBlockArea;
+
+
+
+
+
+class cFloodyFluidSimulator :
+ public cDelayedFluidSimulator
+{
+ typedef cDelayedFluidSimulator super;
+
+public:
+ cFloodyFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, NIBBLETYPE a_Falloff, int a_TickDelay, int a_NumNeighborsForSource);
+
+protected:
+ NIBBLETYPE m_Falloff;
+ int m_NumNeighborsForSource;
+
+ // cDelayedFluidSimulator overrides:
+ virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override;
+
+ /// Checks tributaries, if not fed, decreases the block's level and returns true
+ bool CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta);
+
+ /// Spreads into the specified block, if the blocktype there allows. a_Area is for checking.
+ void SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta);
+
+ /// Checks if there are enough neighbors to create a source at the coords specified; turns into source and returns true if so
+ bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
+} ;
+
+
+
+
diff --git a/source/Simulator/NoopFluidSimulator.h b/source/Simulator/NoopFluidSimulator.h
index 9120fe868..8f894433f 100644
--- a/source/Simulator/NoopFluidSimulator.h
+++ b/source/Simulator/NoopFluidSimulator.h
@@ -1,36 +1,36 @@
-
-// NoopFluidSimulator.h
-
-// Declares the cNoopFluidSimulator class representing a fluid simulator that performs nothing, it ignores all blocks
-
-
-
-
-
-#pragma once
-
-#include "FluidSimulator.h"
-
-
-
-
-
-class cNoopFluidSimulator :
- public cFluidSimulator
-{
- typedef cFluidSimulator super;
-
-public:
- cNoopFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
- super(a_World, a_Fluid, a_StationaryFluid)
- {
- }
-
- // cSimulator overrides:
- virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override {}
- virtual void Simulate(float a_Dt) override {}
-} ;
-
-
-
-
+
+// NoopFluidSimulator.h
+
+// Declares the cNoopFluidSimulator class representing a fluid simulator that performs nothing, it ignores all blocks
+
+
+
+
+
+#pragma once
+
+#include "FluidSimulator.h"
+
+
+
+
+
+class cNoopFluidSimulator :
+ public cFluidSimulator
+{
+ typedef cFluidSimulator super;
+
+public:
+ cNoopFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
+ super(a_World, a_Fluid, a_StationaryFluid)
+ {
+ }
+
+ // cSimulator overrides:
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override {}
+ virtual void Simulate(float a_Dt) override {}
+} ;
+
+
+
+
diff --git a/source/Simulator/VaporizeFluidSimulator.cpp b/source/Simulator/VaporizeFluidSimulator.cpp
index 792783915..4206c64d1 100644
--- a/source/Simulator/VaporizeFluidSimulator.cpp
+++ b/source/Simulator/VaporizeFluidSimulator.cpp
@@ -1,53 +1,53 @@
-
-// VaporizeFluidSimulator.cpp
-
-// Implements the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
-
-#include "Globals.h"
-#include "VaporizeFluidSimulator.h"
-#include "../Chunk.h"
-
-
-
-
-
-cVaporizeFluidSimulator::cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
- super(a_World, a_Fluid, a_StationaryFluid)
-{
-}
-
-
-
-
-
-void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
-{
- if (a_Chunk == NULL)
- {
- return;
- }
- int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
- BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
- if (
- (BlockType == m_FluidBlock) ||
- (BlockType == m_StationaryFluidBlock)
- )
- {
- a_Chunk->SetBlock(RelX, a_BlockY, RelZ, E_BLOCK_AIR, 0);
- a_Chunk->BroadcastSoundEffect("random.fizz", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.6f);
- }
-}
-
-
-
-
-
-void cVaporizeFluidSimulator::Simulate(float a_Dt)
-{
- // Nothing needed
-}
-
-
-
-
+
+// VaporizeFluidSimulator.cpp
+
+// Implements the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
+
+#include "Globals.h"
+#include "VaporizeFluidSimulator.h"
+#include "../Chunk.h"
+
+
+
+
+
+cVaporizeFluidSimulator::cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
+ super(a_World, a_Fluid, a_StationaryFluid)
+{
+}
+
+
+
+
+
+void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
+{
+ if (a_Chunk == NULL)
+ {
+ return;
+ }
+ int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
+ BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
+ if (
+ (BlockType == m_FluidBlock) ||
+ (BlockType == m_StationaryFluidBlock)
+ )
+ {
+ a_Chunk->SetBlock(RelX, a_BlockY, RelZ, E_BLOCK_AIR, 0);
+ a_Chunk->BroadcastSoundEffect("random.fizz", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.6f);
+ }
+}
+
+
+
+
+
+void cVaporizeFluidSimulator::Simulate(float a_Dt)
+{
+ // Nothing needed
+}
+
+
+
+
diff --git a/source/Simulator/VaporizeFluidSimulator.h b/source/Simulator/VaporizeFluidSimulator.h
index c179c8ec4..c8eb7802b 100644
--- a/source/Simulator/VaporizeFluidSimulator.h
+++ b/source/Simulator/VaporizeFluidSimulator.h
@@ -1,34 +1,34 @@
-
-// VaporizeFluidSimulator.h
-
-// Declares the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
-// Useful for water simulation in the Nether
-
-
-
-
-
-#pragma once
-
-#include "FluidSimulator.h"
-
-
-
-
-
-class cVaporizeFluidSimulator :
- public cFluidSimulator
-{
- typedef cFluidSimulator super;
-
-public:
- cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
-
- // cSimulator overrides:
- virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
- virtual void Simulate(float a_Dt) override;
-} ;
-
-
-
-
+
+// VaporizeFluidSimulator.h
+
+// Declares the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
+// Useful for water simulation in the Nether
+
+
+
+
+
+#pragma once
+
+#include "FluidSimulator.h"
+
+
+
+
+
+class cVaporizeFluidSimulator :
+ public cFluidSimulator
+{
+ typedef cFluidSimulator super;
+
+public:
+ cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
+
+ // cSimulator overrides:
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
+ virtual void Simulate(float a_Dt) override;
+} ;
+
+
+
+