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.cpp | 4 +- src/Simulator/IncrementalRedstoneSimulator.inc | 55 +++++++++++++++----------- src/Simulator/SandSimulator.cpp | 1 + src/Simulator/Simulator.cpp | 5 +++ src/Simulator/Simulator.h | 1 - src/Simulator/Simulator.inc | 4 -- 6 files changed, 40 insertions(+), 30 deletions(-) (limited to 'src/Simulator') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 55cc014f3..df05a9fee 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1,6 +1,9 @@ #include "Globals.h" +#include "BlockEntities/ChestEntity.h" + +typedef cItemCallback cChestCallback; #include "IncrementalRedstoneSimulator.inc" @@ -13,7 +16,6 @@ #include "Blocks/BlockTripwireHook.h" #include "Blocks/BlockDoor.h" #include "Blocks/BlockPiston.h" -#include "BlockEntities/ChestEntity.h" cRedstoneSimulator * MakeIncrementalRedstoneSimulator(cWorld & a_World) { 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; diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index 1380f8841..e8887ce59 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -7,6 +7,7 @@ #include "../Defines.h" #include "../Entities/FallingBlock.h" #include "../Chunk.h" +#include "inifile/iniFile.h" diff --git a/src/Simulator/Simulator.cpp b/src/Simulator/Simulator.cpp index 7b944382b..d26702166 100644 --- a/src/Simulator/Simulator.cpp +++ b/src/Simulator/Simulator.cpp @@ -1,6 +1,11 @@ #include "Globals.h" +#include "../World.h" +#include "../BlockID.h" +#include "../Defines.h" +#include "../Chunk.h" + #include "Simulator.inc" #pragma clang diagnostic ignored "-Wweak-template-vtables" diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index ff53b17e1..7cc2f1344 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -2,7 +2,6 @@ #pragma once #include "../Vector3.h" -#include "inifile/iniFile.h" diff --git a/src/Simulator/Simulator.inc b/src/Simulator/Simulator.inc index 1599ea60f..511a6b4c2 100644 --- a/src/Simulator/Simulator.inc +++ b/src/Simulator/Simulator.inc @@ -1,10 +1,6 @@ #include "Simulator.h" -#include "../World.h" -#include "../BlockID.h" -#include "../Defines.h" -#include "../Chunk.h" -- cgit v1.2.3