summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Entity.cpp14
-rw-r--r--src/Entities/Player.cpp2
-rw-r--r--src/Root.cpp29
-rw-r--r--src/Root.h13
4 files changed, 14 insertions, 44 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index b207e79c9..d0540b4eb 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1392,7 +1392,8 @@ bool cEntity::DetectPortal()
TargetPos.x *= 8.0;
TargetPos.z *= 8.0;
- cWorld * TargetWorld = cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName(), dimNether, GetWorld()->GetName(), true);
+ cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName());
+ ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start()
LOGD("Jumping nether -> overworld");
new cNetherPortalScanner(this, TargetWorld, TargetPos, 256);
return true;
@@ -1416,7 +1417,8 @@ bool cEntity::DetectPortal()
TargetPos.x /= 8.0;
TargetPos.z /= 8.0;
- cWorld * TargetWorld = cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedNetherWorldName(), dimNether, GetWorld()->GetName(), true);
+ cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedNetherWorldName());
+ ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start()
LOGD("Jumping overworld -> nether");
new cNetherPortalScanner(this, TargetWorld, TargetPos, 128);
return true;
@@ -1446,7 +1448,9 @@ bool cEntity::DetectPortal()
Player->GetClientHandle()->SendRespawn(dimOverworld);
}
- return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false);
+ cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName());
+ ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start()
+ return MoveToWorld(TargetWorld, false);
}
else
{
@@ -1463,7 +1467,9 @@ bool cEntity::DetectPortal()
reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(dimEnd);
}
- return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedEndWorldName(), dimEnd, GetWorld()->GetName()), false);
+ cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedEndWorldName());
+ ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start()
+ return MoveToWorld(TargetWorld, false);
}
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 5606e9668..b7f6f4d05 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1871,7 +1871,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents);
m_LoadedWorldName = root.get("world", "world").asString();
- a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false);
+ a_World = cRoot::Get()->GetWorld(GetLoadedWorldName());
if (a_World == nullptr)
{
a_World = cRoot::Get()->GetDefaultWorld();
diff --git a/src/Root.cpp b/src/Root.cpp
index 1a39b09a5..4ada5c196 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -510,29 +510,6 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
-cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName, bool a_InitSpawn)
-{
- cWorld * World = m_WorldsByName[a_WorldName];
- if (World != nullptr)
- {
- return World;
- }
-
- cWorld * NewWorld = new cWorld(a_WorldName.c_str(), a_Dimension, a_OverworldName);
- m_WorldsByName[a_WorldName] = NewWorld;
- NewWorld->Start();
- if (a_InitSpawn)
- {
- NewWorld->InitializeSpawn();
- }
- m_PluginManager->CallHookWorldStarted(*NewWorld);
- return NewWorld;
-}
-
-
-
-
-
void cRoot::StartWorlds(void)
{
for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
@@ -582,7 +559,7 @@ cWorld * cRoot::GetDefaultWorld()
-cWorld * cRoot::GetWorld(const AString & a_WorldName, bool a_SearchForFolder)
+cWorld * cRoot::GetWorld(const AString & a_WorldName)
{
WorldMap::iterator itr = m_WorldsByName.find(a_WorldName);
if (itr != m_WorldsByName.end())
@@ -590,10 +567,6 @@ cWorld * cRoot::GetWorld(const AString & a_WorldName, bool a_SearchForFolder)
return itr->second;
}
- if (a_SearchForFolder && cFile::IsFolder(FILE_IO_PREFIX + a_WorldName))
- {
- return CreateAndInitializeWorld(a_WorldName);
- }
return nullptr;
}
diff --git a/src/Root.h b/src/Root.h
index 2ce0e7c32..24c8216d9 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -64,17 +64,8 @@ public:
cServer * GetServer(void) { return m_Server; }
cWorld * GetDefaultWorld(void);
- /** Returns a pointer to the world specified
- If no world of that name was currently loaded and a_SearchForFolder was true, it will consult cFile::IsFolder() to see if a world folder of that name exists and if so, initialise a world based on that name
- */
- 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
- */
- cWorld * CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = "", bool a_InitSpawn = true);
+ /** Returns a pointer to the world specified. If no world of that name exists, returns a nullptr. */
+ cWorld * GetWorld(const AString & a_WorldName);
/** Returns the up time of the server in seconds */
int GetServerUpTime(void)