/// <summary> /// Constructor of the DataHandling class. Saves the parameters and starts a new Thread. /// </summary> /// <param name="data">The incoming data.</param> /// <param name="connection">The ConnectionHandling instance that is creating this instance.</param> /// <param name="closeAfterResponse">If the server should tell the client to close the connection after the following response or not.</param> public DataHandling(string data, ConnectionHandling connection, bool closeAfterResponse) { this.closeAfterResponse = closeAfterResponse; this.data = data; this.connection = connection; Thread handleData = new Thread(HandleData); handleData.IsBackground = false; handleData.Start(); threadID = connection.totalThreads; }
/// <summary> /// Creates a new ConnectionHandling instance when a new client establishes a connection. /// </summary> void Listen() { while (true) { if (DebugLevel <= 0) { Console.WriteLine("\nHandled Connections: " + totalConnections + " Waiting for a connection..."); } Socket handler = listener.Accept(); ConnectionHandling client = new ConnectionHandling(handler, totalConnections); totalConnections++; } }
public static void Main(string[] args) { var stopwatch = Stopwatch.StartNew(); Console.ForegroundColor = ConsoleColor.White; Console.CursorVisible = false; AppDomain.CurrentDomain.UnhandledException += Dispose; try { _configuration = new ConfigHandler(Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + "\\Config\\config.ini"); DatabaseManager = new DatabaseManager(_configuration); LanguageManager = new LanguageManager(); SettingsManager = new SettingsManager(); FigureManager = new FigureDataManager(); RconSocket = new RconSocket(_configuration["rcon.tcp.bindip"], int.Parse(_configuration["rcon.tcp.port"]), _configuration["rcon.tcp.allowedaddr"].Split(Convert.ToChar(";"))); GameContext = new GameContext { PacketManager = new PacketManager(), PlayerController = new PlayerController() }; _connectionManager = new ConnectionHandling(int.Parse(_configuration["game.tcp.port"]), int.Parse(_configuration["game.tcp.conlimit"]), int.Parse(_configuration["game.tcp.conperip"]), _configuration["game.tcp.enablenagles"].ToLower() == "true"); new ServerStatusUpdater(); Console.WriteLine(); ServerStarted = DateTime.Now; stopwatch.Stop(); Logger.Debug("Emulator has finished loading. (took " + stopwatch.ElapsedMilliseconds / 1000 + " s, " + (stopwatch.ElapsedMilliseconds - stopwatch.ElapsedMilliseconds / 1000 * 1000) + " ms)"); } catch (Exception e) { Logger.Error(e); throw; } KeepAlive(); }
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. _languageManager = new LanguageManager(); _languageManager.Init(); _settingsManager = new SettingsManager(); _settingsManager.Init(); _figureManager = new FigureDataManager(); _figureManager.Init(); //Have our encryption ready. HabboEncryptionV2.Initialize(new RSAKeys()); //Make sure RCON is connected before we allow clients to connect. _rcon = new RCONSocket(GetConfig().data["rcon.tcp.bindip"], int.Parse(GetConfig().data["rcon.tcp.port"]), GetConfig().data["rcon.tcp.allowedaddr"].Split(Convert.ToChar(";"))); //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 = new Game(); _game.StartGameLoop(); TimeSpan TimeUsed = DateTime.Now - ServerStarted; Console.WriteLine(); log.Info("EMULATOR -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); } catch (KeyNotFoundException e) { log.Error("Please check your configuration file - some values appear to be missing."); log.Error("Press any key to shut down ..."); Console.ReadKey(true); Environment.Exit(1); return; } catch (InvalidOperationException e) { log.Error("Failed to initialize PlusEmulator: " + e.Message); log.Error("Press any key to shut down ..."); Console.ReadKey(true); Environment.Exit(1); return; } catch (Exception e) { log.Error("Fatal error during startup: " + e); log.Error("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.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); } }
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); } }
internal static void Initialize() { PrettyVersion = string.Format("Firewind {0}", Assembly.GetExecutingAssembly().GetName().Version); Console.Clear(); DateTime Start = DateTime.Now; SystemMute = false; ServerStarted = DateTime.Now; Console.Title = "Firewind: Loading environment."; Logging.WriteWithColor(" _______ __ __ __ ", ConsoleColor.Cyan); Logging.WriteWithColor(" | ___|__|.----.-----.--.--.--.|__|.-----.--| |", ConsoleColor.Cyan); Logging.WriteWithColor(" | ___| || _| -__| | | || || | _ |", ConsoleColor.Cyan); Logging.WriteWithColor(" |___| |__||__| |_____|________||__||__|__|_____|", ConsoleColor.Cyan); Logging.WriteLine(""); Logging.WriteLine("=============================================================="); DefaultEncoding = Encoding.Default; Logging.WriteLine(" " + PrettyVersion); Logging.WriteLine(string.Format(" Licenced to {0}", LicenseHolder)); Logging.WriteLine(string.Format(" Maximum players: {0}", MaxUsers == 0 ? "Unlimited!" : MaxUsers.ToString())); Logging.WriteLine(""); Logging.WriteLine(" Go to the GitHub repo for bug reporting/contributions!"); cultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); IsDebugging = IsDebugging ? System.Diagnostics.Debugger.IsAttached : false; try { LanguageLocale.Init(); ChatCommandRegister.Init(); PetCommandHandeler.Init(); PetLocale.Init(); if (IsDebugging) { Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"Settings_test/configuration.ini")); } else { Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"Settings/configuration.ini")); } DateTime Starts = DateTime.Now; Logging.WriteLine("Connecting to database..."); manager = new DatabaseManager(uint.Parse(FirewindEnvironment.GetConfig().data["db.pool.maxsize"]), int.Parse(FirewindEnvironment.GetConfig().data["db.pool.minsize"])); manager.setServerDetails( FirewindEnvironment.GetConfig().data["db.hostname"], uint.Parse(FirewindEnvironment.GetConfig().data["db.port"]), FirewindEnvironment.GetConfig().data["db.username"], FirewindEnvironment.GetConfig().data["db.password"], FirewindEnvironment.GetConfig().data["db.name"]); manager.init(); TimeSpan TimeUsed2 = DateTime.Now - Starts; Logging.WriteLine("Connected to database! (" + TimeUsed2.Seconds + " s, " + TimeUsed2.Milliseconds + " ms)"); LanguageLocale.InitSwearWord(); friendRequestLimit = (uint)(int.Parse(FirewindEnvironment.GetConfig().data["client.maxrequests"])); Game = new Game(int.Parse(FirewindEnvironment.GetConfig().data["game.tcp.conlimit"])); Game.ContinueLoading(); ConnectionManager = new ConnectionHandling(int.Parse(FirewindEnvironment.GetConfig().data["game.tcp.port"]), MaxUsers, int.Parse(FirewindEnvironment.GetConfig().data["game.tcp.conperip"]), FirewindEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true"); ConnectionManager.init(); ConnectionManager.Start(); StaticClientMessageHandler.Initialize(); ClientMessageFactory.Init(); string[] arrayshit = FirewindEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(';'); MusSystem = new RConListener(FirewindEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(FirewindEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0); useSSO = true; if (Configuration.data.ContainsKey("auth.ssodisabled")) { if (Configuration.data["auth.ssodisabled"] == "false") { useSSO = false; } } if (Configuration.data.ContainsKey("spambans.enabled")) { if (Configuration.data["spambans.enabled"] == "true") { spamBans = true; spamBans_limit = Convert.ToInt32(Configuration.data["spambans.limit"]); Logging.WriteLine("Spam Bans enabled"); } } if (Configuration.data.ContainsKey("SeparatedTasksInMainLoops.enabled")) { if (Configuration.data["SeparatedTasksInMainLoops.enabled"] == "true") { SeparatedTasksInMainLoops = true; Logging.WriteLine("MultiTasking in MainLoop"); } } if (Configuration.data.ContainsKey("SeparatedTasksInGameClientManager.enabled")) { if (Configuration.data["SeparatedTasksInGameClientManager.enabled"] == "true") { SeparatedTasksInGameClientManager = true; Logging.WriteLine("MultiTasking in ClientManager"); } } TimeSpan TimeUsed = DateTime.Now - Start; Logging.WriteWithColor("Firewind -> READY! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)", ConsoleColor.Cyan); isLive = true; if (System.Diagnostics.Debugger.IsAttached) { Logging.WriteLine("Server is debugging: Console writing enabled", true); } else { Logging.WriteLine("Server is not debugging: Console writing disabled", false); 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); FirewindEnvironment.Destroy(); return; } catch (InvalidOperationException e) { Logging.WriteLine("Failed to initialize Firewind Emulator: " + e.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); FirewindEnvironment.Destroy(); return; } catch (Exception e) { Logging.WriteLine("Fatal error during startup: " + e.ToString()); Logging.WriteLine("Press a key to exit"); Console.ReadKey(); Environment.Exit(1); } // Check if this is habin or not try { using (IQueryAdapter dbClient = manager.getQueryreactor()) { dbClient.setQuery("SELECT column_name FROM information_schema.columns WHERE table_schema = '" + FirewindEnvironment.GetConfig().data["db.name"] + "' AND table_name = 'users' AND column_name = 'hpo'"); IsHabin = dbClient.findsResult(); } } catch { } }
public static void Initialize() { ServerStarted = DateTime.Now; Console.WindowWidth = 110; Console.WindowHeight = 45; Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); Console.WriteLine(@" Dual Server" + PrettyBuild + " " + VersionCloud + " / Créditos: Xjoao,Paulo!"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine( Console.LargestWindowWidth > 30 ? @"-------------------------------------------------------------------------------------------------------------" : @""); Console.WriteLine(""); _defaultEncoding = Encoding.Default; Console.Title = "Dual Server | Carregando..."; CultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); try { _configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"Settings/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.Warn("» Ya existe una conexión a la base de datos o hay un problema al conectarse con ella."); Console.ReadKey(true); Environment.Exit(1); return; } log.Info("» Conectado a la Base de datos!"); #region Add 2016 HotelName = Convert.ToString(GetConfig().data["hotel.name"]); Licenseto = Convert.ToString(GetConfig().data["license"]); #endregion Add 2016 //Reset our statistics first. using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("TRUNCATE `catalog_marketplace_data`"); dbClient.runFastQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0'"); dbClient.runFastQuery("UPDATE `users` SET `online` = '0' WHERE `online` = '1'"); dbClient.runFastQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0', `status` = '1'"); } _game = new Game(); _game.ContinueLoading(); //Have our encryption ready. HabboEncryptionV2.Initialize(new RSAKeys()); //Make sure MUS is working. _rcon = new RCONSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(";"))); //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(); Console.ForegroundColor = ConsoleColor.Green; log.Info("» CLOUD SERVER -> LISTO!! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); Console.ResetColor(); IsLive = true; } catch (KeyNotFoundException e) { log.ErrorFormat("Please check your configuration file - some values appear to be missing.", ConsoleColor.Red); log.Error("Press any key to shut down ..."); ExceptionLogger.LogException(e); Console.ReadKey(true); Environment.Exit(1); return; } catch (InvalidOperationException e) { log.Error("Failed to initialize CloudServer: " + e.Message); log.Error("Press any key to shut down ..."); Console.ReadKey(true); Environment.Exit(1); return; } catch (Exception e) { log.Error("Fatal error during startup: " + e); log.Error("Press a key to exit"); Console.ReadKey(); Environment.Exit(1); } }
public static void Initialize() { ServerStarted = DateTime.Now; Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(""); Console.WriteLine(@"© 2016 - 2017 SaoDev Corporation Ltd. Todos os direitos reservados ao Thiago Araujo."); Console.WriteLine(""); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine( Console.LargestWindowWidth > 30 ? @"-------------------------------------------------------------------------------------------------------------" : @""); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); _defaultEncoding = Encoding.Default; Console.Write("VERIFICANDO LICENSIA: "); string passthiago = "servidoresdabiosdevCreditosThiagoAraujoSAODevLTDHappy"; if (ExtraSettings.LICENSE != passthiago) { Console.Clear(); } else { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(@" ( ( ) * ) ) ( "); Console.WriteLine(@" )\ ( ( )\ ) ( ( /( ` ) /(( /(( ) ( ( )\ ( ) ( ( "); Console.WriteLine(@" (((_) )( ))\(()/( )\ )\())( ( ( )(_))\())\ ( /( )\))( ( ((((_)( )( ( /( ))\ )\ ( "); Console.WriteLine(@" )\___(()\ /((_)((_))(_)_))/ )\ )\ _ (_(_())(_)((_))(_))(_))\ )\ )\ _ )(()\ )(_))/((_)(_) )\ "); Console.WriteLine(@" ((/ __|((_)_)) _| | (_) |_ ((_)(_)_) |_ _| |(_)_)(_)_ (()(_)(_) (_)_\(_)(_)(_)_(_))( ! ((_) "); Console.WriteLine(@" | (__| '_/ -_) _` | | | _/ _ (_-<_ | | | ' \| / _` / _` / _ \ / _ \| '_/ _` | || || / _ \ "); Console.WriteLine(@" \___|_| \___\__,_| |_|\__\___/__(_) |_| |_||_|_\__,_\__, \___/ /_/ \_\_| \__,_|\_,_|/ \___/ "); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.Title = ("BIOSEMU - OPS ALGO ESTA ERRADO COM SUA LICENSIA!"); Console.Clear(); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(@" ( ( ) * ) ) ( "); Console.WriteLine(@" )\ ( ( )\ ) ( ( /( ` ) /(( /(( ) ( ( )\ ( ) ( ( "); Console.WriteLine(@" (((_) )( ))\(()/( )\ )\())( ( ( )(_))\())\ ( /( )\))( ( ((((_)( )( ( /( ))\ )\ ( "); Console.WriteLine(@" )\___(()\ /((_)((_))(_)_))/ )\ )\ _ (_(_())(_)((_))(_))(_))\ )\ )\ _ )(()\ )(_))/((_)(_) )\ "); Console.WriteLine(@" ((/ __|((_)_)) _| | (_) |_ ((_)(_)_) |_ _| |(_)_)(_)_ (()(_)(_) (_)_\(_)(_)(_)_(_))( ! ((_) "); Console.WriteLine(@" | (__| '_/ -_) _` | | | _/ _ (_-<_ | | | ' \| / _` / _` / _ \ / _ \| '_/ _` | || || / _ \ "); Console.WriteLine(@" \___|_| \___\__,_| |_|\__\___/__(_) |_| |_||_|_\__,_\__, \___/ /_/ \_\_| \__,_|\_,_|/ \___/ "); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" Licensia do emulador não é valida para o BiosEmulador, Fale com o dono do pack (Thiago Araujo)!"); Console.WriteLine(" "); Console.WriteLine(" Clique em qualquer tecla para desligar o BIOSEMU"); Console.ReadKey(); Environment.Exit(1); } Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(@" ( ) ( * ( ( ) ( "); Console.WriteLine(@" ( )\ ) ( /( )\ ) ( ` )\ ) ( )\ ) ( /( )\ ) "); Console.WriteLine(@" ( )\(()/( )\())(()/( ( )\))( ( (()/( )\ (()/( )\())(()/( "); Console.WriteLine(@" )((_)/(_))(_)\ /(_)) )\ ((_)()\ )\ /(_))(((_)( /(_))((_)\ /(_)) "); Console.WriteLine(@" ((_)_(_)) ((_)(_)) ((_)(_()((_)_ ((_)_)) )\ _ )(_))_ ((_)(_)) "); Console.WriteLine(@" | _ )_ _| / _ \/ __| | __| \/ | | | | | (_)_\(_) \ / _ \| _ \ "); Console.WriteLine(@" | _ \| | | (_) \__ \ | _|| |\/| | |_| | |__ / _ \ | |) | (_) | / "); Console.WriteLine(@" |___/___| \___/|___/ |___|_| |_|\___/|____|/_/ \_\|___/ \___/|_|_\ "); Console.WriteLine(""); Console.WriteLine(@"© 2016 - 2017 SaoDev Corporation Ltd. Todos os direitos reservados ao Thiago Araujo."); Console.WriteLine(""); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine( Console.LargestWindowWidth > 30 ? @"-------------------------------------------------------------------------------------------------------------" : @""); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Gray; Console.Title = "BIOS EMULADOR | Carregando..."; CultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); try { _configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"BiosConfingThiago/ConfigBiosEmuThiago.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.Warn("» Existe uma conexão com o banco de dados já existente ou há um problema para se conectar a ele."); Console.ReadKey(true); Environment.Exit(1); return; } log.Info("» Conectado ao banco de dados!"); #region Add 2016 HotelName = Convert.ToString(GetConfig().data["hotel.name"]); Licenseto = Convert.ToString(GetConfig().data["license"]); #endregion Add 2016 //Reset our statistics first. using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("TRUNCATE `catalog_marketplace_data`"); dbClient.runFastQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0'"); dbClient.runFastQuery("UPDATE `users` SET `online` = '0' WHERE `online` = '1'"); dbClient.runFastQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0', `status` = '1'"); } _game = new Game(); _game.ContinueLoading(); //Have our encryption ready. HabboEncryptionV2.Initialize(new RSAKeys()); //Make sure MUS is working. _rcon = new RCONSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(";"))); //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; Quartovip = int.Parse(GetConfig().data["Quartovip"]); Prisao = int.Parse(GetConfig().data["Prisao"]); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; log.Info("» BIOSEMULADOR -> LISTO!! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); Console.ResetColor(); IsLive = true; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(""); Console.WriteLine( Console.LargestWindowWidth > 30 ? @"-------------------------------------------------------------------------------------------------------------" : @""); Console.ForegroundColor = ConsoleColor.Gray; } catch (KeyNotFoundException e) { log.ErrorFormat("Verifique o seu arquivo de configuração - alguns valores parecem estar faltando.", ConsoleColor.Red); log.Error("Pressione qualquer tecla para desligar ..."); ExceptionLogger.LogException(e); Console.ReadKey(true); Environment.Exit(1); return; } catch (InvalidOperationException e) { log.Error("Falha ao inicializar BIOS EMULADOR:" + e.Message); log.Error("Pressione qualquer tecla para desligar ..."); Console.ReadKey(true); Environment.Exit(1); return; } catch (Exception e) { log.Error("Erro fatal durante a inicialização:" + e); log.Error("Pressione uma tecla para sair"); Console.ReadKey(); Environment.Exit(1); } }
/// <summary> /// Main Void, Initializes the Emulator. /// </summary> internal static void Initialize() { #region Precheck Console.Title = "CityRP está iniciando.."; ServerStarted = DateTime.Now; _defaultEncoding = Encoding.Default; #endregion Precheck #region Database Connection CultureInfo = CultureInfo.CreateSpecificCulture("en-GB"); try { ConfigurationData.Load(Path.Combine(Application.StartupPath, "Settings/main.ini"), false); RoleplayData.Load(Path.Combine(Application.StartupPath, "Settings/Roleplay/settings.ini"), true); DatabaseConnectionType = ConfigurationData.Data["db.type"]; var mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder { Server = (ConfigurationData.Data["db.hostname"]), Port = (uint.Parse(ConfigurationData.Data["db.port"])), UserID = (ConfigurationData.Data["db.username"]), Password = (ConfigurationData.Data["db.password"]), Database = (ConfigurationData.Data["db.name"]), MinimumPoolSize = (uint.Parse(ConfigurationData.Data["db.pool.minsize"])), MaximumPoolSize = (uint.Parse(ConfigurationData.Data["db.pool.maxsize"])), Pooling = (true), AllowZeroDateTime = (true), ConvertZeroDateTime = (true), DefaultCommandTimeout = (300), ConnectionTimeout = (10) }; var mySqlConnectionStringBuilder2 = mySqlConnectionStringBuilder; Manager = new DatabaseManager(mySqlConnectionStringBuilder2.ToString(), DatabaseConnectionType); using (var queryReactor = GetDatabaseManager().GetQueryReactor()) { ConfigData = new ConfigData(queryReactor); PetCommandHandler.Init(queryReactor); PetLocale.Init(queryReactor); OfflineMessages = new Dictionary <uint, List <OfflineMessage> >(); OfflineMessage.InitOfflineMessages(queryReactor); } #endregion Database Connection #region Packets Registering ConsoleTimer = (int.Parse(ConfigurationData.Data["console.clear.time"])); ConsoleTimerOn = (bool.Parse(ConfigurationData.Data["console.clear.enabled"])); FriendRequestLimit = ((uint)int.Parse(ConfigurationData.Data["client.maxrequests"])); LibraryParser.Incoming = new Dictionary <int, LibraryParser.StaticRequestHandler>(); LibraryParser.Library = new Dictionary <string, string>(); LibraryParser.Outgoing = new Dictionary <string, int>(); LibraryParser.Config = new Dictionary <string, string>(); LibraryParser.RegisterLibrary(); LibraryParser.RegisterOutgoing(); LibraryParser.RegisterIncoming(); LibraryParser.RegisterConfig(); #endregion Packets Registering #region Game Initalizer ExtraSettings.RunExtraSettings(); CrossDomainPolicy.Set(); _game = new Game(int.Parse(ConfigurationData.Data["game.tcp.conlimit"])); _game.GetNavigator().LoadNewPublicRooms(); _game.ContinueLoading(); #endregion Game Initalizer #region Languages Parser ServerLanguage = (Convert.ToString(ConfigurationData.Data["system.lang"])); _languages = new Languages(ServerLanguage); #endregion Languages Parser #region Environment SetUp if (ConsoleTimerOn) { Out.WriteLine("Console Clear Timer is enable with " + ConsoleTimer + " seconds."); } _connectionManager = new ConnectionHandling(int.Parse(ConfigurationData.Data["game.tcp.port"]), int.Parse(ConfigurationData.Data["game.tcp.conlimit"]), int.Parse(ConfigurationData.Data["game.tcp.conperip"]), ConfigurationData.Data["game.tcp.enablenagles"].ToLower() == "true"); if (LibraryParser.Config["Crypto.Enabled"] == "true") { Handler.Initialize(LibraryParser.Config["Crypto.RSA.N"], LibraryParser.Config["Crypto.RSA.D"], LibraryParser.Config["Crypto.RSA.E"]); } _connectionManager.init(); LibraryParser.Initialize(); #endregion Environment SetUp #region Tasks and MusSystem if (ConsoleTimerOn) { Timer = new Timer { Interval = ConsoleTimer }; Timer.Elapsed += TimerElapsed; Timer.Start(); } if (ConfigurationData.Data.ContainsKey("StaffAlert.MinRank")) { StaffAlertMinRank = uint.Parse(ConfigurationData.Data["StaffAlert.MinRank"]); } if (ConfigurationData.Data.ContainsKey("SeparatedTasksInMainLoops.enabled") && ConfigurationData.Data["SeparatedTasksInMainLoops.enabled"] == "true") { SeparatedTasksInMainLoops = true; } if (ConfigurationData.Data.ContainsKey("SeparatedTasksInGameClientManager.enabled") && ConfigurationData.Data["SeparatedTasksInGameClientManager.enabled"] == "true") { SeparatedTasksInGameClientManager = true; } if (ConfigurationData.Data.ContainsKey("Debug")) { if (ConfigurationData.Data["Debug"] == "true") { DebugMode = true; } } TimeSpan TimeUsed = DateTime.Now - ServerStarted; Out.WriteLine("CityRP >> Started (" + TimeUsed.Seconds + "s, " + TimeUsed.Milliseconds + "ms)", "", ConsoleColor.Green); IsLive = true; using (var queryReactor = GetDatabaseManager().GetQueryReactor()) { queryReactor.RunFastQuery("UPDATE server_settings SET value = '1' WHERE variable = 'status'"); } } catch (Exception e) { Out.WriteLine("Error in main.ini: Configuration file is invalid" + Environment.NewLine + e.Message, "", ConsoleColor.Red); Out.WriteLine("Please press Y to get more details or press other Key to Exit", "", ConsoleColor.Red); var key = Console.ReadKey(); if (key.Key == ConsoleKey.Y) { Console.WriteLine(); Out.WriteLine( Environment.NewLine + "[Message] Error Details: " + Environment.NewLine + e.StackTrace + Environment.NewLine + e.InnerException + Environment.NewLine + e.TargetSite + Environment.NewLine + "[Message ]Press Any Key To Exit", "", ConsoleColor.Red); Console.ReadKey(); Environment.Exit(1); } else { Environment.Exit(1); } } #endregion Tasks and MusSystem }
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); } }
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); }