summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Simulator/NoopRedstoneSimulator.h40
-rw-r--r--src/Simulator/RedstoneManager.cpp19
-rw-r--r--src/Simulator/RedstoneManager.h17
-rw-r--r--src/Simulator/RedstoneSimulator.h6
-rw-r--r--src/World.cpp40
-rw-r--r--src/World.h9
6 files changed, 122 insertions, 9 deletions
diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h
new file mode 100644
index 000000000..4dd473c64
--- /dev/null
+++ b/src/Simulator/NoopRedstoneSimulator.h
@@ -0,0 +1,40 @@
+
+#pragma once
+
+#include "RedstoneManager.h"
+
+
+
+
+
+class cRedstoneNoopSimulator :
+ public cRedstoneManager
+{
+ typedef cRedstoneManager super;
+public:
+
+ cRedstoneNoopSimulator(cWorld & a_World) :
+ super(a_World)
+ {
+ }
+
+ //~cRedstoneNoopSimulator();
+
+ virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
+ virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override
+ {
+ UNUSED(a_Dt);
+ UNUSED(a_ChunkX);
+ UNUSED(a_ChunkZ);
+ UNUSED(a_Chunk);
+ }
+ virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return false; }
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
+ {
+ UNUSED(a_BlockX);
+ UNUSED(a_BlockY);
+ UNUSED(a_BlockZ);
+ UNUSED(a_Chunk);
+ }
+
+} ; \ No newline at end of file
diff --git a/src/Simulator/RedstoneManager.cpp b/src/Simulator/RedstoneManager.cpp
new file mode 100644
index 000000000..58fb8fa4c
--- /dev/null
+++ b/src/Simulator/RedstoneManager.cpp
@@ -0,0 +1,19 @@
+
+#include "Globals.h"
+
+#include "RedstoneManager.h"
+#include "../World.h"
+
+
+
+
+
+cRedstoneManager::cRedstoneManager(cWorld & a_World) :
+ super(a_World)
+{
+}
+
+
+
+
+
diff --git a/src/Simulator/RedstoneManager.h b/src/Simulator/RedstoneManager.h
new file mode 100644
index 000000000..846b7d8ab
--- /dev/null
+++ b/src/Simulator/RedstoneManager.h
@@ -0,0 +1,17 @@
+
+#pragma once
+
+#include "Simulator.h"
+
+
+
+
+class cRedstoneManager :
+ public cSimulator
+{
+ typedef cSimulator super;
+
+public:
+ cRedstoneManager(cWorld & a_World);
+
+} ; \ No newline at end of file
diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h
index c505b2a0f..c5ab1b9bb 100644
--- a/src/Simulator/RedstoneSimulator.h
+++ b/src/Simulator/RedstoneSimulator.h
@@ -1,7 +1,7 @@
#pragma once
-#include "Simulator.h"
+#include "RedstoneManager.h"
/// Per-chunk data for the simulator, specified individual chunks to simulate; 'Data' is not used
typedef cCoordWithBlockAndBoolVector cRedstoneSimulatorChunkData;
@@ -11,9 +11,9 @@ typedef cCoordWithBlockAndBoolVector cRedstoneSimulatorChunkData;
class cRedstoneSimulator :
- public cSimulator
+ public cRedstoneManager
{
- typedef cSimulator super;
+ typedef cRedstoneManager super;
public:
cRedstoneSimulator(cWorld & a_World);
diff --git a/src/World.cpp b/src/World.cpp
index 5e08fd599..1343d5ad6 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -29,6 +29,7 @@
#include "Simulator/FluidSimulator.h"
#include "Simulator/FireSimulator.h"
#include "Simulator/NoopFluidSimulator.h"
+#include "Simulator/NoopRedstoneSimulator.h"
#include "Simulator/SandSimulator.h"
#include "Simulator/RedstoneSimulator.h"
#include "Simulator/VaporizeFluidSimulator.h"
@@ -596,12 +597,11 @@ void cWorld::Start(void)
m_LavaSimulator = InitializeFluidSimulator(IniFile, "Lava", E_BLOCK_LAVA, E_BLOCK_STATIONARY_LAVA);
m_SandSimulator = new cSandSimulator(*this, IniFile);
m_FireSimulator = new cFireSimulator(*this, IniFile);
- m_RedstoneSimulator = new cRedstoneSimulator(*this);
+ m_RedstoneSimulator = InitializeRedstoneSimulator(IniFile);
- // Water and Lava simulators get registered in InitializeFluidSimulator()
+ // Water, Lava and Redstone simulators get registered in InitializeFluidSimulator()
m_SimulatorManager->RegisterSimulator(m_SandSimulator, 1);
m_SimulatorManager->RegisterSimulator(m_FireSimulator, 1);
- m_SimulatorManager->RegisterSimulator(m_RedstoneSimulator, 1);
m_Lighting.Start(this);
m_Storage.Start(this, m_StorageSchema, m_StorageCompressionFactor );
@@ -2871,6 +2871,40 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul
+cRedstoneManager * cWorld::InitializeRedstoneSimulator(cIniFile & a_IniFile)
+{
+ AString SimulatorName = a_IniFile.GetValueSet("Physics", "RedstoneSimulator", "");
+
+ if (SimulatorName.empty())
+ {
+ LOGWARNING("[Physics] RedstoneSimulator not present or empty in %s, using the default of \"Floody\".", GetIniFileName().c_str());
+ SimulatorName = "redstone";
+ }
+
+ cRedstoneManager * res = NULL;
+
+ if (
+ (NoCaseCompare(SimulatorName, "redstone") == 0)
+ )
+ {
+ res = new cRedstoneSimulator(*this);
+ }
+ else if (
+ (NoCaseCompare(SimulatorName, "noop") == 0)
+ )
+ {
+ res = new cRedstoneNoopSimulator(*this);
+ }
+
+ m_SimulatorManager->RegisterSimulator(res, 1);
+
+ return res;
+}
+
+
+
+
+
cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock)
{
AString SimulatorNameKey;
diff --git a/src/World.h b/src/World.h
index 8cf860ff5..bc4e411cc 100644
--- a/src/World.h
+++ b/src/World.h
@@ -33,7 +33,7 @@
class cFireSimulator;
class cFluidSimulator;
class cSandSimulator;
-class cRedstoneSimulator;
+class cRedstoneManager;
class cItem;
class cPlayer;
class cClientHandle;
@@ -432,7 +432,7 @@ public:
inline cFluidSimulator * GetWaterSimulator(void) { return m_WaterSimulator; }
inline cFluidSimulator * GetLavaSimulator (void) { return m_LavaSimulator; }
- inline cRedstoneSimulator * GetRedstoneSimulator(void) { return m_RedstoneSimulator; }
+ inline cRedstoneManager * GetRedstoneSimulator(void) { return m_RedstoneSimulator; }
/** Calls the callback for each block entity in the specified chunk; returns true if all block entities processed, false if the callback aborted by returning true */
bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback & a_Callback); // Exported in ManualBindings.cpp
@@ -759,7 +759,7 @@ private:
cFluidSimulator * m_WaterSimulator;
cFluidSimulator * m_LavaSimulator;
cFireSimulator * m_FireSimulator;
- cRedstoneSimulator * m_RedstoneSimulator;
+ cRedstoneManager * m_RedstoneSimulator;
cCriticalSection m_CSPlayers;
cPlayerList m_Players;
@@ -858,6 +858,9 @@ private:
/** Creates a new fluid simulator, loads its settings from the inifile (a_FluidName section) */
cFluidSimulator * InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock);
+
+ /** Creates a new redstone simulator.*/
+ cRedstoneManager * InitializeRedstoneSimulator(cIniFile & a_IniFile);
}; // tolua_export