internal static void PerformShutDown(string reason, bool ExitWhenDone) { GlobalClass.ShuttingDown = true; try { GetPacketManager().UnregisterPackets(); } catch { } if (reason != "") { if (ShutdownInitiated) { return; } Console.WriteLine(reason); Logging.DisablePrimaryWriting(); SendMassMessage("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity."); ShutdownInitiated = true; Console.WriteLine("Server shutting down..."); try { Game.GetRoomManager().RemoveAllRooms(); } catch { } try { GetConnectionManager().GetListener().Stop(); GetGame().GetClientManager().CloseAll(); } catch { } try { using (DatabaseClient adapter = GetDatabase().GetClient()) { adapter.ExecuteQuery("UPDATE users SET online = '0'"); adapter.ExecuteQuery("UPDATE rooms SET users_now = '0'"); } ConnectionManager.Shutdown(); Game.Destroy(); } catch { } try { Console.WriteLine("Destroying database manager."); MySqlConnection.ClearAllPools(); DatabaseManager = null; } catch { } Console.WriteLine("System disposed, goodbye!"); } else { Logging.DisablePrimaryWriting(); ShutdownInitiated = true; try { Game.GetRoomManager().RemoveAllRooms(); } catch { } try { GetConnectionManager().GetListener().Stop(); GetGame().GetClientManager().CloseAll(); } catch { } ConnectionManager.Shutdown(); Game.Destroy(); Console.WriteLine(reason); } if (ExitWhenDone) { Environment.Exit(0); } }