Example #1
0
        public static void PerformShutDown()
        {
            Console.Clear();
            log.Info("Server shutting down...");
            Console.Title = "HABBO EMULATOR: SHUTTING DOWN!";

            HabboEnvironment.GetGame().GetClientManager().SendMessage(new BroadcastMessageAlertComposer(HabboEnvironment.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` = ''");
                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("Habbo Emulator has successfully shutdown.");

            Thread.Sleep(1000);
            Environment.Exit(0);
        }
Example #2
0
        public static string GetUsernameById(int UserId)
        {
            string Name = "Unknown User";

            GameClient Client = GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client != null && Client.GetHabbo() != null)
            {
                return(Client.GetHabbo().Username);
            }

            UserCache User = HabboEnvironment.GetGame().GetCacheManager().GenerateUser(UserId);

            if (User != null)
            {
                return(User.Username);
            }

            using (IQueryAdapter dbClient = HabboEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `username` FROM `users` WHERE id = @id LIMIT 1");
                dbClient.AddParameter("id", UserId);
                Name = dbClient.getString();
            }

            if (string.IsNullOrEmpty(Name))
            {
                Name = "Unknown User";
            }

            return(Name);
        }
Example #3
0
        public static void Main(string[] Args)
        {
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND);

            XmlConfigurator.Configure();

            Console.ForegroundColor = ConsoleColor.White;
            Console.CursorVisible   = false;
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += MyHandler;

            HabboEnvironment.Initialize();

            while (true)
            {
                Console.CursorVisible = true;
                if (Logging.DisabledState)
                {
                    Console.Write("HabboEmulator > ");
                }

                ConsoleCommandHandler.InvokeCommand(Console.ReadLine());
                continue;
            }
        }
Example #4
0
        private static void MyHandler(object sender, UnhandledExceptionEventArgs args)
        {
            Logging.DisablePrimaryWriting(true);
            var e = (Exception)args.ExceptionObject;

            Logging.LogCriticalException("SYSTEM CRITICAL EXCEPTION: " + e);
            HabboEnvironment.PerformShutDown();
        }