diff options
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp | 18 | ||||
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h | 36 |
2 files changed, 20 insertions, 34 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp index 33c0f9523..f2c8b7e65 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp @@ -273,26 +273,18 @@ void cIncrementalRedstoneSimulator::ProcessWorkItem(cChunk & Chunk, cChunk & Tic void cIncrementalRedstoneSimulator::AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) { - // Can't inspect block, ignore: - if ((a_Chunk == nullptr) || !a_Chunk->IsValid()) - { - return; - } - - auto & ChunkData = *static_cast<cIncrementalRedstoneSimulatorChunkData *>(a_Chunk->GetRedstoneSimulatorData()); - const auto Relative = cChunkDef::AbsoluteToRelative(a_Block, a_Chunk->GetPos()); - const auto CurrentBlock = a_Chunk->GetBlock(Relative); + auto & ChunkData = *static_cast<cIncrementalRedstoneSimulatorChunkData *>(a_Chunk.GetRedstoneSimulatorData()); - if (!IsRedstone(CurrentBlock)) + if (!IsRedstone(a_Block)) { return; } - if (IsAlwaysTicked(CurrentBlock)) + if (IsAlwaysTicked(a_Block)) { - ChunkData.AlwaysTickedPositions.emplace(Relative); + ChunkData.AlwaysTickedPositions.emplace(a_Position); } // Always update redstone devices: - ChunkData.WakeUp(Relative); + ChunkData.WakeUp(a_Position); } diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h index 7f1a6a9cf..44c63a5a8 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h @@ -21,26 +21,7 @@ public: { } -private: - - virtual void WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) override; - - virtual void Simulate(float Dt) override {}; - virtual void SimulateChunk(std::chrono::milliseconds Dt, int ChunkX, int ChunkZ, cChunk * Chunk) override; - - void ProcessWorkItem(cChunk & Chunk, cChunk & TickingSource, const Vector3i Position); - - virtual cIncrementalRedstoneSimulatorChunkData * CreateChunkData() override - { - return new cIncrementalRedstoneSimulatorChunkData; - } - - virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override - { - return IsRedstone(a_BlockType); - } - - virtual void AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) override; + static const cRedstoneHandler * GetComponentHandler(BLOCKTYPE a_BlockType); /** Returns if a block is a mechanism (something that accepts power and does something) Used by torches to determine if they will power a block */ @@ -164,7 +145,20 @@ private: } } - static const cRedstoneHandler * GetComponentHandler(BLOCKTYPE a_BlockType); +private: + + virtual void WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) override; + virtual void Simulate(float Dt) override {}; + virtual void SimulateChunk(std::chrono::milliseconds Dt, int ChunkX, int ChunkZ, cChunk * Chunk) override; + + void ProcessWorkItem(cChunk & Chunk, cChunk & TickingSource, const Vector3i Position); + + virtual cIncrementalRedstoneSimulatorChunkData * CreateChunkData() override + { + return new cIncrementalRedstoneSimulatorChunkData; + } + + virtual void AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) override; private: |