示例#1
0
        internal static void Initialize()
        {
            if (!Debugger.IsAttached)
            {
                /*                LicenceProvider License = new LicenceProvider();
                                string MachineId = License.GetUniqueId();

                                try
                                {
                                    WebClient Client = new WebClient();
                                    string Request = Client.DownloadString("http://auth.so/" + MachineId);

                                    if (Request != "true")
                                    {
                                        Console.WriteLine();
                                        Console.WriteLine("     Machine ID: " + MachineId);
                                        Console.WriteLine();
                                        Console.WriteLine("     You are not authorised to use this software!");
                                        Console.ReadKey();

                                        Environment.Exit(0);
                                    }
                                }
                                catch (Exception e)
                                {
                                    e.ToString();

                                    Console.WriteLine();
                                    Console.WriteLine("     Machine ID: " + MachineId);
                                    Console.WriteLine();
                                    Console.WriteLine("     It seems there's a problem with the auth servers!");
                                    Console.WriteLine("     If this problem persists, please create a thread on the forums.");
                                    Console.ReadKey();
                                }
                            }
                */
            }
            Console.Clear();

            DateTime Start = DateTime.Now;
            ServerStarted = DateTime.Now;
            //Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine();

            Console.WriteLine(@"      ___                       ___           ___     ");
            Console.WriteLine(@"     /  /\                     /__/\         /  /\    ");
            Console.WriteLine(@"    /  /::\                    \  \:\       /  /:/_   ");
            Console.WriteLine(@"   /  /:/\:\  ___     ___       \  \:\     /  /:/ /\  ");
            Console.WriteLine(@"  /  /:/~/:/ /__/\   /  /\  ___  \  \:\   /  /:/ /::\ ");
            Console.WriteLine(@" /__/:/ /:/  \  \:\ /  /:/ /__/\  \__\:\ /__/:/ /:/\:\ ");
            Console.WriteLine(@" \  \:\/:/    \  \:\  /:/  \  \:\ /  /:/ \  \:\/:/~/:/");
            Console.WriteLine(@"  \  \::/      \  \:\/:/    \  \:\  /:/   \  \::/ /:/ ");
            Console.WriteLine(@"   \  \:\       \  \::/      \  \:\/:/     \__\/ /:/  ");
            Console.WriteLine(@"    \  \:\       \__\/        \  \::/        /__/:/   ");
            Console.WriteLine(@"     \__\/                     \__\/         \__\/    ");

            //Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Plus Emulator R2.1 -> RELEASE63-201405071257-197450526");
            Console.WriteLine("Support and Fixes : http://goo.gl/unG1L3 --- Head Dev: AKllX");

            Console.WriteLine("");
            Console.Title = "Loading Silverwave Emulator";
            DefaultEncoding = Encoding.Default;

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

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

            #region Environment Data Loading
            try
            {
                Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"config.ini"));

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

                manager = new DatabaseManager(connectionString.ToString());
                globalCrypto = new HabboEncryption.HabboEncryption();

                Logging.WriteLine("Connected to database!", ConsoleColor.Green);

                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    //Loading Default
                    ConfigData = new ConfigData(dbClient);
                    PetCommandHandeler.Init(dbClient);
                    LanguageLocale.InitSwearWord(dbClient);
                    PetLocale.Init(dbClient);
                    LanguageLocale.Init(dbClient);
                    OfflineMessages = new Dictionary<uint, List<OfflineMessage>>();
                    OfflineMessage.InitOfflineMessages(dbClient);

                    //Loading GiftsWrappers
                    GiftWrapper = new GiftWrappers(dbClient);
                }

                friendRequestLimit = (uint)(int.Parse(SilverwaveEnvironment.GetConfig().data["client.maxrequests"]));

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

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

                StaticClientMessageHandler.Initialize();

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

                MusSystem = new MusSocket(SilverwaveEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(SilverwaveEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0);
                useSSO = false;
                if (Configuration.data.ContainsKey("auth.ssodisabled"))
                {
                    if (Configuration.data["auth.ssodisabled"] == "true")
                    {
                        useSSO = true;
                    }
                }
                if (Configuration.data.ContainsKey("seasonal.currency.indicator"))
                {
                    LiveCurrencyType = int.Parse(SilverwaveEnvironment.GetConfig().data["seasonal.currency.indicator"]);
                }

                if (Configuration.data.ContainsKey("spambans.enabled"))
                {
                    if (Configuration.data["spambans.enabled"] == "true")
                    {
                        spamBans = true;
                        spamBans_limit = Convert.ToInt32(Configuration.data["spambans.limit"]);
                    }
                }
                if (Configuration.data.ContainsKey("SeparatedTasksInMainLoops.enabled"))
                {
                    if (Configuration.data["SeparatedTasksInMainLoops.enabled"] == "true")
                    {
                        SeparatedTasksInMainLoops = true;
                    }
                }

                if (Configuration.data.ContainsKey("SeparatedTasksInGameClientManager.enabled"))
                {
                    if (Configuration.data["SeparatedTasksInGameClientManager.enabled"] == "true")
                    {
                        SeparatedTasksInGameClientManager = true;
                    }
                }
            #endregion

                TimeSpan TimeUsed = DateTime.Now - Start;
               // while ((System.Diagnostics.Process.GetProcessesByName("MangoFastFood").Length == 0))
                {
                 //   Logging.WriteLine("Run FastFood Emulator!", ConsoleColor.Red);
                }
                Logging.WriteLine("Silverwave -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)", ConsoleColor.Yellow);
                isLive = true;
            }
            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);
                SilverwaveEnvironment.Destroy();

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

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

                return;
            }

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

                Console.ReadKey();
                Environment.Exit(1);
            }
        }
        internal static void Initialize()
        {
            if (!Debugger.IsAttached)
            {
                /*                LicenceProvider License = new LicenceProvider();
                                string MachineId = License.GetUniqueId();

                                try
                                {
                                    WebClient Client = new WebClient();
                                    string Request = Client.DownloadString("http://auth.so/" + MachineId);

                                    if (Request != "true")
                                    {
                                        Console.WriteLine();
                                        Console.WriteLine("     Machine ID: " + MachineId);
                                        Console.WriteLine();
                                        Console.WriteLine("     You are not authorised to use this software!");
                                        Console.ReadKey();

                                        Environment.Exit(0);
                                    }
                                }
                                catch (Exception e)
                                {
                                    e.ToString();

                                    Console.WriteLine();
                                    Console.WriteLine("     Machine ID: " + MachineId);
                                    Console.WriteLine();
                                    Console.WriteLine("     It seems there's a problem with the auth servers!");
                                    Console.WriteLine("     If this problem persists, please create a thread on the forums.");
                                    Console.ReadKey();
                                }
                            }
                */
            }
            Console.Clear();

            DateTime Start = DateTime.Now;
            ServerStarted = DateTime.Now;
            //Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine(@"
               __________  ___    ____  __  __
              / ____/ __ \/   |  / __ \/ / / /
             / / __/ /_/ / /| | / /_/ / /_/ /
            / /_/ / _, _/ ___ |/ ____/ __  /
            \____/_/ |_/_/  |_/_/   /_/ /_/");

            Console.WriteLine("");
            Console.Title = "[ GRAPHIC: CARGANDO... ]";
            DefaultEncoding = Encoding.Default;

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

            #region Environment Data Loading
            try
            {
                Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"config.ini"));

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

                manager = new DatabaseManager(connectionString.ToString());
                globalCrypto = new HabboEncryption.HabboEncryption();

                Logging.WriteLine("Conexión a la base de datos realizada.", ConsoleColor.Gray);

                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    //Loading Default;
                    ConfigData = new ConfigData(dbClient);
                    PetCommandHandeler.Init(dbClient);
                    LanguageLocale.InitSwearWord(dbClient);
                    PetLocale.Init(dbClient);
                    LanguageLocale.Init(dbClient);
                    OfflineMessages = new Dictionary<uint, List<OfflineMessage>>();
                    OfflineMessage.InitOfflineMessages(dbClient);

                    //Loading GiftsWrappers;
                    GiftWrapper = new GiftWrappers(dbClient);
                }

                friendRequestLimit = (uint)(int.Parse(SilverwaveEnvironment.GetConfig().data["client.maxrequests"]));

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

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

                StaticClientMessageHandler.Initialize();

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

                MusSystem = new MusSocket(SilverwaveEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(SilverwaveEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0);
                useSSO = false;
                if (Configuration.data.ContainsKey("auth.ssodisabled"))
                {
                    if (Configuration.data["auth.ssodisabled"] == "true")
                    {
                        useSSO = true;
                    }
                }
                if (Configuration.data.ContainsKey("seasonal.currency.indicator"))
                {
                    LiveCurrencyType = int.Parse(SilverwaveEnvironment.GetConfig().data["seasonal.currency.indicator"]);
                }

                if (Configuration.data.ContainsKey("spambans.enabled"))
                {
                    if (Configuration.data["spambans.enabled"] == "true")
                    {
                        spamBans = true;
                        spamBans_limit = Convert.ToInt32(Configuration.data["spambans.limit"]);
                    }
                }
                if (Configuration.data.ContainsKey("SeparatedTasksInMainLoops.enabled"))
                {
                    if (Configuration.data["SeparatedTasksInMainLoops.enabled"] == "true")
                    {
                        SeparatedTasksInMainLoops = true;
                    }
                }

                if (Configuration.data.ContainsKey("SeparatedTasksInGameClientManager.enabled"))
                {
                    if (Configuration.data["SeparatedTasksInGameClientManager.enabled"] == "true")
                    {
                        SeparatedTasksInGameClientManager = true;
                    }
                }
            #endregion

                TimeSpan TimeUsed = DateTime.Now - Start;
               // while ((System.Diagnostics.Process.GetProcessesByName("MangoFastFood").Length == 0))
                {
                 //   Logging.WriteLine("Run FastFood Emulator!", ConsoleColor.Red);
                }
                Logging.WriteLine("Graphic ha cargado satisfactoriamente en " + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms", ConsoleColor.Yellow);
                isLive = true;
            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("TU ARCHIVO DE CONFIGURACIÓN PARECE ESTAR FALLANDO - REVÍSALO", ConsoleColor.Red);
                Logging.WriteLine("PULSA CUALQUIER TECLA PARA APAGAR EL EMULADOR");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                SilverwaveEnvironment.Destroy();

                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("ERROR: " + e.Message, ConsoleColor.Blue);
                Logging.WriteLine("PULSA CUALQUIER TECLA PARA APAGAR EL EMULADOR");

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

                return;
            }

            catch (Exception e)
            {
                Logging.WriteLine("ERROR FATAL INICIANDO GRAPHIC: " + e.ToString(), ConsoleColor.Red);
                Logging.WriteLine("PULSA CUALQUIER TECLA PARA APAGAR EL EMULADOR");

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