From b8ab03bc6b41dbe8262f87def3ff3513924315d4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 24 Jul 2018 00:35:20 +0100 Subject: At long last... Piston animations! * Fixes #3198 * Fixes #57 (again lol) --- .../IncrementalRedstoneSimulator/PistonHandler.h | 38 +++++++--------------- .../RedstoneSimulatorChunkData.h | 1 - 2 files changed, 12 insertions(+), 27 deletions(-) (limited to 'src/Simulator/IncrementalRedstoneSimulator') diff --git a/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h b/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h index 01742b13c..de001a9e5 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h @@ -36,39 +36,25 @@ public: virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override { // LOGD("Evaluating pisty the piston (%d %d %d)", a_Position.x, a_Position.y, a_Position.z); - auto Data = static_cast(a_World.GetRedstoneSimulator())->GetChunkData(); - auto DelayInfo = Data->GetMechanismDelayInfo(a_Position); - // Delay is used here to prevent an infinite loop (#3168) - if (DelayInfo == nullptr) + bool ShouldBeExtended = (a_PoweringData.PowerLevel != 0); + if (ShouldBeExtended == cBlockPistonHandler::IsExtended(a_Meta)) { - bool ShouldBeExtended = (a_PoweringData.PowerLevel != 0); - if (ShouldBeExtended != cBlockPistonHandler::IsExtended(a_Meta)) - { - Data->m_MechanismDelays[a_Position] = std::make_pair(1, ShouldBeExtended); - } + return {}; + } + + if (ShouldBeExtended) + { + cBlockPistonHandler::ExtendPiston(a_Position, a_World); } else { - int DelayTicks; - bool ShouldBeExtended; - std::tie(DelayTicks, ShouldBeExtended) = *DelayInfo; - - if (DelayTicks == 0) - { - if (ShouldBeExtended) - { - cBlockPistonHandler::ExtendPiston(a_Position, a_World); - } - else - { - cBlockPistonHandler::RetractPiston(a_Position, a_World); - } - - Data->m_MechanismDelays.erase(a_Position); - } + cBlockPistonHandler::RetractPiston(a_Position, a_World); } + // It is necessary to delay after a signal to prevent an infinite loop (#3168) + // However, that is present as a side effect of the implementation of piston animation in Blocks\BlockPiston.cpp + return {}; } diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h index 83374e311..f0fd8d512 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h +++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h @@ -60,7 +60,6 @@ public: /** Structure storing position of mechanism + it's delay ticks (countdown) & if to power on */ std::unordered_map, VectorHasher> m_MechanismDelays; - std::unordered_map> m_UpdateOncePositions; private: -- cgit v1.2.3