diff options
Diffstat (limited to 'source/Root.cpp')
-rw-r--r-- | source/Root.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/source/Root.cpp b/source/Root.cpp index 5ec27aa0d..07de0775c 100644 --- a/source/Root.cpp +++ b/source/Root.cpp @@ -16,6 +16,7 @@ #include "Chunk.h" #include "Protocol/ProtocolRecognizer.h" // for protocol version constants #include "CommandOutput.h" +#include "DeadlockDetect.h" #include "../iniFile/iniFile.h" @@ -90,6 +91,7 @@ void cRoot::InputThread(void * a_Params) void cRoot::Start(void) { + cDeadlockDetect dd; delete m_Log; m_Log = new cMCLogger(); @@ -162,6 +164,9 @@ void cRoot::Start(void) LOG("Starting worlds..."); StartWorlds(); + LOG("Starting deadlock detector..."); + dd.Start(); + LOG("Starting server..."); m_Server->Start(); @@ -183,17 +188,21 @@ void cRoot::Start(void) // Deallocate stuffs LOG("Shutting down server..."); - m_Server->Shutdown(); // This waits for threads to stop and d/c clients + m_Server->Shutdown(); + + LOG("Shutting down deadlock detector..."); + dd.Stop(); + LOG("Stopping world threads..."); StopWorlds(); + LOG("Stopping authenticator..."); m_Authenticator.Stop(); - LOG("Freeing MonsterConfig..."); - delete m_MonsterConfig; m_MonsterConfig = 0; + delete m_MonsterConfig; m_MonsterConfig = NULL; LOG("Stopping WebAdmin..."); - delete m_WebAdmin; m_WebAdmin = 0; + delete m_WebAdmin; m_WebAdmin = NULL; LOG("Unloading recipes..."); delete m_FurnaceRecipe; m_FurnaceRecipe = NULL; delete m_CraftingRecipes; m_CraftingRecipes = NULL; @@ -270,8 +279,9 @@ void cRoot::LoadWorlds(void) void cRoot::StartWorlds(void) { - for( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) { + itr->second->Start(); itr->second->InitializeSpawn(); } } @@ -282,9 +292,9 @@ void cRoot::StartWorlds(void) void cRoot::StopWorlds(void) { - for( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) { - itr->second->StopThreads(); + itr->second->Stop(); } } @@ -344,7 +354,7 @@ bool cRoot::ForEachWorld(cWorldListCallback & a_Callback) -void cRoot::TickWorlds(float a_Dt) +void cRoot::TickCommands(void) { // Execute any pending commands: cCommandQueue PendingCommands; @@ -356,12 +366,6 @@ void cRoot::TickWorlds(float a_Dt) { ExecuteConsoleCommand(itr->m_Command, *(itr->m_Output)); } - - // Tick the worlds: - for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) - { - itr->second->Tick(a_Dt); - } } |