From 99856df6869d32731e6fdcfeb1460297410f5820 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 29 Jul 2020 00:12:45 +0100 Subject: Add WakeUp/AddBlock distinction * WakeUp is for singular changes (block breaking for example). The simulator should check blocks around the position and discover other affected blocks as it sees fit * AddBlock is for when you know a whole area is to be updated; chunk loading, or area wakeups for example + Prepares for correct handling of destroyed blocks after removal of SolidBlockHandler in the redstone simulator --- src/Simulator/SimulatorManager.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/Simulator/SimulatorManager.cpp') diff --git a/src/Simulator/SimulatorManager.cpp b/src/Simulator/SimulatorManager.cpp index a2740f707..f10c285e0 100644 --- a/src/Simulator/SimulatorManager.cpp +++ b/src/Simulator/SimulatorManager.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "SimulatorManager.h" +#include "../Chunk.h" #include "../World.h" @@ -58,11 +59,13 @@ void cSimulatorManager::SimulateChunk(std::chrono::milliseconds a_Dt, int a_Chun -void cSimulatorManager::WakeUp(Vector3i a_Block, cChunk * a_Chunk) +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) { - itr->first->WakeUp(a_Block, a_Chunk); + itr->first->WakeUp(a_Chunk, a_Position, a_Chunk.GetBlock(a_Position)); } } @@ -70,11 +73,11 @@ void cSimulatorManager::WakeUp(Vector3i a_Block, cChunk * a_Chunk) -void cSimulatorManager::WakeUpArea(const cCuboid & a_Area) +void cSimulatorManager::WakeUp(const cCuboid & a_Area) { - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) + for (const auto Item : m_Simulators) { - itr->first->WakeUpArea(a_Area); + Item.first->WakeUp(a_Area); } } @@ -86,7 +89,3 @@ void cSimulatorManager::RegisterSimulator(cSimulator * a_Simulator, int a_Rate) { m_Simulators.push_back(std::make_pair(a_Simulator, a_Rate)); } - - - - -- cgit v1.2.3