Пример #1
0
        public static void PerformShutDown(bool Crashed = true)
        {
            Console.Clear();
            log.Info("Servidor desligando...");
            Console.Title = "Plus Emulador: Desligando!";

            if (!Crashed)
            {
                PlusEnvironment.GetGame().GetClientManager().SendMessage(new Communication.Packets.Outgoing.Rooms.Notifications.RoomNotificationComposer("[Alerta de Manutenção]", PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("shutdown_alert"), "disconnection", "ok", "event:"));
            }
            else
            {
                PlusEnvironment.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("[Alerta de Manutenção]", PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("shutdown_alert_crash"), "disconnection", "ok", "event:"));
            }
            GetGame().StopGameLoop();

            Thread.Sleep(Crashed ? 6500 : 2500);

            GetConnectionManager().Destroy();             //Stop listening.

            GetGame().GetPacketManager().UnregisterAll(); //Unregister the packets.
            GetGame().GetPacketManager().WaitForAllToComplete();

            FarmingManager.UpdateAllFarmingSpaces();

            RoleplayManager.TimerManager.EndAllTimers();
            RoleplayManager.TimerManager = null;

            GetGame().GetClientManager().CloseAll(); //Close all connections
            GetGame().GetRoomManager().Dispose();    //Stop the game loop.

            using (IQueryAdapter dbClient = _manager.GetQueryReactor())
            {
                dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`");
                dbClient.RunQuery("UPDATE `users` SET online = '0', `auth_ticket` = NULL");
                dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0'");
                dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0', `environment_status` = '" + (Crashed ? 3 : 0) + "'");
            }

            WebSocketChatManager.StopAllChats();

            log.Info("Plus Emulador desligado com sucesso.");

            Thread.Sleep(1000);
            Environment.Exit(0);
        }
Пример #2
0
        public static void PerformShutDown()
        {
            Console.Clear();
            log.Info("Server shutting down...");
            Console.Title = "PLUS EMULATOR: SHUTTING DOWN!";

            PlusEnvironment.GetGame().GetClientManager().SendMessage(new BroadcastMessageAlertComposer(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("shutdown_alert")));
            GetGame().StopGameLoop();
            Thread.Sleep(2500);
            GetConnectionManager().Destroy();             //Stop listening.
            GetGame().GetPacketManager().UnregisterAll(); //Unregister the packets.
            GetGame().GetPacketManager().WaitForAllToComplete();
            GetGame().GetClientManager().CloseAll();      //Close all connections
            GetGame().GetRoomManager().Dispose();         //Stop the game loop.

            using (IQueryAdapter dbClient = _manager.GetQueryReactor())
            {
                dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`");
                dbClient.RunQuery("UPDATE `users` SET online = '0', `auth_ticket` = NULL");
                dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0'");
                dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0'");
            }

            log.Info("Plus Emulator has successfully shutdown.");

            Thread.Sleep(1000);
            Environment.Exit(0);
        }