diff options
Diffstat (limited to '')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp | 5 | ||||
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp index 3c79d152b..0e9621910 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp @@ -125,8 +125,11 @@ void cIncrementalRedstoneSimulator::Simulate(float a_dt) } auto CurrentHandler = cIncrementalRedstoneSimulator::CreateComponent(m_World, CurrentBlock, &m_Data); - if (CurrentHandler == nullptr) + if (CurrentHandler == nullptr) // Block at CurrentPosition doesn't have a corresponding redstone handler { + // Clean up cached PowerData for CurrentPosition + static_cast<cIncrementalRedstoneSimulator *>(m_World.GetRedstoneSimulator())->GetChunkData()->ErasePowerData(CurrentLocation); + continue; } diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h index 8e025d154..b461512f0 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h +++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneSimulatorChunkData.h @@ -41,6 +41,12 @@ public: return (Result == m_MechanismDelays.end()) ? nullptr : &Result->second; } + /** Erase cached PowerData for position */ + void ErasePowerData(const Vector3i & a_Position) + { + m_CachedPowerLevels.erase(a_Position); + } + cRedstoneHandler::PoweringData ExchangeUpdateOncePowerData(const Vector3i & a_Position, cRedstoneHandler::PoweringData a_PoweringData) { auto Result = m_CachedPowerLevels.find(a_Position); |