diff options
author | Safwat Halaby <SafwatHalaby@users.noreply.github.com> | 2015-12-25 13:25:20 +0100 |
---|---|---|
committer | Safwat Halaby <SafwatHalaby@users.noreply.github.com> | 2015-12-25 13:59:54 +0100 |
commit | 74912a2aafc4714161abd990e3fc731d958e352a (patch) | |
tree | e62f05944af6767ee4ec01fc86bf08c6ab48c706 /src | |
parent | Merge pull request #2815 from SafwatHalaby/world (diff) | |
download | cuberite-74912a2aafc4714161abd990e3fc731d958e352a.tar cuberite-74912a2aafc4714161abd990e3fc731d958e352a.tar.gz cuberite-74912a2aafc4714161abd990e3fc731d958e352a.tar.bz2 cuberite-74912a2aafc4714161abd990e3fc731d958e352a.tar.lz cuberite-74912a2aafc4714161abd990e3fc731d958e352a.tar.xz cuberite-74912a2aafc4714161abd990e3fc731d958e352a.tar.zst cuberite-74912a2aafc4714161abd990e3fc731d958e352a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Root.cpp | 50 | ||||
-rw-r--r-- | src/Root.h | 2 |
2 files changed, 49 insertions, 3 deletions
diff --git a/src/Root.cpp b/src/Root.cpp index 99dabc099..36fd067b3 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -347,7 +347,6 @@ void cRoot::LoadGlobalSettings() void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile) { // First get the default world - AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world"); if (a_IsNewIniFile) { a_Settings.AddValue("Worlds", "World", "world_nether"); @@ -359,11 +358,58 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn return; } + AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world"); m_pDefaultWorld = new cWorld(DefaultWorldName.c_str()); m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld; + auto Worlds = a_Settings.GetValues("Worlds"); + + // Fix servers that have default world configs created prior to #2815. See #2810. + // This can probably be removed several years after 2016 + // We start by inspecting the world linkage and determining if it's the default one + if (DefaultWorldName == "world") + { + auto DefaultWorldIniFile= cpp14::make_unique<cIniFile>(); + assert(DefaultWorldIniFile->ReadFile("world/world.ini")); + AString NetherName = DefaultWorldIniFile->GetValue("LinkedWorlds", "NetherWorldName", ""); + AString EndName = DefaultWorldIniFile->GetValue("LinkedWorlds", "EndWorldName", ""); + if ((NetherName.compare("world_nether") == 0) && (EndName.compare("world_end") == 0)) + { + // This is a default world linkage config, see if the nether and end are in settings.ini + // If both of them are not in settings.ini, then this is a pre-#2815 default config + // so we add them to settings.ini + // Note that if only one of them is not in settings.ini, it's nondefault and we don't touch it + + bool NetherInSettings = false; + bool EndInSettings = false; + + for (auto WorldNameValue : Worlds) + { + AString ValueName = WorldNameValue.first; + if (ValueName.compare("World") != 0) + { + continue; + } + AString WorldName = WorldNameValue.second; + if (WorldName.compare("world_nether") == 0) + { + NetherInSettings = true; + } + else if (WorldName.compare("world_end") == 0) + { + EndInSettings = true; + } + } + + if ((!NetherInSettings) && (!EndInSettings)) + { + a_Settings.AddValue("Worlds", "World", "world_nether"); + a_Settings.AddValue("Worlds", "World", "world_end"); + Worlds = a_Settings.GetValues("Worlds"); // Refresh the Worlds list so that the rest of the function works as usual + } + } + } // Then load the other worlds - auto Worlds = a_Settings.GetValues("Worlds"); if (Worlds.size() <= 0) { return; diff --git a/src/Root.h b/src/Root.h index 064752ab4..261dac29f 100644 --- a/src/Root.h +++ b/src/Root.h @@ -224,7 +224,7 @@ private: void LoadGlobalSettings(); /** Loads the worlds from settings.ini, creates the worldmap */ - void LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_NewIniFile); + void LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile); /** Starts each world's life */ void StartWorlds(void); |