summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 127621069..c704b46bb 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -512,14 +512,58 @@ 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
{
m_LinkedOverworldName = IniFile.GetValueSet("LinkedWorlds", "OverworldName", GetLinkedOverworldName());
}
+ // If we are linked to one or more worlds that do not exist, ask the server to stop.
+ AString BadWorlds = "";
+ cRoot * Root = cRoot::Get();
+ if (GetDimension() == dimOverworld)
+ {
+ if ((!m_LinkedNetherWorldName.empty()) && (Root->GetWorld(m_LinkedNetherWorldName) == nullptr))
+ {
+ BadWorlds = m_LinkedNetherWorldName;
+ }
+ if ((!m_LinkedEndWorldName.empty()) && (Root->GetWorld(m_LinkedEndWorldName) == nullptr))
+ {
+ if (!(BadWorlds.empty()))
+ {
+ BadWorlds += ", ";
+ }
+ BadWorlds += m_LinkedEndWorldName;
+ }
+ }
+ else
+ {
+ if ((!m_LinkedOverworldName.empty()) && (Root->GetWorld(m_LinkedOverworldName) == nullptr))
+ {
+ BadWorlds = m_LinkedOverworldName;
+ }
+ }
+ if (!BadWorlds.empty())
+ {
+ const char * WorldName = m_WorldName.c_str();
+ LOGERROR("\n###### ERROR: \"%s\" is linked to the following nonexisting world/s:\n%s\n\nPlease edit %s/world.ini and fix this.\n\nNote that the server started enforcing proper world linkages recently. And people with older configs may naturally get this error. If you just want a working default config and don't mind losing this world, delete the folder \"%s\" and the server will receate one for you. Otherwise edit the world.ini file and fix the invalid linkages.\n\nMore help and info:\nhttps://forum.cuberite.org/thread-2366.html\n######\n",
+ WorldName, BadWorlds.c_str(), WorldName, WorldName);
+ cRoot::Get()->StopServer();
+ }
+
+
// Adjust the enum-backed variables into their respective bounds:
m_GameMode = static_cast<eGameMode> (Clamp<int>(GameMode, gmSurvival, gmSpectator));
m_TNTShrapnelLevel = static_cast<eShrapnelLevel>(Clamp<int>(TNTShrapnelLevel, slNone, slAll));