summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2015-01-25 00:34:19 +0100
committerHowaner <franzi.moos@googlemail.com>2015-01-25 00:34:19 +0100
commit1eedccc56a1a80b42adbea8dbbe968d42c7fe712 (patch)
treea5fe3fb72a3c3918b2c4ba413c686f718f5d403c /src/Root.cpp
parentC++11 and function rename. (diff)
parentGamosocm support (diff)
downloadcuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.gz
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.bz2
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.lz
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.xz
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.zst
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.zip
Diffstat (limited to 'src/Root.cpp')
-rw-r--r--src/Root.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index 9f8ffeeff..eaacf3608 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -47,6 +47,7 @@ cRoot::cRoot(void) :
m_FurnaceRecipe(nullptr),
m_WebAdmin(nullptr),
m_PluginManager(nullptr),
+ m_MojangAPI(nullptr),
m_bStop(false),
m_bRestart(false)
{
@@ -135,8 +136,9 @@ void cRoot::Start(void)
}
LOG("Starting server...");
+ m_MojangAPI = new cMojangAPI;
bool ShouldAuthenticate = IniFile.GetValueSetB("Authentication", "Authenticate", true);
- m_MojangAPI.Start(IniFile, ShouldAuthenticate); // Mojang API needs to be started before plugins, so that plugins may use it for DB upgrades on server init
+ m_MojangAPI->Start(IniFile, ShouldAuthenticate); // Mojang API needs to be started before plugins, so that plugins may use it for DB upgrades on server init
if (!m_Server->InitServer(IniFile, ShouldAuthenticate))
{
IniFile.WriteFile("settings.ini");
@@ -149,7 +151,7 @@ void cRoot::Start(void)
LOGD("Loading settings...");
m_RankManager.reset(new cRankManager());
- m_RankManager->Initialize(m_MojangAPI);
+ m_RankManager->Initialize(*m_MojangAPI);
m_CraftingRecipes = new cCraftingRecipes;
m_FurnaceRecipe = new cFurnaceRecipe();
@@ -196,7 +198,7 @@ void cRoot::Start(void)
}
#endif
- LOG("Startup complete, took %ld ms!", static_cast<long int>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - BeginTime).count()));
+ LOG("Startup complete, took %ldms!", static_cast<long int>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - BeginTime).count()));
#ifdef _WIN32
EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button
#endif
@@ -213,21 +215,28 @@ void cRoot::Start(void)
// Stop the server:
m_WebAdmin->Stop();
+
LOG("Shutting down server...");
m_Server->Shutdown();
+ delete m_MojangAPI; m_MojangAPI = nullptr;
+
LOGD("Shutting down deadlock detector...");
dd.Stop();
+
LOGD("Stopping world threads...");
StopWorlds();
+
LOGD("Stopping authenticator...");
m_Authenticator.Stop();
LOGD("Freeing MonsterConfig...");
delete m_MonsterConfig; m_MonsterConfig = nullptr;
delete m_WebAdmin; m_WebAdmin = nullptr;
+
LOGD("Unloading recipes...");
delete m_FurnaceRecipe; m_FurnaceRecipe = nullptr;
delete m_CraftingRecipes; m_CraftingRecipes = nullptr;
+
LOGD("Unloading worlds...");
UnloadWorlds();
@@ -238,6 +247,7 @@ void cRoot::Start(void)
LOG("Cleaning up...");
delete m_Server; m_Server = nullptr;
+
LOG("Shutdown successful!");
}
@@ -629,7 +639,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
bool cRoot::DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback)
{
- for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end();itr++)
+ for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
{
if (itr->second->DoWithPlayerByUUID(a_PlayerUUID, a_Callback))
{