summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/cRoot.cpp14
-rw-r--r--source/cRoot.h4
-rw-r--r--source/cWorld.cpp13
-rw-r--r--source/cWorld.h5
4 files changed, 32 insertions, 4 deletions
diff --git a/source/cRoot.cpp b/source/cRoot.cpp
index 9ab923d50..ef234044f 100644
--- a/source/cRoot.cpp
+++ b/source/cRoot.cpp
@@ -162,6 +162,8 @@ void cRoot::Start()
// Deallocate stuffs
LOG("Shutting down server...");
m_Server->Shutdown(); // This waits for threads to stop and d/c clients
+ LOG("Stopping world threads...");
+ StopWorlds();
LOG("Stopping authenticator...");
m_Authenticator.Stop();
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)
{
for( WorldMap::iterator itr = m_pState->WorldsByName.begin(); itr != m_pState->WorldsByName.end(); ++itr )
diff --git a/source/cRoot.h b/source/cRoot.h
index 21bd39f7d..fc12d876c 100644
--- a/source/cRoot.h
+++ b/source/cRoot.h
@@ -78,6 +78,10 @@ private:
/// Starts each world's life
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);
cServer * m_Server;
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 187642242..980d09cdb 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -208,9 +208,6 @@ cWorld::~cWorld()
delete m_FireSimulator;
delete m_RedstoneSimulator;
- m_Generator.Stop();
- m_ChunkSender.Stop();
-
UnloadUnusedChunks();
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)
{
m_Time += a_Dt / 1000.f;
diff --git a/source/cWorld.h b/source/cWorld.h
index fd594f22b..0a4d0280e 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -326,7 +326,10 @@ public:
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 SetWeather ( eWeather a_Weather ); //tolua_export