summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-24 15:53:36 +0100
committerSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-25 12:49:13 +0100
commitb4649248d12863a5898f805d48ab4361b9c61b26 (patch)
tree69869ac74b44c4fc4d852ccb73a8d4c02c112f9c /src
parentMerge pull request #2816 from SafwatHalaby/redstone (diff)
downloadcuberite-b4649248d12863a5898f805d48ab4361b9c61b26.tar
cuberite-b4649248d12863a5898f805d48ab4361b9c61b26.tar.gz
cuberite-b4649248d12863a5898f805d48ab4361b9c61b26.tar.bz2
cuberite-b4649248d12863a5898f805d48ab4361b9c61b26.tar.lz
cuberite-b4649248d12863a5898f805d48ab4361b9c61b26.tar.xz
cuberite-b4649248d12863a5898f805d48ab4361b9c61b26.tar.zst
cuberite-b4649248d12863a5898f805d48ab4361b9c61b26.zip
Diffstat (limited to 'src')
-rw-r--r--src/Root.cpp20
-rw-r--r--src/Root.h2
2 files changed, 18 insertions, 4 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index 1fbbaed3c..99dabc099 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -143,13 +143,16 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
LOG("Reading server config...");
auto IniFile = cpp14::make_unique<cIniFile>();
- if (!IniFile->ReadFile("settings.ini"))
+ bool IsNewIniFile = !IniFile->ReadFile("settings.ini");
+
+ if (IsNewIniFile)
{
LOGWARN("Regenerating settings.ini, all settings will be reset");
IniFile->AddHeaderComment(" This is the main server configuration");
IniFile->AddHeaderComment(" Most of the settings here can be configured using the webadmin interface, if enabled in webadmin.ini");
IniFile->AddHeaderComment(" See: http://wiki.mc-server.org/doku.php?id=configure:settings.ini for further configuration help");
}
+
auto settingsRepo = cpp14::make_unique<cOverridesSettingsRepository>(std::move(IniFile), std::move(a_OverridesRepo));
LOG("Starting server...");
@@ -174,7 +177,7 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
m_BrewingRecipes.reset(new cBrewingRecipes());
LOGD("Loading worlds...");
- LoadWorlds(*settingsRepo);
+ LoadWorlds(*settingsRepo, IsNewIniFile);
LOGD("Loading plugin manager...");
m_PluginManager = new cPluginManager();
@@ -341,10 +344,21 @@ void cRoot::LoadGlobalSettings()
-void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings)
+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");
+ a_Settings.AddValue("Worlds", "World", "world_end");
+ m_pDefaultWorld = new cWorld("world");
+ m_WorldsByName["world"] = m_pDefaultWorld;
+ m_WorldsByName["world_nether"] = new cWorld("world_nether", dimNether, "world");
+ m_WorldsByName["world_end"] = new cWorld("world_end", dimEnd, "world");
+ return;
+ }
+
m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
diff --git a/src/Root.h b/src/Root.h
index 142b323a5..064752ab4 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);
+ void LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_NewIniFile);
/** Starts each world's life */
void StartWorlds(void);