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() { Console.Clear(); ServerStarted = DateTime.Now; Console.ForegroundColor = ConsoleColor.Gray; PatchDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/"; Console.Title = "Butterfly Emulator"; try { _configuration = new ConfigurationData(PatchDir + "Settings/configuration.ini", false); _datebasemanager = new DatabaseManager(uint.Parse(GetConfig().data["db.pool.maxsize"]), uint.Parse(GetConfig().data["db.pool.minsize"]), GetConfig().data["db.hostname"], uint.Parse(GetConfig().data["db.port"]), GetConfig().data["db.username"], GetConfig().data["db.password"], GetConfig().data["db.name"]); int TryCount = 0; while (!_datebasemanager.IsConnected()) { TryCount++; Thread.Sleep(5000); //sleep 5sec if (TryCount > 10) { Logging.WriteLine("Failed to connect to the specified MySQL server."); Console.ReadKey(true); Environment.Exit(1); return; } } HabboEncryptionV2.Initialize(new RSAKeys()); _languageManager = new LanguageManager(); _languageManager.Init(); _game = new Game(); _game.StartGameLoop(); _figureManager = new FigureDataManager(); _figureManager.Init(); if (_configuration.data["Websocketenable"] == "true") { _webSocketManager = new WebSocketManager(527, int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conlimit"])); } _connectionManager = new ConnectionHandeling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"])); if (_configuration.data["Musenable"] == "true") { _rcon = new RCONSocket(int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(new char[1] { ';' })); } StaticEvents = _configuration.data["static.events"] == "true"; Logging.WriteLine("ENVIRONMENT -> READY!"); if (Debugger.IsAttached) { 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 ex) { Logging.WriteLine("Please check your configuration file - some values appear to be missing."); Logging.WriteLine("Press any key to shut down ..."); Logging.WriteLine((ex).ToString()); Console.ReadKey(true); } catch (InvalidOperationException ex) { Logging.WriteLine("Failed to initialize ButterflyEmulator: " + ex.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); } catch (Exception ex) { Console.WriteLine("Fatal error during startup: " + (ex).ToString()); Console.WriteLine("Press a key to exit"); Console.ReadKey(); Environment.Exit(1); } }
// Projeto prisma lindo public Game() { Console.WriteLine(); log.Info("» Iniciando BIOS EMULADOR Para " + BiosEmuThiago.HotelName + ""); Console.WriteLine(); SessionUserRecord = 0; // Run Extra Settings // BotFrankConfig.RunBotFrank(); ExtraSettings.RunExtraSettings(); // Run Catalog Settings CatalogSettings.RunCatalogSettings(); // Run Notification Settings NotificationSettings.RunNotiSettings(); _languageManager = new LanguageManager(); _languageManager.Init(); _settingsManager = new SettingsManager(); _settingsManager.Init(); _packetManager = new PacketManager(); _clientManager = new GameClientManager(); _moderationManager = new ModerationManager(); _moderationManager.Init(); _itemDataManager = new ItemDataManager(); _itemDataManager.Init(); _catalogManager = new CatalogManager(); _catalogManager.Init(_itemDataManager); _craftingManager = new CraftingManager(); _craftingManager.Init(); _televisionManager = new TelevisionManager(); _navigatorManager = new NavigatorManager(); _roomManager = new RoomManager(); _chatManager = new ChatManager(); _groupManager = new GroupManager(); _groupManager.Init(); _groupForumManager = new GroupForumManager(); _questManager = new QuestManager(); _achievementManager = new AchievementManager(); _talentManager = new TalentManager(); _talentManager.Initialize(); _talentTrackManager = new TalentTrackManager(); _landingViewManager = new LandingViewManager(); _gameDataManager = new GameDataManager(); _botManager = new BotManager(); _cacheManager = new CacheManager(); _rewardManager = new RewardManager(); _badgeManager = new BadgeManager(); _badgeManager.Init(); // GetHallOfFame.GetInstance().Load(); _permissionManager = new PermissionManager(); _permissionManager.Init(); _subscriptionManager = new SubscriptionManager(); _subscriptionManager.Init(); TraxSoundManager.Init(); HabboCameraManager.Init(); HelperToolsManager.Init(); _figureManager = new FigureDataManager(BiosEmuThiago.GetConfig().data["game.legacy.figure_mutant"].ToString() == "1"); _figureManager.Init(); _crackableManager = new CrackableManager(); _crackableManager.Initialize(BiosEmuThiago.GetDatabaseManager().GetQueryReactor()); _furniMaticRewardsManager = new FurniMaticRewardsManager(); _furniMaticRewardsManager.Initialize(BiosEmuThiago.GetDatabaseManager().GetQueryReactor()); _targetedoffersManager = new TargetedOffersManager(); _targetedoffersManager.Initialize(BiosEmuThiago.GetDatabaseManager().GetQueryReactor()); }