summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-08 10:57:57 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-08 10:57:57 +0100
commited97946bb946bae2caf8f7dd963a75dceddfcc86 (patch)
tree6df0a1f27e4db9f9a790d1105246ba658be6b571 /src
parentMerge pull request #2953 from LogicParrot/worldRebuild (diff)
parentPrevent server from starting if there's bad world linkage (diff)
downloadcuberite-ed97946bb946bae2caf8f7dd963a75dceddfcc86.tar
cuberite-ed97946bb946bae2caf8f7dd963a75dceddfcc86.tar.gz
cuberite-ed97946bb946bae2caf8f7dd963a75dceddfcc86.tar.bz2
cuberite-ed97946bb946bae2caf8f7dd963a75dceddfcc86.tar.lz
cuberite-ed97946bb946bae2caf8f7dd963a75dceddfcc86.tar.xz
cuberite-ed97946bb946bae2caf8f7dd963a75dceddfcc86.tar.zst
cuberite-ed97946bb946bae2caf8f7dd963a75dceddfcc86.zip
Diffstat (limited to 'src')
-rw-r--r--src/Root.cpp15
-rw-r--r--src/Root.h4
-rw-r--r--src/World.cpp34
3 files changed, 50 insertions, 3 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index 07b7ddb60..1a39b09a5 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -327,6 +327,17 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
+void cRoot::StopServer()
+{
+ m_TerminateEventRaised = true;
+ m_StopEvent.Set();
+ m_InputThreadRunFlag.clear();
+}
+
+
+
+
+
void cRoot::LoadGlobalSettings()
{
// Nothing needed yet
@@ -655,9 +666,7 @@ void cRoot::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback
// Some commands are built-in:
if (a_Cmd == "stop")
{
- m_TerminateEventRaised = true;
- m_StopEvent.Set();
- m_InputThreadRunFlag.clear();
+ StopServer();
return;
}
else if (a_Cmd == "restart")
diff --git a/src/Root.h b/src/Root.h
index 261dac29f..2ce0e7c32 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -57,6 +57,9 @@ public:
void Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo);
+ /** Stops the server, as if "/stop" was typed in the console. */
+ void StopServer();
+
// tolua_begin
cServer * GetServer(void) { return m_Server; }
cWorld * GetDefaultWorld(void);
@@ -66,6 +69,7 @@ public:
*/
cWorld * GetWorld(const AString & a_WorldName, bool a_SearchForFolder = false);
+
/** Returns a pointer to a world of specified name - will search loaded worlds first, then create anew if not found
The dimension parameter is used to create a world with a specific dimension
a_OverworldName should be set for non-overworld dimensions if one wishes that world to link back to an overworld via portals
diff --git a/src/World.cpp b/src/World.cpp
index fa9b7f966..0cb2615ef 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -530,6 +530,40 @@ void cWorld::Start(void)
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######\nERROR: %s is linked to one or more invalid worlds: %s\nPlease edit %s/world.ini and fix this.\n######\n",
+ WorldName, BadWorlds.c_str(), 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));