aboutsummaryrefslogtreecommitdiff
path: root/src/trinitycore/WorldRunnable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/trinitycore/WorldRunnable.cpp')
-rw-r--r--src/trinitycore/WorldRunnable.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/trinitycore/WorldRunnable.cpp b/src/trinitycore/WorldRunnable.cpp
index b29e1434a64..607b60684a9 100644
--- a/src/trinitycore/WorldRunnable.cpp
+++ b/src/trinitycore/WorldRunnable.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
@@ -29,13 +29,19 @@
#include "Timer.h"
#include "ObjectAccessor.h"
#include "MapManager.h"
+#include "BattleGroundMgr.h"
#include "Database/DatabaseEnv.h"
-#if (defined(SHORT_SLEEP) || defined(WIN32))
+#ifdef WIN32
#define WORLD_SLEEP_CONST 50
#else
-#define WORLD_SLEEP_CONST 100 //Is this still needed?? [On linux some time ago not working 50ms]
+#define WORLD_SLEEP_CONST 100 //Is this still needed?? [On linux some time ago not working 50ms]
+#endif
+
+#ifdef WIN32
+#include "ServiceWin32.h"
+extern int m_ServiceStatus;
#endif
/// Heartbeat for the World
@@ -43,6 +49,8 @@ void WorldRunnable::run()
{
///- Init new SQL thread for the world database
WorldDatabase.ThreadStart(); // let thread do safe mySQL requests (one connection call enough)
+ CharacterDatabase.ThreadStart();
+ LoginDatabase.ThreadStart();
sWorld.InitResultQueue();
uint32 realCurrTime = 0;
@@ -72,16 +80,25 @@ void WorldRunnable::run()
}
else
prevSleepTime = 0;
+
+ #ifdef WIN32
+ if (m_ServiceStatus == 0) World::StopNow(SHUTDOWN_EXIT_CODE);
+ while (m_ServiceStatus == 2) Sleep(1000);
+ #endif
}
sWorld.KickAll(); // save and kick all players
sWorld.UpdateSessions( 1 ); // real players unload required UpdateSessions call
+ // unload battleground templates before different singletons destroyed
+ sBattleGroundMgr.DeleteAllBattleGrounds();
+
sWorldSocketMgr->StopNetwork();
MapManager::Instance().UnloadAll(); // unload all grids (including locked in memory)
///- End the database thread
WorldDatabase.ThreadEnd(); // free mySQL thread resources
+ CharacterDatabase.ThreadStart();
+ LoginDatabase.ThreadEnd();
}
-