예제 #1
0
        internal static Habbo getHabboForName(string UserName)
        {
            Habbo result;

            try
            {
                using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor.setQuery("SELECT id FROM users WHERE username = @user");
                    queryreactor.addParameter("user", UserName);
                    int integer = queryreactor.getInteger();
                    if (integer > 0)
                    {
                        result = CyberEnvironment.getHabboForId(checked ((uint)integer));
                        return(result);
                    }
                }
                result = null;
            }
            catch
            {
                result = null;
            }
            return(result);
        }
예제 #2
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);
            }
        }