diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-09-17 19:40:10 +0200 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-09-17 19:40:10 +0200 |
commit | 6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd (patch) | |
tree | 69681d2a6bd1f3572305f7120d9231b394ac9c88 /src/Simulator | |
parent | IncrementalRedstoneSimulator now has no dependencies on cChunk (diff) | |
download | cuberite-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 '')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator.cpp | 4 | ||||
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator.inc | 55 | ||||
-rw-r--r-- | src/Simulator/SandSimulator.cpp | 1 | ||||
-rw-r--r-- | src/Simulator/Simulator.cpp | 5 | ||||
-rw-r--r-- | src/Simulator/Simulator.h | 1 | ||||
-rw-r--r-- | src/Simulator/Simulator.inc | 4 |
6 files changed, 40 insertions, 30 deletions
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<cChestEntity> 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<cChunk, cWorld> * 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<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; 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" |