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/Simulator.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/Simulator/Simulator.cpp') diff --git a/src/Simulator/Simulator.cpp b/src/Simulator/Simulator.cpp index ac2e757e4..e55b77f0f 100644 --- a/src/Simulator/Simulator.cpp +++ b/src/Simulator/Simulator.cpp @@ -1,33 +1,38 @@ #include "Globals.h" -#include "../World.h" -#include "../Defines.h" +#include "Simulator.h" #include "../Chunk.h" #include "../Cuboid.h" +#include "../World.h" -#ifdef __clang__ - #pragma clang diagnostic ignored "-Wweak-template-vtables" -#endif // __clang__ -#include "Simulator.h" +void cSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) +{ + ASSERT(a_Chunk.IsValid()); + + AddBlock(a_Chunk, a_Position, a_Block); +} -void cSimulator::WakeUp(Vector3i a_Block, cChunk * a_Chunk) + +void cSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position, Vector3i a_Offset, BLOCKTYPE a_Block) { - AddBlock(a_Block, a_Chunk); + ASSERT(a_Chunk.IsValid()); + + WakeUp(a_Chunk, a_Position, a_Block); } -void cSimulator::WakeUpArea(const cCuboid & a_Area) +void cSimulator::WakeUp(const cCuboid & a_Area) { cCuboid area(a_Area); area.Sort(); @@ -60,7 +65,8 @@ void cSimulator::WakeUpArea(const cCuboid & a_Area) { for (int x = startX; x <= endX; ++x) { - AddBlock({x, y, z}, &a_CBChunk); + const auto Position = cChunkDef::AbsoluteToRelative({ x, y, z }); + AddBlock(a_CBChunk, Position, a_CBChunk.GetBlock(Position)); } // for x } // for z } // for y @@ -70,7 +76,3 @@ void cSimulator::WakeUpArea(const cCuboid & a_Area) } // for cx } // for cz } - - - - -- cgit v1.2.3