summaryrefslogtreecommitdiffstats
path: root/source/Simulator
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Simulator/RedstoneSimulator.cpp37
-rw-r--r--source/Simulator/RedstoneSimulator.h1
2 files changed, 38 insertions, 0 deletions
diff --git a/source/Simulator/RedstoneSimulator.cpp b/source/Simulator/RedstoneSimulator.cpp
index 2224d300d..1862537e0 100644
--- a/source/Simulator/RedstoneSimulator.cpp
+++ b/source/Simulator/RedstoneSimulator.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "RedstoneSimulator.h"
+#include "../DispenserEntity.h"
#include "../Piston.h"
#include "../World.h"
#include "../BlockID.h"
@@ -387,6 +388,36 @@ void cRedstoneSimulator::HandleChange( const Vector3i & a_BlockPos )
}
} // switch (BlockType)
} // while (m_RefreshPistons[])
+
+ while (!m_RefreshDispensers.empty())
+ {
+ Vector3i pos = m_RefreshDispensers.back();
+ m_RefreshDispensers.pop_back();
+
+ BLOCKTYPE BlockType = m_World->GetBlock(pos);
+ if (BlockType == E_BLOCK_DISPENSER)
+ {
+ if (IsPowered(pos))
+ {
+ class cActivateDispenser :
+ public cDispenserCallback
+ {
+ public:
+ cActivateDispenser()
+ {
+ }
+
+ virtual bool Item(cDispenserEntity * a_Dispenser) override
+ {
+ a_Dispenser->Activate();
+ return false;
+ }
+ } ;
+ cActivateDispenser DispAct;
+ m_World->DoWithDispenserAt(pos.x, pos.y, pos.z, DispAct);
+ }
+ }
+ }
}
@@ -416,6 +447,12 @@ bool cRedstoneSimulator::PowerBlock(const Vector3i & a_BlockPos, const Vector3i
m_RefreshPistons.push_back(a_BlockPos);
break;
}
+
+ case E_BLOCK_DISPENSER:
+ {
+ m_RefreshDispensers.push_back(a_BlockPos);
+ break;
+ }
case E_BLOCK_REDSTONE_REPEATER_OFF:
case E_BLOCK_REDSTONE_REPEATER_ON:
diff --git a/source/Simulator/RedstoneSimulator.h b/source/Simulator/RedstoneSimulator.h
index 089b84aeb..0b0333164 100644
--- a/source/Simulator/RedstoneSimulator.h
+++ b/source/Simulator/RedstoneSimulator.h
@@ -71,6 +71,7 @@ private:
BlockList m_BlocksBuffer;
BlockList m_RefreshPistons;
+ BlockList m_RefreshDispensers;
BlockList m_RefreshTorchesAround;