1
0

Fixed crash introduced by #2821

This commit is contained in:
LogicParrot 2016-01-12 15:13:53 +02:00
parent d4e99aedb1
commit 41f2b6c99f

View File

@ -369,42 +369,44 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
if (DefaultWorldName == "world") if (DefaultWorldName == "world")
{ {
auto DefaultWorldIniFile= cpp14::make_unique<cIniFile>(); auto DefaultWorldIniFile= cpp14::make_unique<cIniFile>();
assert(DefaultWorldIniFile->ReadFile("world/world.ini")); if (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 AString NetherName = DefaultWorldIniFile->GetValue("LinkedWorlds", "NetherWorldName", "");
// If both of them are not in settings.ini, then this is a pre-#2815 default config AString EndName = DefaultWorldIniFile->GetValue("LinkedWorlds", "EndWorldName", "");
// so we add them to settings.ini if ((NetherName.compare("world_nether") == 0) && (EndName.compare("world_end") == 0))
// 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; // This is a default world linkage config, see if the nether and end are in settings.ini
if (ValueName.compare("World") != 0) // If both of them are not in settings.ini, then this is a pre-#2815 default config
{ // so we add them to settings.ini
continue; // Note that if only one of them is not in settings.ini, it's nondefault and we don't touch it
}
AString WorldName = WorldNameValue.second;
if (WorldName.compare("world_nether") == 0)
{
NetherInSettings = true;
}
else if (WorldName.compare("world_end") == 0)
{
EndInSettings = true;
}
}
if ((!NetherInSettings) && (!EndInSettings)) bool NetherInSettings = false;
{ bool EndInSettings = false;
a_Settings.AddValue("Worlds", "World", "world_nether");
a_Settings.AddValue("Worlds", "World", "world_end"); for (auto WorldNameValue : Worlds)
Worlds = a_Settings.GetValues("Worlds"); // Refresh the Worlds list so that the rest of the function works as usual {
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
}
} }
} }
} }