diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-13 11:53:28 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-13 11:53:28 +0200 |
commit | f7da7c2536b438db92bc28b88c4139d9af15e44f (patch) | |
tree | 4710e9e41ebcf2317ebacade2801732ba9184b41 /source/World.cpp | |
parent | ProtoProxy: Fixed parsing of the PACKET_PLAYER_ABILITIES packet. (diff) | |
download | cuberite-f7da7c2536b438db92bc28b88c4139d9af15e44f.tar cuberite-f7da7c2536b438db92bc28b88c4139d9af15e44f.tar.gz cuberite-f7da7c2536b438db92bc28b88c4139d9af15e44f.tar.bz2 cuberite-f7da7c2536b438db92bc28b88c4139d9af15e44f.tar.lz cuberite-f7da7c2536b438db92bc28b88c4139d9af15e44f.tar.xz cuberite-f7da7c2536b438db92bc28b88c4139d9af15e44f.tar.zst cuberite-f7da7c2536b438db92bc28b88c4139d9af15e44f.zip |
Diffstat (limited to 'source/World.cpp')
-rw-r--r-- | source/World.cpp | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/source/World.cpp b/source/World.cpp index 7180213fe..f932c7c04 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -12,12 +12,14 @@ #include "Root.h" #include "../iniFile/iniFile.h" #include "ChunkMap.h" -#include "SimulatorManager.h" -#include "WaterSimulator.h" -#include "LavaSimulator.h" -#include "FireSimulator.h" -#include "SandSimulator.h" -#include "RedstoneSimulator.h" + +// Simulators: +#include "Simulator/SimulatorManager.h" +#include "Simulator/ClassicFluidSimulator.h" +#include "Simulator/FluidSimulator.h" +#include "Simulator/FireSimulator.h" +#include "Simulator/SandSimulator.h" +#include "Simulator/RedstoneSimulator.h" // Mobs: #include "Mobs/Chicken.h" @@ -288,11 +290,11 @@ cWorld::cWorld( const AString & a_WorldName ) m_BlockTickQueue.reserve(1000); m_BlockTickQueueCopy.reserve(1000); - //Simulators: - m_WaterSimulator = new cWaterSimulator( this ); - m_LavaSimulator = new cLavaSimulator( this ); - m_SandSimulator = new cSandSimulator(this); - m_FireSimulator = new cFireSimulator(this); + // Simulators: + m_WaterSimulator = InitializeFluidSimulator(IniFile, "Water", E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER); + m_LavaSimulator = InitializeFluidSimulator(IniFile, "Lava", E_BLOCK_LAVA, E_BLOCK_STATIONARY_LAVA); + m_SandSimulator = new cSandSimulator(this); + m_FireSimulator = new cFireSimulator(this); m_RedstoneSimulator = new cRedstoneSimulator(this); m_SimulatorManager = new cSimulatorManager(); @@ -2153,3 +2155,44 @@ bool cWorld::IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ) +cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock) +{ + AString SimulatorNameKey; + Printf(SimulatorNameKey, "%sSimulator", a_FluidName); + AString SimulatorSectionName; + Printf(SimulatorSectionName, "%sSimulator", a_FluidName); + AString SimulatorName = a_IniFile.GetValue("Physics", SimulatorNameKey, ""); + if (SimulatorName.empty()) + { + LOGWARNING("%s [Physics]:%s not present or empty, using the default of \"Classic\".", GetIniFileName().c_str(), SimulatorNameKey.c_str()); + SimulatorName = "Classic"; + } + + cFluidSimulator * res = NULL; + /* + // TODO: other fluid simulators + if (NoCaseCompare(SimulatorName, "floody") == 0) + { + // TODO: Floody simulator params + res = new cFloodyFluidSimulator(this, a_SimulateBlock, a_StationaryBlock); + } + else + */ + { + if (NoCaseCompare(SimulatorName, "classic") != 0) + { + // The simulator name doesn't match anything we have, issue a warning: + LOGWARNING("%s [Physics]:%s specifies an unknown simulator, using the default \"Classic\".", GetIniFileName().c_str(), SimulatorNameKey.c_str()); + } + int DefaultFalloff = (strcmp(a_FluidName, "Water") == 0) ? 1 : 2; + int DefaultMaxHeight = (strcmp(a_FluidName, "Water") == 0) ? 7 : 6; + int Falloff = a_IniFile.GetValueI(SimulatorSectionName, "Falloff", DefaultFalloff); + int MaxHeight = a_IniFile.GetValueI(SimulatorSectionName, "MaxHeight", DefaultMaxHeight); + res = new cClassicFluidSimulator(this, a_SimulateBlock, a_StationaryBlock, MaxHeight, Falloff); + } + + return res; +} + + + |