diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-29 21:15:09 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-04 19:15:18 +0200 |
commit | adb86a75dac91a210149fc28b1dbf5225896f66c (patch) | |
tree | b62bcb6cba06726081c598879d84018f7a39c824 /src/Simulator/SimulatorManager.cpp | |
parent | Use std::queue for the block tick queue (diff) | |
download | cuberite-adb86a75dac91a210149fc28b1dbf5225896f66c.tar cuberite-adb86a75dac91a210149fc28b1dbf5225896f66c.tar.gz cuberite-adb86a75dac91a210149fc28b1dbf5225896f66c.tar.bz2 cuberite-adb86a75dac91a210149fc28b1dbf5225896f66c.tar.lz cuberite-adb86a75dac91a210149fc28b1dbf5225896f66c.tar.xz cuberite-adb86a75dac91a210149fc28b1dbf5225896f66c.tar.zst cuberite-adb86a75dac91a210149fc28b1dbf5225896f66c.zip |
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); + } } } |