From 3143d6ce679f322ee73d3d70e2d843e9c98cc043 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 19 Aug 2020 21:14:40 +0100 Subject: Remove std::make_unique from redstone handler creation --- .../RedstoneToggleHandler.h | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h') diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h index b66ce47fd..b8f910d5f 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h @@ -1,7 +1,6 @@ #pragma once -#include "RedstoneHandler.h" #include "../../Blocks/BlockButton.h" #include "../../Blocks/BlockLever.h" @@ -9,9 +8,9 @@ -class cRedstoneToggleHandler final : public cRedstoneHandler +namespace RedstoneToggleHandler { - inline static Vector3i GetOffsetAttachedTo(Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) + inline Vector3i GetOffsetAttachedTo(Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) { switch (a_BlockType) { @@ -60,22 +59,7 @@ class cRedstoneToggleHandler final : public cRedstoneHandler } } - virtual unsigned char GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked) const override - { - UNUSED(a_QueryBlockType); - - const auto Meta = a_Chunk.GetMeta(a_Position); - const auto QueryOffset = a_QueryPosition - a_Position; - - if (IsLinked && (QueryOffset != GetOffsetAttachedTo(a_Position, a_BlockType, Meta))) - { - return 0; - } - - return GetPowerLevel(a_BlockType, Meta); - } - - static unsigned char GetPowerLevel(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) + inline unsigned char GetPowerLevel(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) { switch (a_BlockType) { @@ -90,12 +74,27 @@ class cRedstoneToggleHandler final : public cRedstoneHandler } } - virtual void Update(cChunk & a_Chunk, cChunk & CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override + inline unsigned char GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked) + { + UNUSED(a_QueryBlockType); + + const auto Meta = a_Chunk.GetMeta(a_Position); + const auto QueryOffset = a_QueryPosition - a_Position; + + if (IsLinked && (QueryOffset != GetOffsetAttachedTo(a_Position, a_BlockType, Meta))) + { + return 0; + } + + return GetPowerLevel(a_BlockType, Meta); + } + + inline void Update(cChunk & a_Chunk, cChunk & CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) { // LOGD("Evaluating templatio<> the lever/button (%d %d %d)", a_Position.x, a_Position.y, a_Position.z); } - virtual void ForValidSourcePositions(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override + inline void ForValidSourcePositions(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback & Callback) { UNUSED(a_Chunk); UNUSED(a_Position); -- cgit v1.2.3