Exemplo n.º 1
0
        /// <summary>
        ///     Shutdown the Emulator
        /// </summary>
        /// <param name="restart">if set to <c>true</c> [restart].</param>
        /// Set a Different Message in Hotel
        internal static void PerformShutDown(bool restart)
        {
            DateTime now = DateTime.Now;

            CacheManager.StopProcess();

            ShutdownStarted = true;

            Console.Title = "Yupi Emulator | Shutting down...";

            GetGame().StopGameLoop();
            GetGame().GetRoomManager().RemoveAllRooms();

            GetGame().GetClientManager().CloseAll();

            GetConnectionManager().Destroy();

            foreach (Group group in GetGame().GetGroupManager().Groups.Values)
            {
                group.UpdateForum();
            }

            using (IQueryAdapter queryReactor = YupiDatabaseManager.GetQueryReactor())
            {
                queryReactor.RunFastQuery("UPDATE users SET online = '0'");
                queryReactor.RunFastQuery("UPDATE rooms_data SET users_now = 0");
                queryReactor.RunFastQuery("TRUNCATE TABLE users_rooms_visits");
            }

            GetConnectionManager().Destroy();

            GetGame().Destroy();

            YupiLogManager.Stop();

            YupiWriterManager.WriteLine(" destroyed", "Yupi.Game", ConsoleColor.DarkYellow);

            TimeSpan span = DateTime.Now - now;

            YupiWriterManager.WriteLine("Elapsed " + TimeSpanToString(span) + "ms on Shutdown Proccess", "Yupi.Life", ConsoleColor.DarkYellow);

            IsLive = false;

            if (restart)
            {
                Process.Start(Assembly.GetEntryAssembly().Location);
            }

            Console.WriteLine("Closing...");

            Environment.Exit(0);
        }