1
0

World threads are stopped before the plugin mgr for clean exit (FS #228)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@669 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-07-15 20:07:38 +00:00
parent e65d28484d
commit 2c490d4229
4 changed files with 32 additions and 4 deletions

View File

@ -162,6 +162,8 @@ void cRoot::Start()
// Deallocate stuffs // Deallocate stuffs
LOG("Shutting down server..."); LOG("Shutting down server...");
m_Server->Shutdown(); // This waits for threads to stop and d/c clients m_Server->Shutdown(); // This waits for threads to stop and d/c clients
LOG("Stopping world threads...");
StopWorlds();
LOG("Stopping authenticator..."); LOG("Stopping authenticator...");
m_Authenticator.Stop(); m_Authenticator.Stop();
LOG("Stopping plugin manager..."); LOG("Stopping plugin manager...");
@ -253,6 +255,18 @@ void cRoot::StartWorlds(void)
void cRoot::StopWorlds(void)
{
for( WorldMap::iterator itr = m_pState->WorldsByName.begin(); itr != m_pState->WorldsByName.end(); ++itr )
{
itr->second->StopThreads();
}
}
void cRoot::UnloadWorlds(void) void cRoot::UnloadWorlds(void)
{ {
for( WorldMap::iterator itr = m_pState->WorldsByName.begin(); itr != m_pState->WorldsByName.end(); ++itr ) for( WorldMap::iterator itr = m_pState->WorldsByName.begin(); itr != m_pState->WorldsByName.end(); ++itr )

View File

@ -78,6 +78,10 @@ private:
/// Starts each world's life /// Starts each world's life
void StartWorlds(void); void StartWorlds(void);
/// Stops each world's threads, so that it's safe to unload them
void StopWorlds(void);
/// Unloads all worlds from memory
void UnloadWorlds(void); void UnloadWorlds(void);
cServer * m_Server; cServer * m_Server;

View File

@ -208,9 +208,6 @@ cWorld::~cWorld()
delete m_FireSimulator; delete m_FireSimulator;
delete m_RedstoneSimulator; delete m_RedstoneSimulator;
m_Generator.Stop();
m_ChunkSender.Stop();
UnloadUnusedChunks(); UnloadUnusedChunks();
m_Storage.WaitForFinish(); m_Storage.WaitForFinish();
@ -510,6 +507,16 @@ void cWorld::InitializeSpawn(void)
void cWorld::StopThreads(void)
{
m_Generator.Stop();
m_ChunkSender.Stop();
}
void cWorld::Tick(float a_Dt) void cWorld::Tick(float a_Dt)
{ {
m_Time += a_Dt / 1000.f; m_Time += a_Dt / 1000.f;

View File

@ -326,7 +326,10 @@ public:
void Tick(float a_Dt); void Tick(float a_Dt);
void InitializeSpawn(); void InitializeSpawn(void);
/// Stops threads that belong to this world (part of deinit)
void StopThreads(void);
void CastThunderbolt (int a_X, int a_Y, int a_Z); //tolua_export void CastThunderbolt (int a_X, int a_Y, int a_Z); //tolua_export
void SetWeather ( eWeather a_Weather ); //tolua_export void SetWeather ( eWeather a_Weather ); //tolua_export