summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-08 10:57:42 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-08 10:57:42 +0100
commit8fd2cb5db2498e4618472322706c1fdaea6b03bb (patch)
tree46b27425e0aeecd1ce13cc7d5832921abf435d4d /src
parentMerge pull request #2969 from LogicParrot/ini (diff)
parentProper world linkages and dimension types for newly created world.ini's (diff)
downloadcuberite-8fd2cb5db2498e4618472322706c1fdaea6b03bb.tar
cuberite-8fd2cb5db2498e4618472322706c1fdaea6b03bb.tar.gz
cuberite-8fd2cb5db2498e4618472322706c1fdaea6b03bb.tar.bz2
cuberite-8fd2cb5db2498e4618472322706c1fdaea6b03bb.tar.lz
cuberite-8fd2cb5db2498e4618472322706c1fdaea6b03bb.tar.xz
cuberite-8fd2cb5db2498e4618472322706c1fdaea6b03bb.tar.zst
cuberite-8fd2cb5db2498e4618472322706c1fdaea6b03bb.zip
Diffstat (limited to 'src')
-rw-r--r--src/Root.cpp60
-rw-r--r--src/World.cpp14
2 files changed, 71 insertions, 3 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index 737d350ff..07b7ddb60 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -409,6 +409,28 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
return;
}
+ /* Here are the world creation rules. Note that these only apply for a world which is in settings.ini but has no world.ini file.
+ If an ini file is present, it overrides the world linkages and the dimension type in cWorld::start()
+ The creation rules are as follows:
+
+ - If a world exists in settings.ini but has no world.ini, then:
+ - If the world name is x_nether, create a world.ini with the dimension type "nether".
+ - If a world called x exists, set it as x_nether's overworld.
+ - Otherwise set the default world as x_nether's overworld.
+
+ - If the world name is x_end, create a world.ini with the dimension type "end".
+ - If a world called x exists, set it as x_end's overworld.
+ - Otherwise set the default world as x_end's overworld.
+
+ - If the world name is x (and doesn't end with _end or _nether)
+ - Create a world.ini with a dimension type of "overworld".
+ - If a world called x_nether exists, set it as x's nether world.
+ - Otherwise set x's nether world to blank.h
+ - If a world called x_end exists, set it as x's end world.
+ - Otherwise set x's nether world to blank.
+
+ */
+
bool FoundAdditionalWorlds = false;
for (auto WorldNameValue : Worlds)
{
@@ -423,7 +445,43 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
continue;
}
FoundAdditionalWorlds = true;
- cWorld * NewWorld = new cWorld(WorldName.c_str());
+ cWorld * NewWorld;
+ AString LowercaseName = StrToLower(WorldName);
+ AString NetherAppend="_nether";
+ AString EndAppend="_end";
+
+ // if the world is called x_nether
+ if ((LowercaseName.size() > NetherAppend.size()) && (LowercaseName.substr(LowercaseName.size() - NetherAppend.size()) == NetherAppend))
+ {
+ // The world is called x_nether, see if a world called x exists. If yes, choose it as the linked world,
+ // otherwise, choose the default world as the linked world.
+ // As before, any ini settings will completely override this if an ini is already present.
+
+ AString LinkTo = WorldName.substr(0, WorldName.size() - NetherAppend.size());
+ if (GetWorld(LinkTo) == nullptr)
+ {
+ LinkTo = DefaultWorldName;
+ }
+ NewWorld = new cWorld(WorldName.c_str(), dimNether, LinkTo);
+ }
+ // if the world is called x_end
+ else if ((LowercaseName.size() > EndAppend.size()) && (LowercaseName.substr(LowercaseName.size() - EndAppend.size()) == EndAppend))
+ {
+ // The world is called x_end, see if a world called x exists. If yes, choose it as the linked world,
+ // otherwise, choose the default world as the linked world.
+ // As before, any ini settings will completely override this if an ini is already present.
+
+ AString LinkTo = WorldName.substr(0, WorldName.size() - EndAppend.size());
+ if (GetWorld(LinkTo) == nullptr)
+ {
+ LinkTo = DefaultWorldName;
+ }
+ NewWorld = new cWorld(WorldName.c_str(), dimEnd, LinkTo);
+ }
+ else
+ {
+ NewWorld = new cWorld(WorldName.c_str());
+ }
m_WorldsByName[WorldName] = NewWorld;
} // for i - Worlds
diff --git a/src/World.cpp b/src/World.cpp
index 127621069..fa9b7f966 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -512,8 +512,18 @@ void cWorld::Start(void)
if (GetDimension() == dimOverworld)
{
- m_LinkedNetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", GetName() + "_nether");
- m_LinkedEndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", GetName() + "_end");
+ AString MyNetherName = GetName() + "_nether";
+ AString MyEndName = GetName() + "_end";
+ if (cRoot::Get()->GetWorld(MyNetherName) == nullptr)
+ {
+ MyNetherName = "";
+ }
+ if (cRoot::Get()->GetWorld(MyEndName) == nullptr)
+ {
+ MyEndName = "";
+ }
+ m_LinkedNetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", MyNetherName);
+ m_LinkedEndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", MyEndName);
}
else
{