remove cWorld::createAndInitializeWorld
This commit is contained in:
parent
ed97946bb9
commit
3efdfca61d
@ -2126,7 +2126,6 @@ a_Player:OpenWindow(Window);
|
||||
BroadcastChatLeave = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtLeave. Use for players leaving the server." },
|
||||
BroadcastChatSuccess = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtSuccess. Use for success messages." },
|
||||
BroadcastChatWarning = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtWarning. Use for concerning events, such as plugin reload etc." },
|
||||
CreateAndInitializeWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Creates a new world and initializes it. If there is a world whith the same name it returns nil.<br><br><b>NOTE:</b> This function is currently unsafe, do not use!" },
|
||||
FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "bool", Notes = "Calls the given callback function for the player with the name best matching the name string provided.<br>This function is case-insensitive and will match partial names.<br>Returns false if player not found or there is ambiguity, true otherwise. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|Player}})</pre>" },
|
||||
DoWithPlayerByUUID = { Params = "PlayerUUID, CallbackFunction", Return = "bool", Notes = "If there is the player with the uuid, calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|Player}})</pre> The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." },
|
||||
ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|cPlayer}})</pre>" },
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
29
src/Root.cpp
29
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;
|
||||
}
|
||||
|
||||
|
13
src/Root.h
13
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)
|
||||
|
Loading…
Reference in New Issue
Block a user