diff options
Diffstat (limited to '')
-rw-r--r-- | src/Simulator/SimulatorManager.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/Simulator/SimulatorManager.cpp b/src/Simulator/SimulatorManager.cpp index f10c285e0..07b4a7214 100644 --- a/src/Simulator/SimulatorManager.cpp +++ b/src/Simulator/SimulatorManager.cpp @@ -63,9 +63,29 @@ void cSimulatorManager::WakeUp(cChunk & a_Chunk, Vector3i a_Position) { ASSERT(a_Chunk.IsValid()); - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) + for (const auto Item : m_Simulators) + { + Item.first->WakeUp(a_Chunk, a_Position, a_Chunk.GetBlock(a_Position)); + } + + for (const auto Offset : cSimulator::AdjacentOffsets) { - itr->first->WakeUp(a_Chunk, a_Position, a_Chunk.GetBlock(a_Position)); + auto Relative = a_Position + Offset; + auto Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(Relative); + + if ((Chunk == nullptr) || !Chunk->IsValid()) + { + continue; + } + + // Stored block to give to simulators for performance + // Since they all need this we save them querying it themselves + const auto Block = Chunk->GetBlock(Relative); + + for (const auto Item : m_Simulators) + { + Item.first->WakeUp(*Chunk, Relative, Offset, Block); + } } } |