summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-31 23:17:49 +0200
committermadmaxoft <github@xoft.cz>2014-07-31 23:17:49 +0200
commit6d02fce9a26d4272baea08dc58238321cca0183a (patch)
tree0109076ae52c67513259d7946a44b9f7b5a563fb /src/Root.cpp
parentRemoved trailing whitespace. (diff)
parentMerge pull request #1267 from mc-server/RoofedForest (diff)
downloadcuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.gz
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.bz2
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.lz
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.xz
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.zst
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.zip
Diffstat (limited to 'src/Root.cpp')
-rw-r--r--src/Root.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index 7d4fb80fd..c20cf0d21 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -270,12 +270,12 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
{
// First get the default world
AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "world");
- m_pDefaultWorld = new cWorld( DefaultWorldName.c_str());
+ m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
// Then load the other worlds
unsigned int KeyNum = IniFile.FindKey("Worlds");
- unsigned int NumWorlds = IniFile.GetNumValues( KeyNum);
+ unsigned int NumWorlds = IniFile.GetNumValues(KeyNum);
if (NumWorlds <= 0)
{
return;
@@ -313,13 +313,15 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
-cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName)
+cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName)
{
- if (m_WorldsByName[a_WorldName] != NULL)
+ cWorld * World = m_WorldsByName[a_WorldName];
+ if (World != NULL)
{
- return NULL;
+ return World;
}
- cWorld* NewWorld = new cWorld(a_WorldName.c_str());
+
+ cWorld * NewWorld = new cWorld(a_WorldName.c_str(), a_Dimension, a_OverworldName);
m_WorldsByName[a_WorldName] = NewWorld;
NewWorld->Start();
NewWorld->InitializeSpawn();
@@ -371,7 +373,7 @@ void cRoot::UnloadWorlds(void)
-cWorld* cRoot::GetDefaultWorld()
+cWorld * cRoot::GetDefaultWorld()
{
return m_pDefaultWorld;
}
@@ -380,12 +382,19 @@ cWorld* cRoot::GetDefaultWorld()
-cWorld* cRoot::GetWorld( const AString & a_WorldName)
+cWorld * cRoot::GetWorld(const AString & a_WorldName, bool a_SearchForFolder)
{
- WorldMap::iterator itr = m_WorldsByName.find( a_WorldName);
+ WorldMap::iterator itr = m_WorldsByName.find(a_WorldName);
if (itr != m_WorldsByName.end())
+ {
return itr->second;
- return 0;
+ }
+
+ if (a_SearchForFolder && cFile::IsFolder(FILE_IO_PREFIX + a_WorldName))
+ {
+ return CreateAndInitializeWorld(a_WorldName);
+ }
+ return NULL;
}
@@ -397,9 +406,12 @@ bool cRoot::ForEachWorld(cWorldListCallback & a_Callback)
for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2)
{
++itr2;
- if (a_Callback.Item(itr->second))
+ if (itr->second != NULL)
{
- return false;
+ if (a_Callback.Item(itr->second))
+ {
+ return false;
+ }
}
}
return true;