summaryrefslogtreecommitdiffstats
path: root/src/Simulator
diff options
context:
space:
mode:
Diffstat (limited to 'src/Simulator')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.inc12
-rw-r--r--src/Simulator/NoopRedstoneSimulator.h5
-rw-r--r--src/Simulator/RedstoneSimulator.h2
-rw-r--r--src/Simulator/Simulator.cpp7
4 files changed, 24 insertions, 2 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator.inc b/src/Simulator/IncrementalRedstoneSimulator.inc
index adaa47967..200fc0971 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.inc
+++ b/src/Simulator/IncrementalRedstoneSimulator.inc
@@ -27,6 +27,11 @@ public:
{
}
~cIncrementalRedstoneSimulator();
+
+ virtual cRedstoneSimulatorChunkData * CreateChunkData() override
+ {
+ return new cIncrementalRedstoneSimulatorChunkData;
+ }
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, ChunkType * a_Chunk) override;
@@ -408,7 +413,12 @@ void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime,
// Every time a block is changed (AddBlock called), we want to go through all lists and check to see if the coordiantes stored within are still valid
// Checking only when a block is changed, as opposed to every tick, also improves performance
- PoweredBlocksList & PoweredBlocks = ((cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData())->m_PoweredBlocks;
+ cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::cIncrementalRedstoneSimulatorChunkData * SimulatorChunkData = ((cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData());
+ if (SimulatorChunkData == NULL)
+ {
+ return;
+ }
+ PoweredBlocksList & PoweredBlocks = SimulatorChunkData->m_PoweredBlocks;
for (typename PoweredBlocksList::iterator itr = PoweredBlocks.begin(); itr != PoweredBlocks.end();)
{
if (!itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h
index 88e141e85..7c961f32b 100644
--- a/src/Simulator/NoopRedstoneSimulator.h
+++ b/src/Simulator/NoopRedstoneSimulator.h
@@ -36,5 +36,10 @@ public:
UNUSED(a_BlockZ);
UNUSED(a_Chunk);
}
+
+ virtual cRedstoneSimulatorChunkData * CreateChunkData() override
+ {
+ return NULL;
+ }
} ;
diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h
index f6d36f869..6104d39b4 100644
--- a/src/Simulator/RedstoneSimulator.h
+++ b/src/Simulator/RedstoneSimulator.h
@@ -24,5 +24,7 @@ public:
super(a_World)
{
}
+
+ virtual cRedstoneSimulatorChunkData * CreateChunkData() = 0;
} ;
diff --git a/src/Simulator/Simulator.cpp b/src/Simulator/Simulator.cpp
index d26702166..29a1132ad 100644
--- a/src/Simulator/Simulator.cpp
+++ b/src/Simulator/Simulator.cpp
@@ -8,6 +8,11 @@
#include "Simulator.inc"
-#pragma clang diagnostic ignored "-Wweak-template-vtables"
+#ifdef __clang__
+ #pragma clang diagnostic ignored "-Wweak-template-vtables"
+#endif // __clang__
+
template class cSimulator<cChunk, cWorld>;
+
+