Esempio n. 1
0
        public static void LoadMus()
        {
            Logging.Write("Listening for MUS connections on (" + GetSettingsData().Data["mus.ip"] + ":" + GetSettingsData().Data["mus.port"] + ")");

            try
            {
                MusSocket = new MusSocket(GetSettingsData().Data["mus.ip"], int.Parse(GetSettingsData().Data["mus.port"]), GetSettingsData().Data["mus.allowedips"].Split(Convert.ToChar(";")), 0);
                Logging.WriteSimpleLine(" - Completed!");
            }
            catch (Exception Error)
            {
                Logging.WriteSimpleLine(" - Incomplete!");
                Logging.LogError(Error.ToString());
                Logging.WriteLine("Could not load mus socket!", ConsoleColor.Red);
                Logging.WriteLine("Press any key to shut down ...", ConsoleColor.Red);
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
        }
Esempio n. 2
0
        internal static void Initialize()
        {
            ServerStarted = DateTime.Now;
            //Console.ForegroundColor = ConsoleColor.DarkBlue;
            //Console.WriteLine("\n                                                                 ");
            //Console.WriteLine(@"        $$$$$$\    $$\                         $$\                ");
            //Console.WriteLine(@"       $$  __$$\   $$ |                        \__|               ");
            //Console.WriteLine(@"       $$ /  $$ |$$$$$$\    $$$$$$\  $$$$$$$\  $$\ $$\   $$\      ");
            //Console.WriteLine(@"       $$ |  $$ |\_$$  _|   \____$$\ $$  __$$\ $$ |\$$\ $$  |     ");
            //Console.WriteLine(@"       $$ |  $$ |  $$ |     $$$$$$$ |$$ |  $$ |$$ | \$$$$  /      ");
            //Console.WriteLine(@"       $$ |  $$ |  $$ |$$\ $$  __$$ |$$ |  $$ |$$ | $$  $$<       ");
            //Console.WriteLine(@"        $$$$$$  |  \$$$$  |\$$$$$$$ |$$ |  $$ |$$ |$$  /\$$\      ");
            //Console.WriteLine(@"        \______/    \____/  \_______|\__|  \__|\__|\__/  \__|     ");
            //Console.WriteLine("\n                                                                 ");
            //Console.ForegroundColor = ConsoleColor.DarkGreen;
            //Console.WriteLine(@"   © 2016 - 2017 - Todos os direitos reservados ao Thiago Araujo.");
            //Console.WriteLine(@"                                                                 ");
            Console.ForegroundColor = ConsoleColor.Gray;

            try
            {
                #region Starting
                Configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"Settings/configuration.ini"));

                UsersCache.Initialize();
                LowPriorityWorker.Init();
                APIexterna.InitStatus();
                LanguageLocale.Init();
                ChatCommandRegister.Init();
                PetLocale.Init();
                #endregion
                #region MySQL Configuration
                var starts = DateTime.Now;
                Logging.WriteLine("[Otanix] @ Conectando na database...");

                manager = new DatabaseManager(uint.Parse(GetConfig().data["db.pool.maxsize"]),
                                              int.Parse(GetConfig().data["db.pool.minsize"]));
                manager.setServerDetails(
                    GetConfig().data["db.hostname"],
                    uint.Parse(GetConfig().data["db.port"]),
                    GetConfig().data["db.username"],
                    GetConfig().data["db.password"],
                    GetConfig().data["db.name"]);
                manager.init();

                var timeUsed2 = DateTime.Now - starts;
                Logging.WriteLine("[Otanix] @ Conectado com sucesso na database! (" + timeUsed2.Seconds + " s, " + timeUsed2.Milliseconds + " ms)");
                #endregion
                #region Cycles Configuration
                starts = DateTime.Now;

                StaticClientMessageHandler.Initialize();
                ClientMessageFactory.Init();

                var timeUsed3 = DateTime.Now - starts;
                Logging.WriteLine("[Otanix] @ Iniciando os ciclos! (" + timeUsed3.Seconds + " s, " + timeUsed3.Milliseconds +
                                  " ms)");

                Game = new Game();
                Game.ContinueLoading();
                #endregion
                #region Connections Configuration
                ConnectionManager = new ConnectionHandeling(int.Parse(GetConfig().data["game.tcp.port"]),
                                                            int.Parse(GetConfig().data["game.tcp.conlimit"]),
                                                            int.Parse(GetConfig().data["game.tcp.conperip"]),
                                                            GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                ConnectionManager.init();
                ConnectionManager.Start();

                Handler.Initialize(RsaKeyHolder.N, RsaKeyHolder.D, RsaKeyHolder.E);
                Logging.WriteLine("[Otanix] @ RSA Crypto iniciada!");

                if (GetConfig().data["mus.enable"].ToLower() == "true")
                {
                    MusSystem = new MusSocket(int.Parse(GetConfig().data["mus.tcp.port"]));
                }
                #endregion
                #region Last Process
                var TimeUsed = DateTime.Now - ServerStarted;
                Logging.WriteLine("[Otanix] @ ENVIRONMENT -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
                Console.Title = "Otanix Emulador ~ Versão privada por Thiago Araujo para " + EmuSettings.HOTEL_LINK;

                if (Debugger.IsAttached)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Logging.WriteLine("[Otanix] @ Alerta: Servidor está em DEBUG, console ativado!");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Logging.WriteLine("[Otanix] @ Alerta: Servidor não está em DEBUG, console desativado!");
                    Logging.DisablePrimaryWriting(false);
                }

                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("[Otanix] @ Alerta: Pressione alguma tecla para ativar o console de comandos.");
                Console.ForegroundColor = ConsoleColor.White;
                #endregion
            }
            catch (KeyNotFoundException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Logging.WriteLine("Avviso: controlla il file di configurazione, alcuni valori sembrano mancare.");
                Logging.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                Destroy();
            }
            catch (InvalidOperationException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Logging.WriteLine("Avviso: impossibile avviare il programma, " + e.Message);
                Logging.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma...");

                Console.ReadKey(true);
                Destroy();
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Avviso: errore di avvio irreversibile, " + e);
                Console.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma...");

                Console.ReadKey();
                Environment.Exit(1);
            }
            Console.ForegroundColor = ConsoleColor.White;
        }
Esempio n. 3
0
        public static void Initialize()
        {
            string CurrentTime = DateTime.Now.ToString("HH:mm:ss" + " | ");

            ServerStarted           = DateTime.Now;
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Clear();
            Console.WriteLine(@"                 ::::    :::       ::::::::::       ::::::::       ::::    ::: ");
            Console.WriteLine(@"                :+:+:   :+:       :+:             :+:    :+:      :+:+:   :+:  ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(@"               :+:+:+  +:+       +:+             +:+     +:      +:+:+:+ +:+   ");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine(@"              +#+ +:+ +#+       +#++:++#        +#+    +:+      +#+ +:+ +#+    ");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine(@"             +#+  +#+#+#       +#+             +#+    +#+      +#+  +#+#+#     ");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(@"            #+#   #+#+#       #+#             #+#    #+#      #+#   #+#+#      ");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine(@"           ###    ####       ##########       ########       ###    ####       ");
            Console.WriteLine("");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("");
            Console.WriteLine(@"                                       © 2020 - Neon Corporation ©");
            Console.WriteLine(@"            Agradecimientos a » @Sledmore @Nillus - Un proyecto hecho por Javas para Keko Hotel");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine(@"-------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("");
            Console.Title    = "Loading Neon...";
            _defaultEncoding = Encoding.Default;

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

            CultureInfo = CultureInfo.CreateSpecificCulture("en-GB");

            try
            {
                _configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"config.ini"));

                MySqlConnectionStringBuilder connectionString = new MySqlConnectionStringBuilder
                {
                    ConnectionTimeout     = 10,
                    Database              = GetConfig().data["db.name"],
                    DefaultCommandTimeout = 30,
                    Logging             = false,
                    MaximumPoolSize     = uint.Parse(GetConfig().data["db.pool.maxsize"]),
                    MinimumPoolSize     = uint.Parse(GetConfig().data["db.pool.minsize"]),
                    Password            = GetConfig().data["db.password"],
                    Pooling             = true,
                    Port                = uint.Parse(GetConfig().data["db.port"]),
                    Server              = GetConfig().data["db.hostname"],
                    UserID              = GetConfig().data["db.username"],
                    AllowZeroDateTime   = true,
                    ConvertZeroDateTime = true,
                };

                _manager = new DatabaseManager(connectionString.ToString());

                if (!_manager.IsConnected())
                {
                    Console.WriteLine(CurrentTime + "» Ya existe una conexión a la base de datos.");
                    Console.ReadKey(true);
                    Environment.Exit(1);
                    return;
                }
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine(CurrentTime + "» Conexión a la base de datos.");
                //Reset our statistics first.
                using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`");
                    dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0';");
                    dbClient.RunQuery("UPDATE `users` SET `online` = '0' WHERE `online` = '1'");
                    dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0'");
                }

                //Get the configuration & Game set.
                ConfigData = new ConfigData();
                _game      = new Game();

                //Have our encryption ready.
                HabboEncryptionV2.Initialize(new RSAKeys());

                //Make sure MUS is working.
                MusSystem = new MusSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(";")), 0);

                //Accept connections.
                _connectionManager = new ConnectionHandling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"]), GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                _connectionManager.init();

                _game.StartGameLoop();

                TimeSpan TimeUsed = DateTime.Now - ServerStarted;

                Console.WriteLine();

                log.Info(">> NEON SERVER -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("Please check your configuration file - some values appear to be missing.", ConsoleColor.Red);
                Logging.WriteLine("Press any key to shut down ...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Failed to initialize KeyEmulator: " + e.Message, ConsoleColor.Red);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (Exception e)
            {
                Logging.WriteLine("Fatal error during startup: " + e, ConsoleColor.Red);
                Logging.WriteLine("Press a key to exit");

                Console.ReadKey();
                Environment.Exit(1);
            }
        }
Esempio n. 4
0
        public static void Initialize()
        {
            ServerStarted           = DateTime.Now;
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine();
            Console.WriteLine("                     ____  __           ________  _____  __");
            Console.WriteLine(@"                    / __ \/ /_  _______/ ____/  |/  / / / /");
            Console.WriteLine("                   / /_/ / / / / / ___/ __/ / /|_/ / / / / ");
            Console.WriteLine("                  / ____/ / /_/ (__  ) /___/ /  / / /_/ /  ");
            Console.WriteLine(@"                 /_/   /_/\__,_/____/_____/_/  /_/\____/ ");

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("                                " + PrettyVersion + " <Build " + PrettyBuild + ">");
            Console.WriteLine("                                http://PlusIndustry.com");

            Console.WriteLine("");
            Console.Title    = "Loading Plus Emulator";
            _defaultEncoding = Encoding.Default;

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

            CultureInfo = CultureInfo.CreateSpecificCulture("en-GB");


            try
            {
                _configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"config.ini"));

                var connectionString = new MySqlConnectionStringBuilder
                {
                    ConnectionTimeout     = 10,
                    Database              = GetConfig().data["db.name"],
                    DefaultCommandTimeout = 30,
                    Logging             = false,
                    MaximumPoolSize     = uint.Parse(GetConfig().data["db.pool.maxsize"]),
                    MinimumPoolSize     = uint.Parse(GetConfig().data["db.pool.minsize"]),
                    Password            = GetConfig().data["db.password"],
                    Pooling             = true,
                    Port                = uint.Parse(GetConfig().data["db.port"]),
                    Server              = GetConfig().data["db.hostname"],
                    UserID              = GetConfig().data["db.username"],
                    AllowZeroDateTime   = true,
                    ConvertZeroDateTime = true,
                };

                _manager = new DatabaseManager(connectionString.ToString());

                if (!_manager.IsConnected())
                {
                    log.Error("Failed to connect to the specified MySQL server.");
                    Console.ReadKey(true);
                    Environment.Exit(1);
                    return;
                }

                log.Info("Connected to Database!");

                //Reset our statistics first.
                using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`");
                    dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0';");
                    dbClient.RunQuery("UPDATE `users` SET `online` = '0' WHERE `online` = '1'");
                    dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0'");
                }

                //Get the configuration & Game set.
                ConfigData = new ConfigData();
                _game      = new Game();

                //Have our encryption ready.
                HabboEncryptionV2.Initialize(new RSAKeys());

                //Make sure MUS is working.
                MusSystem = new MusSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(";")), 0);

                //Accept connections.
                _connectionManager = new ConnectionHandling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"]), GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                _connectionManager.init();

                _game.StartGameLoop();

                TimeSpan TimeUsed = DateTime.Now - ServerStarted;

                Console.WriteLine();

                log.Info("EMULATOR -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("Please check your configuration file - some values appear to be missing.", ConsoleColor.Red);
                Logging.WriteLine("Press any key to shut down ...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Failed to initialize PlusEmulator: " + e.Message, ConsoleColor.Red);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (Exception e)
            {
                Logging.WriteLine("Fatal error during startup: " + e, ConsoleColor.Red);
                Logging.WriteLine("Press a key to exit");

                Console.ReadKey();
                Environment.Exit(1);
            }
        }
        public static void Initialize()
        {
            string CurrentTime = DateTime.Now.ToString("HH:mm:ss" + " | ");

            ServerStarted        = DateTime.Now;
            Console.WindowWidth  = 120;
            Console.WindowHeight = 42;


            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(@" _   _       _     _     _     ");
            Console.WriteLine(@"| | | | __ _| |__ | |__ (_)___ ");
            Console.WriteLine(@"| |_| |/ _` | '_ \| '_ \| / __|");
            Console.WriteLine(@"|  _  | (_| | |_) | |_) | \__ \");
            Console.WriteLine(@"|_| |_|\__,_|_.__/|_.__/|_|___/");
            Console.WriteLine(@"                               ");
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Emulator »");
            Console.Title    = "Loading Quasar Emulator";
            _defaultEncoding = Encoding.Default;

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

            CultureInfo = CultureInfo.CreateSpecificCulture("en-GB");

            try
            {
                _configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"config.ini"));

                var connectionString = new MySqlConnectionStringBuilder
                {
                    ConnectionTimeout     = 10,
                    Database              = GetConfig().data["db.name"],
                    DefaultCommandTimeout = 30,
                    Logging             = false,
                    MaximumPoolSize     = uint.Parse(GetConfig().data["db.pool.maxsize"]),
                    MinimumPoolSize     = uint.Parse(GetConfig().data["db.pool.minsize"]),
                    Password            = GetConfig().data["db.password"],
                    Pooling             = true,
                    Port                = uint.Parse(GetConfig().data["db.port"]),
                    Server              = GetConfig().data["db.hostname"],
                    UserID              = GetConfig().data["db.username"],
                    AllowZeroDateTime   = true,
                    ConvertZeroDateTime = true,
                };

                _manager = new DatabaseManager(connectionString.ToString());

                if (!_manager.IsConnected())
                {
                    Console.WriteLine(CurrentTime + "» Kan geen verbinding maken met de database.");
                    Console.ReadKey(true);
                    Environment.Exit(1);
                    return;
                }
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine(CurrentTime + "» Heeft verbinding met de database.");
                Console.ResetColor();
                //Reset our statistics first.
                using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`");
                    dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0';");
                    dbClient.RunQuery("UPDATE `users` SET `online` = '0' WHERE `online` = '1'");
                    dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0'");
                }

                //Get the configuration & Game set.
                ConfigData = new ConfigData();
                _game      = new Game();

                //Have our encryption ready.
                HabboEncryptionV2.Initialize(new RSAKeys());

                //Make sure MUS is working.
                MusSystem = new MusSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(";")), 0);

                //Accept connections.
                _connectionManager = new ConnectionHandling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"]), GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                _connectionManager.init();

                _game.StartGameLoop();

                TimeSpan TimeUsed = DateTime.Now - ServerStarted;
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(CurrentTime + "» Emulator is opgestart! [" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms]");
                Console.ResetColor();
            }

            catch (KeyNotFoundException e)
            {
                Logging.WriteLine(CurrentTime + "Je configuratie is verkeerd ingesteld.", ConsoleColor.Red);
                Logging.WriteLine(CurrentTime + "Druk een toets in om af te sluiten..");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine(CurrentTime + "Fout bij het vinden van de Emulator Key." + e.Message, ConsoleColor.Red);
                Logging.WriteLine(CurrentTime + "Druk een toets in om af te sluiten..");
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (Exception e)
            {
                Logging.WriteLine(CurrentTime + "Relevante error tijdens het opstarten: " + e, ConsoleColor.Red);
                Logging.WriteLine(CurrentTime + "Druk een toets in om af te sluiten..");

                Console.ReadKey();
                Environment.Exit(1);
            }
        }
Esempio n. 6
0
        public void Initialize()
        {
            ServerStarted = DateTime.Now;
            TextManager.WritePhoenix();
            try
            {
                Configuration = new ConfigurationData("config.conf");
                DateTime now = DateTime.Now;

                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Gray;

                DatabaseServer server   = new DatabaseServer(GetConfig().data["db.hostname"], uint.Parse(GetConfig().data["db.port"]), GetConfig().data["db.username"], GetConfig().data["db.password"]);
                Database       database = new Database(GetConfig().data["db.name"], uint.Parse(GetConfig().data["db.pool.minsize"]), uint.Parse(GetConfig().data["db.pool.maxsize"]));
                DatabaseManager = new DatabaseManager(server, database);
                Game            = new Game(int.Parse(GetConfig().data["game.tcp.conlimit"]));

                Messages = new MessageHandler();
                Messages.RegisterHandshake();
                Messages.RegisterMessenger();
                Messages.RegisterNavigator();
                Messages.RegisterRoomsAction();
                Messages.RegisterRoomsAvatar();
                Messages.RegisterRoomsChat();
                Messages.RegisterRoomsEngine();
                Messages.RegisterRoomsFurniture();
                Messages.RegisterRoomsPets();
                Messages.RegisterRoomsSession();
                Messages.RegisterRoomsSettings();
                Messages.RegisterCatalog();
                Messages.RegisterMarketplace();
                Messages.RegisterRecycler();
                Messages.RegisterQuest();
                Messages.RegisterInventoryAchievements();
                Messages.RegisterInventoryAvatarFX();
                Messages.RegisterInventoryBadges();
                Messages.RegisterInventoryFurni();
                Messages.RegisterInventoryPurse();
                Messages.RegisterInventoryTrading();
                Messages.RegisterAvatar();
                Messages.RegisterUsers();
                Messages.RegisterRegister();
                Messages.RegisterHelp();
                Messages.RegisterSound();
                Messages.RegisterWired();
                Messages.RegisterFriendStream(); //NEW!

                MusListener       = new MusSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
                ConnectionManager = new TcpConnectionManager(GetConfig().data["game.tcp.bindip"], int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]));
                ConnectionManager.GetListener().Start();
                TimeSpan span = DateTime.Now - now;
                Logging.WriteLine(string.Concat(new object[] { "Server -> READY! (", span.Seconds, " s, ", span.Milliseconds, " ms)" }));
                Console.Beep();
            }
            catch (KeyNotFoundException)
            {
                Logging.WriteLine("Failed to boot, key not found.");
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Destroy();
            }
            catch (InvalidOperationException ex)
            {
                Logging.WriteLine("Failed to initialize PhoenixEmulator: " + ex.Message);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Destroy();
            }
        }
Esempio n. 7
0
        internal static void Initialize()
        {
            Console.Clear();
            DateTime Start = DateTime.Now;

            SystemMute = false;

            IrcEnabled           = false;
            ServerStarted        = DateTime.Now;
            Console.Title        = PiciEnvironment.Title + " " + PiciEnvironment.Version;
            Console.WindowHeight = 30;
            DefaultEncoding      = Encoding.Default;

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("");
            Console.WriteLine("          ______ _       _    _______             ");
            Console.WriteLine("         (_____ (_)     (_)  (_______)            ");
            Console.WriteLine("          _____) )  ____ _    _____   ____  _   _ ");
            Console.WriteLine(@"         |  ____/ |/ ___) |  |  ___) |    \| | | |");
            Console.WriteLine(@"         | |    | ( (___| |  | |_____| | | | |_| |");
            Console.WriteLine(@"         |_|    |_|\____)_|  |_______)_|_|_|____/ ");


            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("                              " + PiciEnvironment.Title + " " + PiciEnvironment.Version + " (Build " + PiciEnvironment.Build + ")");


            Console.WriteLine();

            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine();

            cultureInfo = CultureInfo.CreateSpecificCulture("en-GB");
            LanguageLocale.Init();

            try
            {
                ChatCommandRegister.Init();
                PetCommandHandeler.Init();
                PetLocale.Init();
                Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"config.conf"));

                DateTime Starts = DateTime.Now;

                dbType = DatabaseType.MySQL;

                manager = new DatabaseManager(uint.Parse(PiciEnvironment.GetConfig().data["db.pool.maxsize"]), uint.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), int.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), dbType);
                manager.setServerDetails(
                    PiciEnvironment.GetConfig().data["db.hostname"],
                    uint.Parse(PiciEnvironment.GetConfig().data["db.port"]),
                    PiciEnvironment.GetConfig().data["db.username"],
                    PiciEnvironment.GetConfig().data["db.password"],
                    PiciEnvironment.GetConfig().data["db.name"]);
                manager.init();

                TimeSpan TimeUsed2 = DateTime.Now - Starts;

                LanguageLocale.InitSwearWord();

                Game = new Game(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"]));
                Game.ContinueLoading();

                ConnectionManager = new ConnectionHandeling(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.port"]),
                                                            int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"]),
                                                            int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conperip"]),
                                                            PiciEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                ConnectionManager.init();

                ConnectionManager.Start();

                StaticClientMessageHandler.Initialize();
                ClientMessageFactory.Init();

                string[] arrayshit = PiciEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(","));

                MusSystem = new MusSocket(PiciEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(PiciEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0);

                //InitIRC();

                groupsEnabled = true;

                useSSO = true;

                TimeSpan TimeUsed = DateTime.Now - Start;

                Logging.WriteLine("Server -> Started! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
                isLive = true;

                Console.Beep();


                if (bool_0_12)
                {
                    Console.WriteLine("Coffee team, I appreciate you testing. ;-*");
                    System.Threading.Thread.Sleep(2500);
                    PreformShutDown(true);
                    return;
                }
            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("Please check your configuration file - some values appear to be missing.");
                Logging.WriteLine("Press any key to shut down ...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                PiciEnvironment.Destroy();

                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Failed to initialize PiciEmulator: " + e.Message);
                Logging.WriteLine("Press any key to shut down ...");

                Console.ReadKey(true);
                PiciEnvironment.Destroy();

                return;
            }

            catch (Exception e)
            {
                Console.WriteLine("Fatal error during startup: " + e.ToString());
                Console.WriteLine("Press a key to exit");

                Console.ReadKey();
                Environment.Exit(1);
            }
        }
Esempio n. 8
0
        internal static void Initialize()
        {
            Console.Clear();
            CyberEnvironment.ServerStarted = DateTime.Now;
            Console.SetWindowSize(120, 40);
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine();
            Console.WriteLine(@"                              ____ _   _ ___  ____ ____    ____ _  _ _  _ _    ____ ___ ____ ____ ");
            Console.WriteLine(@"                              |     \_/  |__] |___ |__/    |___ |\/| |  | |    |__|  |  |  | |__/ ");
            Console.WriteLine(@"                              |___   |   |__] |___ |  \    |___ |  | |__| |___ |  |  |  |__| |  \ ");
            Console.WriteLine();
            Console.WriteLine("                                                Cyber Emulator - Version: " + PrettyBuild);
            Console.WriteLine("                                         based on Plus, developed by Kessiler Rodrigues.");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("                                                 " + PrettyRelease);
            Console.Title = "Cyber Emulator | Loading data [...]";
            CyberEnvironment.DefaultEncoding = Encoding.Default;
            Console.WriteLine("");

            CyberEnvironment.cultureInfo = CultureInfo.CreateSpecificCulture("en-GB");
            TextHandling.replaceDecimal();
            try
            {
                CyberEnvironment.Configuration = new ConfigurationData(Path.Combine(Application.StartupPath, "config.ini"), false);


                MySqlConnectionStringBuilder mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder();
                mySqlConnectionStringBuilder.Server                = (CyberEnvironment.GetConfig().data["db.hostname"]);
                mySqlConnectionStringBuilder.Port                  = (uint.Parse(CyberEnvironment.GetConfig().data["db.port"]));
                mySqlConnectionStringBuilder.UserID                = (CyberEnvironment.GetConfig().data["db.username"]);
                mySqlConnectionStringBuilder.Password              = (CyberEnvironment.GetConfig().data["db.password"]);
                mySqlConnectionStringBuilder.Database              = (CyberEnvironment.GetConfig().data["db.name"]);
                mySqlConnectionStringBuilder.MinimumPoolSize       = (uint.Parse(CyberEnvironment.GetConfig().data["db.pool.minsize"]));
                mySqlConnectionStringBuilder.MaximumPoolSize       = (uint.Parse(CyberEnvironment.GetConfig().data["db.pool.maxsize"]));
                mySqlConnectionStringBuilder.Pooling               = (true);
                mySqlConnectionStringBuilder.AllowZeroDateTime     = (true);
                mySqlConnectionStringBuilder.ConvertZeroDateTime   = (true);
                mySqlConnectionStringBuilder.DefaultCommandTimeout = (300u);
                mySqlConnectionStringBuilder.ConnectionTimeout     = (10u);
                CyberEnvironment.manager = new DatabaseManager(mySqlConnectionStringBuilder.ToString());

                using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    ConfigData = new ConfigData(queryreactor);
                    PetLocale.Init(queryreactor);
                    OfflineMessages = new Dictionary <uint, List <OfflineMessage> >();
                    OfflineMessage.InitOfflineMessages(queryreactor);
                    GiftWrappers = new GiftWrappers(queryreactor);
                }

                FriendRequestLimit = (uint)int.Parse(CyberEnvironment.GetConfig().data["client.maxrequests"]);
                if (ExtraSettings.RunExtraSettings())
                {
                    Logging.WriteLine("Loaded an extra settings file.");
                }

                Game = new Game(int.Parse(GetConfig().data["game.tcp.conlimit"]));
                Game.start();

                ConnectionManager = new ConnectionHandling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"]), GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");

                HabboCrypto.Initialize(new RsaKeyHolder());
                CyberEnvironment.ConnectionManager.init();
                CyberEnvironment.ConnectionManager.Start();
                StaticClientMessageHandler.Initialize();

                string[] allowedIps = GetConfig().data["mus.tcp.allowedaddr"].Split(';');
                MusSystem = new MusSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), allowedIps, 0);


                if (Configuration.data.ContainsKey("StaffAlert.MinRank"))
                {
                    StaffAlertMinRank = uint.Parse(CyberEnvironment.GetConfig().data["StaffAlert.MinRank"]);
                }
                if (Configuration.data.ContainsKey("SeparatedTasksInMainLoops.enabled") && Configuration.data["SeparatedTasksInMainLoops.enabled"] == "true")
                {
                    SeparatedTasksInMainLoops = true;
                }
                if (Configuration.data.ContainsKey("SeparatedTasksInGameClientManager.enabled") && Configuration.data["SeparatedTasksInGameClientManager.enabled"] == "true")
                {
                    SeparatedTasksInGameClientManager = true;
                }
                Logging.WriteLine("Game was succesfully loaded.");
                isLive = true;
            }
            catch (KeyNotFoundException ex)
            {
                Logging.WriteLine("Something is missing in your configuration", ConsoleColor.Red);
                Logging.WriteLine(ex.ToString(), ConsoleColor.Yellow);
                Logging.WriteLine("Please type a key to shut down ...", ConsoleColor.Gray);
                Console.ReadKey(true);
                CyberEnvironment.Destroy();
            }
            catch (InvalidOperationException ex1)
            {
                Logging.WriteLine("Something wrong happened: " + ex1.Message, ConsoleColor.Red);
                Logging.WriteLine(ex1.ToString(), ConsoleColor.Yellow);
                Logging.WriteLine("Please type a key to shut down...", ConsoleColor.Gray);
                Console.ReadKey(true);
                CyberEnvironment.Destroy();
            }
            catch (Exception ex2)
            {
                Logging.WriteLine("An exception got caught: " + ex2.Message, ConsoleColor.Red);
                Logging.WriteLine("Type a key to know more about the error", ConsoleColor.Gray);
                Console.ReadKey();
                Logging.WriteLine(ex2.ToString(), ConsoleColor.Yellow);
                Logging.WriteLine("Please type a ket to shut down...", ConsoleColor.Gray);
                Console.ReadKey();
                Environment.Exit(1);
            }
        }
Esempio n. 9
0
        internal static void Initialize()
        {
            Console.Clear();
            DateTime Start = DateTime.Now;

            SystemMute = false;

            ServerStarted   = DateTime.Now;
            Console.Title   = "Loading Butterfly Emulator";
            DefaultEncoding = Encoding.Default;
            //Logging.rzFlag();
            Logging.WriteLine();
            Logging.WriteLine(PrettyVersion);



            cultureInfo = CultureInfo.CreateSpecificCulture("en-GB");
            LanguageLocale.Init();

            try
            {
                ChatCommandRegister.Init();
                PetCommandHandeler.Init();
                PetLocale.Init();
                Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"Settings/configuration.ini"));
                if (ButterflyEnvironment.GetConfig().data["db.password"] == "changeme")
                {
                    throw new ArgumentException("Your MySQL password may not be 'changeme'.\nChange your password to start the server.");
                }

                DateTime Starts = DateTime.Now;
                Logging.WriteLine("Connecting to database...");

                dbType = GetConfig().data.ContainsKey("db.mssql") && GetConfig().data["db.mssql"] == "true" ? DatabaseType.MSSQL : DatabaseType.MySQL;

                manager = new DatabaseManager(uint.Parse(ButterflyEnvironment.GetConfig().data["db.pool.maxsize"]), int.Parse(ButterflyEnvironment.GetConfig().data["db.pool.minsize"]), dbType);
                manager.setServerDetails(
                    ButterflyEnvironment.GetConfig().data["db.hostname"],
                    uint.Parse(ButterflyEnvironment.GetConfig().data["db.port"]),
                    ButterflyEnvironment.GetConfig().data["db.username"],
                    ButterflyEnvironment.GetConfig().data["db.password"],
                    ButterflyEnvironment.GetConfig().data["db.name"]);
                manager.init();

                TimeSpan TimeUsed2 = DateTime.Now - Starts;
                Logging.WriteLine("Connected to database! (" + TimeUsed2.Seconds + " s, " + TimeUsed2.Milliseconds + " ms)");

                LanguageLocale.InitSwearWord();

                Game = new Game(int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.conlimit"]));
                Game.ContinueLoading();

                ConnectionManager = new ConnectionHandeling(int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.port"]),
                                                            int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.conlimit"]),
                                                            int.Parse(ButterflyEnvironment.GetConfig().data["game.tcp.conperip"]),
                                                            ButterflyEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                ConnectionManager.init();

                ConnectionManager.Start();

                StaticClientMessageHandler.Initialize();
                ClientMessageFactory.Init();

                string[] arrayshit = ButterflyEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(","));

                MusSystem = new MusSocket(ButterflyEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(ButterflyEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0);

                groupsEnabled = false;
                if (Configuration.data.ContainsKey("groups.enabled"))
                {
                    if (Configuration.data["groups.enabled"] == "true")
                    {
                        groupsEnabled = true;
                    }
                }

                useSSO = true;
                if (Configuration.data.ContainsKey("auth.ssodisabled"))
                {
                    if (Configuration.data["auth.ssodisabled"] == "false")
                    {
                        useSSO = false;
                    }
                }

                TimeSpan TimeUsed = DateTime.Now - Start;

                Logging.WriteLine("ENVIRONMENT -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
                isLive = true;
                if (System.Diagnostics.Debugger.IsAttached || Configuration.data["debug.console"] == "1")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Logging.WriteLine("Server is debugging: Console writing enabled");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Logging.WriteLine("Server is not debugging: Console writing disabled");
                    Logging.DisablePrimaryWriting(false);
                }
            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("Please check your configuration file - some values appear to be missing.");
                Logging.WriteLine("Press any key to shut down ...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                ButterflyEnvironment.Destroy();

                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Failed to initialize ButterflyEmulator: " + e.Message);
                Logging.WriteLine("Press any key to shut down ...");

                Console.ReadKey(true);
                ButterflyEnvironment.Destroy();

                return;
            }

            catch (Exception e)
            {
                Console.WriteLine("Fatal error during startup: " + e.ToString());
                Console.WriteLine("Press a key to exit");

                Console.ReadKey();
                Environment.Exit(1);
            }
        }
Esempio n. 10
0
        public static void Initialize()
        {
            ServerStarted           = DateTime.Now;
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine();
            Console.WriteLine("                     ____  __           ________  _____  __");
            Console.WriteLine(@"                    / __ \/ /_  _______/ ____/  |/  / / / /");
            Console.WriteLine("                   / /_/ / / / / / ___/ __/ / /|_/ / / / / ");
            Console.WriteLine("                  / ____/ / /_/ (__  ) /___/ /  / / /_/ /  ");
            Console.WriteLine(@"                 /_/   /_/\__,_/____/_____/_/  /_/\____/ ");

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("                                " + PrettyVersion + " <Feito por " + PrettyBuild + ">");
            Console.WriteLine("                                suamae");

            Console.WriteLine("");
            Console.Title    = "Plus Emulador [Carregando...]";
            _defaultEncoding = Encoding.Default;

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

            CultureInfo = CultureInfo.CreateSpecificCulture("pt-BR");


            try
            {
                _configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"config.ini"));

                var connectionString = new MySqlConnectionStringBuilder
                {
                    ConnectionTimeout     = 60,
                    Database              = GetConfig().data["db.name"],
                    DefaultCommandTimeout = 120,
                    Logging             = false,
                    MaximumPoolSize     = uint.Parse(GetConfig().data["db.pool.maxsize"]),
                    MinimumPoolSize     = uint.Parse(GetConfig().data["db.pool.minsize"]),
                    Password            = GetConfig().data["db.password"],
                    Pooling             = true,
                    Port                = uint.Parse(GetConfig().data["db.port"]),
                    Server              = GetConfig().data["db.hostname"],
                    UserID              = GetConfig().data["db.username"],
                    AllowZeroDateTime   = true,
                    ConvertZeroDateTime = true,
                };

                _manager = new DatabaseManager(connectionString.ToString());

                if (!_manager.IsConnected())
                {
                    log.Error("Falha ao conectar ao específico servidor MySQL.");
                    Console.ReadKey(true);
                    Environment.Exit(1);
                    return;
                }


                log.Info("Conectado a database!");

                //Reset our statistics first.
                int randomInt = ((System.Diagnostics.Debugger.IsAttached) ? 0 : 1);
                using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`");
                    dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0';");
                    dbClient.RunQuery("UPDATE `users` SET `online` = '0' WHERE `online` = '1'");
                    dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0', `environment_status` = '" + randomInt + "'");
                }

                //Get the configuration & Game set.
                ConfigData = new ConfigData();
                _game      = new Game();

                //Have our encryption ready.
                HabboEncryptionV2.Initialize(new RSAKeys());

                //Make sure MUS is working.
                MusSystem = new MusSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(";")), 0);

                //Accept connections.
                _connectionManager = new ConnectionHandling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"]), GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                _connectionManager.init();

                _game.StartGameLoop();

                TimeSpan TimeUsed = DateTime.Now - ServerStarted;

                Console.WriteLine();

                log.Info("EMULATOR -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("Verifique o seu arquivo de configuração - alguns valores parecem estar faltando.", ConsoleColor.Red);
                Logging.WriteLine("Pressione qualquer tecla para desligar...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Falha ao inicializar Plus Emulador: " + e.Message, ConsoleColor.Red);
                Logging.WriteLine("Pressione qualquer tecla para desligar...");
                Console.ReadKey(true);
                Environment.Exit(1);
                return;
            }
            catch (Exception e)
            {
                Logging.WriteLine("Erro fatal para iniciar: " + e, ConsoleColor.Red);
                Logging.WriteLine("Pressione qualquer tecla para fechar.");

                Console.ReadKey();
                Environment.Exit(1);
            }


            RoleplayBotManager.Initialize(false);
        }