summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp78
1 files changed, 74 insertions, 4 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 6bcd1391a..6904000ea 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -66,6 +66,9 @@ const int TIME_NIGHT_END = 22812;
const int TIME_SUNRISE = 23999;
const int TIME_SPAWN_DIVISOR = 148;
+#define DEFAULT_NETHER_NAME GetName() + "_nether"
+#define DEFAULT_END_NAME GetName() + "_end"
+
@@ -229,7 +232,7 @@ void cWorld::cTickThread::Execute(void)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cWorld:
-cWorld::cWorld(const AString & a_WorldName) :
+cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName) :
m_WorldName(a_WorldName),
m_IniFileName(m_WorldName + "/world.ini"),
m_StorageSchema("Default"),
@@ -250,7 +253,9 @@ cWorld::cWorld(const AString & a_WorldName) :
m_Scoreboard(this),
m_MapManager(this),
m_GeneratorCallbacks(*this),
- m_TickThread(*this)
+ m_TickThread(*this),
+ m_Dimension(a_Dimension),
+ m_OverworldName(a_OverworldName)
{
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
@@ -508,7 +513,7 @@ void cWorld::InitializeSpawn(void)
-void cWorld::Start(void)
+void cWorld::Start(bool a_WasDimensionSet)
{
m_SpawnX = 0;
m_SpawnY = cChunkDef::Height;
@@ -520,8 +525,10 @@ void cWorld::Start(void)
{
LOGWARNING("Cannot read world settings from \"%s\", defaults will be used.", m_IniFileName.c_str());
}
- AString Dimension = IniFile.GetValueSet("General", "Dimension", "Overworld");
+
+ AString Dimension = IniFile.GetValueSet("General", "Dimension", a_WasDimensionSet ? DimensionToString(GetDimension()) : "Overworld");
m_Dimension = StringToDimension(Dimension);
+ m_OverworldName = IniFile.GetValue("General", "OverworldName", a_WasDimensionSet ? m_OverworldName : "");
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
int KeyNum = IniFile.FindKey("SpawnPosition");
@@ -566,10 +573,52 @@ void cWorld::Start(void)
m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true);
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);
+ int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather);
+ m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay);
+
+ if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
+ {
+ m_bNetherPortalsEnabled = IniFile.GetValueSetB("General", "NetherPortalsEnabled", true);
+ m_NetherWorldName = IniFile.GetValueSet("General", "NetherWorldName", DEFAULT_NETHER_NAME);
+ m_bEndPortalsEnabled = IniFile.GetValueSetB("General", "EndPortalsEnabled", true);
+ m_EndWorldName = IniFile.GetValueSet("General", "EndWorldName", DEFAULT_END_NAME);
+ }
// Adjust the enum-backed variables into their respective bounds:
m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure);
m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
+ m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm);
+
+ switch (GetDimension())
+ {
+ case dimEnd:
+ {
+ IniFile.GetValueSet("Generator", "BiomeGen", "Constant");
+ IniFile.GetValueSet("Generator", "ConstantBiome", "End");
+ IniFile.GetValueSet("Generator", "HeightGen", "Biomal");
+ IniFile.GetValueSet("Generator", "CompositionGen", "End");
+ break;
+ }
+ case dimOverworld:
+ {
+ IniFile.GetValueSet("Generator", "BiomeGen", "MultiStepMap");
+ IniFile.GetValueSet("Generator", "HeightGen", "DistortedHeightmap");
+ IniFile.GetValueSet("Generator", "CompositionGen", "DistortedHeightmap");
+ IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, WaterSprings, LavaLakes, LavaSprings, OreNests, Mineshafts, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator");
+ break;
+ }
+ case dimNether:
+ {
+ IniFile.GetValueSet("Generator", "BiomeGen", "Constant");
+ IniFile.GetValueSet("Generator", "ConstantBiome", "Nether");
+ IniFile.GetValueSet("Generator", "HeightGen", "Flat");
+ IniFile.GetValueSet("Generator", "FlatHeight", "128");
+ IniFile.GetValueSet("Generator", "CompositionGen", "Nether");
+ IniFile.GetValueSet("Generator", "Finishers", "WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator");
+ IniFile.GetValueSet("Generator", "BottomLavaHeight", "30");
+ break;
+ }
+ }
// Load allowed mobs:
const char * DefaultMonsters = "";
@@ -703,6 +752,27 @@ void cWorld::Stop(void)
} // for itr - m_Clients[]
m_Clients.clear();
}
+
+ // Write settings to file; these are all plugin changeable values - keep updated!
+ cIniFile IniFile;
+ IniFile.ReadFile(m_IniFileName);
+ if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
+ {
+ IniFile.SetValueB("General", "NetherPortalsEnabled", m_bNetherPortalsEnabled);
+ IniFile.SetValue("General", "NetherWorldName", m_NetherWorldName);
+ IniFile.SetValueB("General", "EndPortalsEnabled", m_bEndPortalsEnabled);
+ IniFile.SetValue("General", "EndWorldName", m_EndWorldName);
+ }
+ else
+ {
+ IniFile.SetValue("General", "OverworldName", m_OverworldName);
+ }
+ IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel);
+ IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled);
+ IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes);
+ IniFile.SetValueI("General", "Weather", (int)m_Weather);
+ IniFile.SetValueI("General", "TimeInTicks", m_TimeOfDay);
+ IniFile.WriteFile(m_IniFileName);
m_TickThread.Stop();
m_Lighting.Stop();