From e225b7f8262df48ad4d7094bc295add3007b0649 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Mon, 11 Sep 2017 22:20:49 +0100 Subject: Replace ItemCallbacks with lambdas (#3993) --- .../TrappedChestHandler.h | 37 ++++------------------ 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h') diff --git a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h index 4ae4aff3d..80e55faec 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h @@ -1,4 +1,4 @@ - + #pragma once #include "RedstoneHandler.h" @@ -28,38 +28,15 @@ public: UNUSED(a_BlockType); UNUSED(a_Meta); - class cGetTrappedChestPlayers : - public cItemCallback - { - public: - cGetTrappedChestPlayers(void) : - m_NumberOfPlayers(0) - { - } - - virtual ~cGetTrappedChestPlayers() override - { - } - - virtual bool Item(cChestEntity * a_Chest) override + int NumberOfPlayers = 0; + VERIFY(!a_World.DoWithChestAt(a_Position.x, a_Position.y, a_Position.z, [&](cChestEntity & a_Chest) { - ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST); - m_NumberOfPlayers = a_Chest->GetNumberOfPlayers(); + ASSERT(a_Chest.GetBlockType() == E_BLOCK_TRAPPED_CHEST); + NumberOfPlayers = a_Chest.GetNumberOfPlayers(); return true; } - - unsigned char GetPowerLevel(void) const - { - return static_cast(std::min(m_NumberOfPlayers, 15)); - } - - private: - int m_NumberOfPlayers; - - } GTCP; - - VERIFY(!a_World.DoWithChestAt(a_Position.x, a_Position.y, a_Position.z, GTCP)); - return GTCP.GetPowerLevel(); + )); + return static_cast(std::min(NumberOfPlayers, 15)); } virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override -- cgit v1.2.3