summaryrefslogtreecommitdiffstats
path: root/source/Simulator
diff options
context:
space:
mode:
Diffstat (limited to 'source/Simulator')
-rw-r--r--source/Simulator/DelayedFluidSimulator.cpp15
-rw-r--r--source/Simulator/DelayedFluidSimulator.h8
2 files changed, 15 insertions, 8 deletions
diff --git a/source/Simulator/DelayedFluidSimulator.cpp b/source/Simulator/DelayedFluidSimulator.cpp
index 3ace286ed..317452c57 100644
--- a/source/Simulator/DelayedFluidSimulator.cpp
+++ b/source/Simulator/DelayedFluidSimulator.cpp
@@ -17,7 +17,7 @@ cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld * a_World, BLOCKTYPE a_Flu
super(a_World, a_Fluid, a_StationaryFluid),
m_TickDelay(a_TickDelay),
m_Slots(NULL),
- m_CurrentSlotNum(a_TickDelay - 1)
+ m_CurrentSlotNum(0)
{
m_Slots = new CoordsArray[a_TickDelay];
}
@@ -70,21 +70,22 @@ void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
void cDelayedFluidSimulator::Simulate(float a_Dt)
{
- CoordsArray & Blocks = m_Slots[m_CurrentSlotNum];
-
- // First move to the next slot, so that simulated blocks can write another batch of scheduled blocks:
- m_CurrentSlotNum += 1;
- if (m_CurrentSlotNum >= m_TickDelay)
+ int SlotNum = m_CurrentSlotNum + 1;
+ if (SlotNum >= m_TickDelay)
{
- m_CurrentSlotNum = 0;
+ SlotNum = 0;
}
+ CoordsArray & Blocks = m_Slots[SlotNum];
+
// Simulate the blocks in the scheduled slot:
for (CoordsArray::iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
{
SimulateBlock(itr->x, itr->y, itr->z);
}
Blocks.clear();
+
+ m_CurrentSlotNum = SlotNum;
}
diff --git a/source/Simulator/DelayedFluidSimulator.h b/source/Simulator/DelayedFluidSimulator.h
index b9c180580..51fe2a514 100644
--- a/source/Simulator/DelayedFluidSimulator.h
+++ b/source/Simulator/DelayedFluidSimulator.h
@@ -34,7 +34,13 @@ protected:
int m_TickDelay; // Count of the m_Slots array
CoordsArray * m_Slots; // Slots, one for each delay tick
int m_CurrentSlotNum; // Index into m_Slots[] where to insert new blocks
-
+
+ /*
+ Slots:
+ | 0 | 1 | ... | m_CurrentSlotNum | m_CurrentSlotNum + 1 | ... | m_TickDelay - 1 |
+ adding blocks here ^ | ^ simulating here
+ */
+
/// Called from Simulate() to simulate each block in one slot of blocks. Descendants override this method to provide custom simulation.
virtual void SimulateBlock(int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
} ;