summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
authorHaoTNN <haotnn@gmail.com>2015-06-03 01:08:57 +0200
committerHaoTNN <haotnn@gmail.com>2015-06-03 01:08:57 +0200
commit3142598dee31acc23c738a1a728638665c8940b8 (patch)
tree2eb837ed785678d536d677ff5020fabca089f2e5 /src/Root.cpp
parentMerge remote-tracking branch 'upstream/master' (diff)
parentMerge pull request #2182 from birkett/master (diff)
downloadcuberite-3142598dee31acc23c738a1a728638665c8940b8.tar
cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.gz
cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.bz2
cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.lz
cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.xz
cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.zst
cuberite-3142598dee31acc23c738a1a728638665c8940b8.zip
Diffstat (limited to 'src/Root.cpp')
-rw-r--r--src/Root.cpp51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index c3c880e73..54e65b6da 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -72,7 +72,7 @@ cRoot::~cRoot()
void cRoot::InputThread(cRoot & a_Params)
{
cLogCommandOutputCallback Output;
-
+
while (!cRoot::m_ShouldStop && !a_Params.m_bRestart && !m_TerminateEventRaised && std::cin.good())
{
AString Command;
@@ -105,12 +105,12 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> overridesRepo)
HMENU hmenu = GetSystemMenu(hwnd, FALSE);
EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling
#endif
-
+
cLogger::cListener * consoleLogListener = MakeConsoleListener();
cLogger::cListener * fileLogListener = new cFileListener();
cLogger::GetInstance().AttachListener(consoleLogListener);
cLogger::GetInstance().AttachListener(fileLogListener);
-
+
LOG("--- Started Log ---\n");
#ifdef BUILD_ID
@@ -162,30 +162,30 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> overridesRepo)
m_RankManager->Initialize(*m_MojangAPI);
m_CraftingRecipes = new cCraftingRecipes;
m_FurnaceRecipe = new cFurnaceRecipe();
-
+
LOGD("Loading worlds...");
LoadWorlds(*settingsRepo);
LOGD("Loading plugin manager...");
m_PluginManager = new cPluginManager();
m_PluginManager->ReloadPluginsNow(*settingsRepo);
-
+
LOGD("Loading MonsterConfig...");
m_MonsterConfig = new cMonsterConfig;
// This sets stuff in motion
LOGD("Starting Authenticator...");
m_Authenticator.Start(*settingsRepo);
-
+
LOGD("Starting worlds...");
StartWorlds();
-
+
if (settingsRepo->GetValueSetB("DeadlockDetect", "Enabled", true))
{
LOGD("Starting deadlock detector...");
dd.Start(settingsRepo->GetValueSetI("DeadlockDetect", "IntervalSec", 20));
}
-
+
settingsRepo->Flush();
LOGD("Finalising startup...");
@@ -207,6 +207,10 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> overridesRepo)
#endif
LOG("Startup complete, took %ldms!", static_cast<long int>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - BeginTime).count()));
+
+ // Save the current time
+ m_StartTime = std::chrono::steady_clock::now();
+
#ifdef _WIN32
EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button
#endif
@@ -253,7 +257,7 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> overridesRepo)
LOGD("Unloading worlds...");
UnloadWorlds();
-
+
LOGD("Stopping plugin manager...");
delete m_PluginManager; m_PluginManager = nullptr;
@@ -264,9 +268,9 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> overridesRepo)
LOG("Shutdown successful!");
}
-
+
LOG("--- Stopped Log ---");
-
+
cLogger::GetInstance().DetachListener(consoleLogListener);
delete consoleLogListener;
cLogger::GetInstance().DetachListener(fileLogListener);
@@ -299,7 +303,7 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings)
{
return;
}
-
+
bool FoundAdditionalWorlds = false;
for (auto WorldNameValue : Worlds)
{
@@ -554,6 +558,23 @@ void cRoot::SaveAllChunks(void)
+void cRoot::SendPlayerLists(cPlayer * a_DestPlayer)
+{
+ for (const auto & itr : m_WorldsByName)
+ {
+ itr.second->SendPlayerList(a_DestPlayer);
+ } // for itr - m_WorldsByName[]
+}
+
+
+
+void cRoot::BroadcastPlayerListsAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
+{
+ for (const auto & itr : m_WorldsByName)
+ {
+ itr.second->BroadcastPlayerListAddPlayer(a_Player);
+ } // for itr - m_WorldsByName[]
+}
void cRoot::BroadcastChat(const AString & a_Message, eMessageType a_ChatPrefix)
@@ -578,8 +599,6 @@ void cRoot::BroadcastChat(const cCompositeChat & a_Message)
-
-
bool cRoot::ForEachPlayer(cPlayerListCallback & a_Callback)
{
for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2)
@@ -850,7 +869,3 @@ int cRoot::GetFurnaceFuelBurnTime(const cItem & a_Fuel)
cFurnaceRecipe * FR = Get()->GetFurnaceRecipe();
return FR->GetBurnTime(a_Fuel);
}
-
-
-
-