From 1673c8497852c3a6a90cf793cf4dffcbaef4b6d7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 26 Jul 2020 16:08:20 +0100 Subject: [PATCH] Remove redundant ErasePowerData call * Also fix a return that should've been continue --- .../IncrementalRedstoneSimulator.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp index 2eb515604..c4aa0a94b 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp @@ -152,7 +152,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(std::chrono::milliseconds a_Dt const auto NeighbourChunk = a_Chunk->GetRelNeighborChunkAdjustCoords(CurrentLocation); if ((NeighbourChunk == nullptr) || !NeighbourChunk->IsValid()) { - return; + continue; } ProcessWorkItem(*NeighbourChunk, *a_Chunk, CurrentLocation); @@ -170,17 +170,15 @@ void cIncrementalRedstoneSimulator::SimulateChunk(std::chrono::milliseconds a_Dt void cIncrementalRedstoneSimulator::ProcessWorkItem(cChunk & Chunk, cChunk & TickingSource, const Vector3i Position) { - auto & ChunkData = *static_cast(Chunk.GetRedstoneSimulatorData()); - BLOCKTYPE CurrentBlock; NIBBLETYPE CurrentMeta; Chunk.GetBlockTypeMeta(Position, CurrentBlock, CurrentMeta); auto CurrentHandler = GetComponentHandler(CurrentBlock); - if (CurrentHandler == nullptr) // Block at CurrentPosition doesn't have a corresponding redstone handler + if (CurrentHandler == nullptr) { - // Clean up cached PowerData for CurrentPosition - ChunkData.ErasePowerData(Position); + // Block at Position doesn't have a corresponding redstone handler + // ErasePowerData will have been called in AddBlock return; } @@ -229,7 +227,7 @@ void cIncrementalRedstoneSimulator::ProcessWorkItem(cChunk & Chunk, cChunk & Tic void cIncrementalRedstoneSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk) { // Can't inspect block, ignore: - if ((a_Chunk == nullptr) || (!a_Chunk->IsValid())) + if ((a_Chunk == nullptr) || !a_Chunk->IsValid()) { return; }