From 40eba5244ddd7045a9c3539c5f46c9921301ed90 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 8 Aug 2020 18:22:16 +0100 Subject: Remove the redstone solid block handler - Remove cSolidBlockHandler * Functionality now integrated into simulator dispatcher * Fix door double open/close issues, arisen due to the top/bottom halves getting different power + Small migration to block states for redstone wire --- .../PressurePlateHandler.h | 29 +++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h') diff --git a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h index f6969e15a..979d1ef96 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h @@ -11,19 +11,18 @@ class cPressurePlateHandler final : public cRedstoneHandler { -public: - - virtual unsigned char GetPowerDeliveredToPosition(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override + 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_BlockType); - UNUSED(a_Meta); UNUSED(a_QueryPosition); UNUSED(a_QueryBlockType); - return DataForChunk(a_Chunk).GetCachedPowerData(a_Position).PowerLevel; + // Plates only link power blocks below + // Retrieve and return the cached power calculated by Update for performance: + return (IsLinked && (a_QueryPosition != (a_Position + OffsetYM))) ? 0 : DataForChunk(a_Chunk).GetCachedPowerData(a_Position).PowerLevel; } - static unsigned char GetPowerLevel(cChunk & Chunk, const Vector3i Position, const BLOCKTYPE BlockType) + static unsigned char GetPowerLevel(const cChunk & Chunk, const Vector3i Position, const BLOCKTYPE BlockType) { unsigned NumberOfEntities = 0; bool FoundPlayer = false; @@ -70,12 +69,6 @@ public: } } - static void UpdatePlate(cChunk & Chunk, cChunk & CurrentlyTicking, Vector3i Position) - { - UpdateAdjustedRelative(Chunk, CurrentlyTicking, Position + OffsetYM); - UpdateAdjustedRelatives(Chunk, CurrentlyTicking, Position, RelativeLaterals); - } - virtual void Update(cChunk & a_Chunk, cChunk & CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override { // LOGD("Evaluating clicky the pressure plate (%d %d %d)", a_Position.x, a_Position.y, a_Position.z); @@ -107,7 +100,9 @@ public: // Immediately depress plate a_Chunk.SetMeta(a_Position, E_META_PRESSURE_PLATE_DEPRESSED); - return UpdatePlate(a_Chunk, CurrentlyTicking, a_Position); + + UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents); + return; } // Not a resting state @@ -137,7 +132,7 @@ public: { // Yes. Update power ChunkData.SetCachedPowerData(a_Position, PoweringData(a_BlockType, Power)); - return UpdatePlate(a_Chunk, CurrentlyTicking, a_Position); + UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents); } return; @@ -159,7 +154,7 @@ public: { // Yes. Update power ChunkData.SetCachedPowerData(a_Position, PoweringData(a_BlockType, Power)); - return UpdatePlate(a_Chunk, CurrentlyTicking, a_Position); + UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents); } // Yes, but player's still on the plate, do nothing @@ -173,10 +168,10 @@ public: ChunkData.SetCachedPowerData(a_Position, PoweringData(a_BlockType, Power)); a_Chunk.SetMeta(a_Position, E_META_PRESSURE_PLATE_RAISED); - return UpdatePlate(a_Chunk, CurrentlyTicking, a_Position); + UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents); } - virtual void ForValidSourcePositions(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override + virtual void ForValidSourcePositions(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override { UNUSED(a_Chunk); UNUSED(a_Position); -- cgit v1.2.3