Run scriptapi_on_shutdown() thread-safely and remove some old crap
authorPerttu Ahola <celeron55@gmail.com>
Fri, 30 Nov 2012 17:41:13 +0000 (19:41 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 30 Nov 2012 17:41:13 +0000 (19:41 +0200)
src/server.cpp

index 67c1ce9270748783b09958121acd8c1e0e3ea96c..a793c6e2a74f1839198b63425871cfb6fea77ea6 100644 (file)
@@ -1113,11 +1113,16 @@ Server::~Server()
                }
        }
 
-       /*
-               Execute script shutdown hooks
-       */
-       scriptapi_on_shutdown(m_lua);
-       
+       {
+               JMutexAutoLock envlock(m_env_mutex);
+               JMutexAutoLock conlock(m_con_mutex);
+
+               /*
+                       Execute script shutdown hooks
+               */
+               scriptapi_on_shutdown(m_lua);
+       }
+
        {
                JMutexAutoLock envlock(m_env_mutex);
 
@@ -1149,14 +1154,6 @@ Server::~Server()
                        i = m_clients.getIterator();
                        i.atEnd() == false; i++)
                {
-                       /*// Delete player
-                       // NOTE: These are removed by env destructor
-                       {
-                               u16 peer_id = i.getNode()->getKey();
-                               JMutexAutoLock envlock(m_env_mutex);
-                               m_env->removePlayer(peer_id);
-                       }*/
-                       
                        // Delete client
                        delete i.getNode()->getValue();
                }