summaryrefslogtreecommitdiffstats
path: root/src/Simulator/IncrementalRedstoneSimulator.inc
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-09-17 19:40:10 +0200
committerTycho <work.tycho+git@gmail.com>2014-09-17 19:40:10 +0200
commit6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd (patch)
tree69681d2a6bd1f3572305f7120d9231b394ac9c88 /src/Simulator/IncrementalRedstoneSimulator.inc
parentIncrementalRedstoneSimulator now has no dependencies on cChunk (diff)
downloadcuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.gz
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.bz2
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.lz
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.xz
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.zst
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.zip
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator.inc')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.inc55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator.inc b/src/Simulator/IncrementalRedstoneSimulator.inc
index e3c856328..eee2daa7c 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.inc
+++ b/src/Simulator/IncrementalRedstoneSimulator.inc
@@ -6,6 +6,8 @@
#include "RedstoneSimulator.h"
+typedef cItemCallback<cEntity> cEntityCallback;
+
@@ -1630,7 +1632,7 @@ void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime,
}
default:
{
- LOGD("Unimplemented pressure plate type %s in cRedstoneSimulator", ItemToFullString(a_MyType).c_str());
+ LOGD("Unimplemented pressure plate type %s in cRedstoneSimulator", ItemToFullString(cItem(a_MyType)).c_str());
break;
}
}
@@ -1701,37 +1703,42 @@ void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime,
}
}
+template <class ChestType>
+class cGetTrappedChestPlayers :
+ public cItemCallback<ChestType>
+{
+public:
+ cGetTrappedChestPlayers(void) :
+ m_NumberOfPlayers(0)
+ {
+ }
+ virtual ~cGetTrappedChestPlayers()
+ {
+ }
+ virtual bool Item(ChestType * a_Chest) override
+ {
+ ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST);
+ m_NumberOfPlayers = a_Chest->GetNumberOfPlayers();
+ return (m_NumberOfPlayers <= 0);
+ }
-template <class ChunkType, class WorldType, template <BLOCKTYPE block> class GetHandlerCompileTime, class ChestType>
-void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
-{
- class cGetTrappedChestPlayers :
- public cChestCallback
+ unsigned char GetPowerLevel(void) const
{
- public:
- cGetTrappedChestPlayers(void) :
- m_NumberOfPlayers(0)
- {
- }
+ return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL);
+ }
- virtual bool Item(ChestType * a_Chest) override
- {
- ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST);
- m_NumberOfPlayers = a_Chest->GetNumberOfPlayers();
- return (m_NumberOfPlayers <= 0);
- }
+private:
+ int m_NumberOfPlayers;
- unsigned char GetPowerLevel(void) const
- {
- return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL);
- }
+};
- private:
- int m_NumberOfPlayers;
- } GTCP;
+template <class ChunkType, class WorldType, template <BLOCKTYPE block> class GetHandlerCompileTime, class ChestType>
+void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ cGetTrappedChestPlayers<ChestType> GTCP;
int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;