summaryrefslogtreecommitdiffstats
path: root/source/Simulator/FloodyFluidSimulator.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-14 20:30:16 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-14 20:30:16 +0200
commit41a38e8d9098d6627cd26351577cf032e6996c87 (patch)
tree34d53e6291c6d353a9c3a37a472b933f9fa5e57d /source/Simulator/FloodyFluidSimulator.cpp
parentInitial Floody fluid simulator. (diff)
downloadcuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar
cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.gz
cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.bz2
cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.lz
cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.xz
cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.zst
cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.zip
Diffstat (limited to '')
-rw-r--r--source/Simulator/FloodyFluidSimulator.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/Simulator/FloodyFluidSimulator.cpp b/source/Simulator/FloodyFluidSimulator.cpp
index 7dcd4edca..ae382d0a6 100644
--- a/source/Simulator/FloodyFluidSimulator.cpp
+++ b/source/Simulator/FloodyFluidSimulator.cpp
@@ -39,6 +39,11 @@ void cFloodyFluidSimulator::SimulateBlock(int a_BlockX, int a_BlockY, int a_Bloc
int y = (a_BlockY > 0) ? 1 : 0; // Relative y-coord of this block in Area
NIBBLETYPE MyMeta = Area.GetRelBlockMeta(1, y, 1);
+ if (!IsAnyFluidBlock(Area.GetRelBlockType(1, y, 1)))
+ {
+ // Can happen - if a block is scheduled for simulating and gets replaced in the meantime.
+ return;
+ }
if (MyMeta != 0)
{
@@ -121,6 +126,9 @@ bool cFloodyFluidSimulator::CheckTributaries(int a_BlockX, int a_BlockY, int a_B
void cFloodyFluidSimulator::SpreadToNeighbor(int a_BlockX, int a_BlockY, int a_BlockZ, const cBlockArea & a_Area, NIBBLETYPE a_NewMeta)
{
+ ASSERT(a_NewMeta <= 8); // Invalid meta values
+ ASSERT(a_NewMeta > 0); // Source blocks aren't spread
+
BLOCKTYPE Block = a_Area.GetBlockType(a_BlockX, a_BlockY, a_BlockZ);
if (IsAnyFluidBlock(Block))
@@ -149,8 +157,6 @@ void cFloodyFluidSimulator::SpreadToNeighbor(int a_BlockX, int a_BlockY, int a_B
}
// Spread:
- LOGD("Fluid: spreading to block {%d, %d, %d}, meta %d", a_BlockX, a_BlockY, a_BlockZ, a_NewMeta);
-
m_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_FluidBlock, a_NewMeta);
}