From 6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 17 Sep 2014 18:40:10 +0100 Subject: Added first test to show the object can be created --- src/Simulator/IncrementalRedstoneSimulator.inc | 55 +++++++++++++++----------- 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'src/Simulator/IncrementalRedstoneSimulator.inc') 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 cEntityCallback; + @@ -1630,7 +1632,7 @@ void cIncrementalRedstoneSimulator +class cGetTrappedChestPlayers : + public cItemCallback +{ +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 GetHandlerCompileTime, class ChestType> -void cIncrementalRedstoneSimulator::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 GetHandlerCompileTime, class ChestType> +void cIncrementalRedstoneSimulator::HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) +{ + cGetTrappedChestPlayers GTCP; int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX; int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ; -- cgit v1.2.3