private static void Main(string[] args) { Console.Title = "Fabiano Swagger of Doom - World Server"; try { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new Settings("wServer"); using (var db = new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <int>("db_port", "6379"), Settings.GetValue <string>("db_auth", ""))) { manager = new RealmManager( Settings.GetValue <int>("maxClients", "100"), Settings.GetValue <int>("tps", "20"), db); WhiteList = Settings.GetValue <bool>("whiteList", "false"); Verify = Settings.GetValue <bool>("verifyEmail", "false"); WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff"); manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } } catch (Exception e) { log.Fatal(e); foreach (var c in manager.Clients) { c.Value.Disconnect(); } Console.ReadLine(); } }
private static void Main(string[] args) { Console.Title = "Zy's Realm - World Server"; try { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <string>("db_database", "rotmgprod"), Settings.GetValue <string>("db_user", "root"), Settings.GetValue <string>("db_auth", "")); manager = new RealmManager( Settings.GetValue <int>("maxClients", "100"), Settings.GetValue <int>("tps", "20")); WhiteList = Settings.GetValue <bool>("whiteList", "false"); DebugMode = Settings.GetValue <bool>("debugMode", "false"); manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt")) { new Thread(autoBroadcastNews).Start(); } Console.WriteLine("Server initialized."); if (isStopped()) { Console.WriteLine("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); Console.WriteLine("Server terminated."); } } catch (Exception e) { Console.WriteLine(e); foreach (var c in manager.Clients) { c.Value.Disconnect(Client.DisconnectReason.STOPPING_SERVER); } Console.ReadLine(); } }
private static void Main(string[] args) { Console.Title = "Loading..."; XmlConfigurator.ConfigureAndWatch(new FileInfo("_gameserver.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (var db = new Database()) { Usage = -1; manager = new RealmManager(db); autoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART; manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); if (autoRestart) { chat = manager.Chat; uptime = DateTime.Now; restart(); usage(); } Console.Title = Settings.GAMESERVER.TITLE; Logger.Info("Server initialized."); Console.CancelKeyPress += delegate { Shutdown?.Set(); }; while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Logger.Info("Terminating..."); server?.Stop(); policy?.Stop(); manager?.Stop(); Shutdown?.Dispose(); Logger.Info("Server terminated."); Environment.Exit(0); } }
static void Main(string[] args) { Console.Title = "Stable World Server"; Console.WindowWidth = 110; XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) using (var db = new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <int>("db_port", "6379"), Settings.GetValue <string>("db_auth", ""))) { RealmManager manager = new RealmManager( Settings.GetValue <int>("maxClient", "100"), Settings.GetValue <int>("tps", "20"), db); manager.Initialize(); manager.Run(); Server server = new Server(manager, 2050); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); db.Dispose(); log.Info("Server terminated."); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); Database.Init(Settings.GetValue <string>("db_host", "nillysrealm.com"), Settings.GetValue <string>("db_port", "3306"), Settings.GetValue <string>("db_name", "rotmg"), Settings.GetValue <string>("db_user", ""), Settings.GetValue <string>("db_pass", "botmaker")); var manager = new RealmManager(); manager.Initialize(); manager.Run(); var server = new Server(Settings.GetValue <int>("port", "2050")); var policy = new PolicyServer(); policy.Start(); server.Start(); log.Info("Server initialized."); Console.CancelKeyPress += delegate { log.Info("Terminating..."); server.Stop(); policy.Stop(); //Settings.Dispose(); log.Info("Server terminated."); Thread.Sleep(500); Environment.Exit(0); }; while (true) { Thread.Sleep(500); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) { new Database( Settings.GetValue("dbHost", "127.0.0.1"), Settings.GetValue("dbName", "fluffyadventure"), Settings.GetValue("dbUser", "root"), Settings.GetValue("dbPassword", "")); RealmManager manager = new RealmManager( Settings.GetValue <int>("maxClient", "100"), Settings.GetValue <int>("tps", "20")); manager.Initialize(); manager.Run(); Server server = new Server(manager, 2050); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } }
//This is set here, just in case the client SOMEHOW manages to connect before the Settings.Value is set. Which is impossible, but it's whatever. private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); System.Timers.Timer timer = new System.Timers.Timer(65 * 60 * 1000); timer.Elapsed += AutoRestart; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) { serverDatabaseConnString = Settings.GetValue("conn"); //Ugh, this should do good. :] serverTPS = Settings.GetValue <int>("tps", "5"); serverMaxClients = Settings.GetValue <int>("maxClient", "100"); manager = new RealmManager(serverMaxClients, serverTPS); manager.Initialize(); manager.Run(); var server = new Server(manager, 2050); var policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); timer.Start(); while (((uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape) { log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } } }
private static void Main(string[] args) { Console.Title = "Phoenix Realms: Reborn - World Server"; XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) { var db = new Database(Settings.GetValue("conn")); var manager = new RealmManager( Settings.GetValue <int>("maxClient", "100"), Settings.GetValue <int>("tps", "10"), db); manager.Initialize(); manager.Run(); var server = new Server(manager, 2050); var policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); db.Dispose(); log.Info("Server terminated."); } }
private static void Main(string[] args) { Console.Title = "wServer"; try { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); new Database(); manager = new RealmManager( Settings.GetValue <int>("maxClients", "50"), Settings.GetValue <int>("tps", "20")); WhiteList = Settings.GetValue <bool>("whiteList", "false"); Verify = Settings.GetValue <bool>("verifyEmail", "false"); WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff"); manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); new Thread(AutoNotify).Start(); if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt")) { new Thread(autoBroadcastNews).Start(); } log.Info("Server initialized."); uint key = 0; while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape) { if (key == (2 | 80)) { Settings.Reload(); } } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } catch (Exception e) { log.Fatal(e); foreach (var c in manager.Clients) { c.Value.Disconnect(); } Console.ReadLine(); } }
private static void Main(string[] args) { Console.Title = "Loading..."; XmlConfigurator.ConfigureAndWatch(new FileInfo("_gameserver.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (var db = new Database()) { GameUsage = -1; Manager = new RealmManager(db); AutoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART; Manager.Initialize(); Manager.Run(); Log._("Message", Message.Messages.Count); Server server = new Server(Manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; Settings.DISPLAY_SUPPORTED_VERSIONS(); Log.Info("Initializing GameServer..."); policy.Start(); server.Start(); if (AutoRestart) { Chat = Manager.Chat; Uptime = DateTime.Now; Restart(); Usage(); } Console.Title = Settings.GAMESERVER.TITLE; Log.Info("Initializing GameServer... OK!"); Console.CancelKeyPress += delegate { Shutdown?.Set(); }; while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Log.Info("Terminating..."); server?.Stop(); policy?.Stop(); Manager?.Stop(); Shutdown?.Dispose(); Log.Warn("Terminated GameServer."); Thread.Sleep(1000); Environment.Exit(0); } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); // Typically, you wouldn't force the current culture on an entire application unless you know sure your application is used in a specific region (which ACE is not) // We do this because almost all of the client/user input/output code does not take culture into account, and assumes en-US formatting. // Without this, many commands that require special characters like , and . will break Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); // Init our text encoding options. This will allow us to use more than standard ANSI text, which the client also supports. System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); // Look for the log4net.config first in the current environment directory, then in the ExecutingAssembly location var exeLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var containerConfigDirectory = "/ace/Config"; var log4netConfig = Path.Combine(exeLocation, "log4net.config"); var log4netConfigExample = Path.Combine(exeLocation, "log4net.config.example"); var log4netConfigContainer = Path.Combine(containerConfigDirectory, "log4net.config"); if (IsRunningInContainer && File.Exists(log4netConfigContainer)) { File.Copy(log4netConfigContainer, log4netConfig, true); } var log4netFileInfo = new FileInfo("log4net.config"); if (!log4netFileInfo.Exists) { log4netFileInfo = new FileInfo(log4netConfig); } if (!log4netFileInfo.Exists) { var exampleFile = new FileInfo(log4netConfigExample); if (!exampleFile.Exists) { Console.WriteLine("log4net Configuration file is missing. Please copy the file log4net.config.example to log4net.config and edit it to match your needs before running ACE."); throw new Exception("missing log4net configuration file"); } else { if (!IsRunningInContainer) { Console.WriteLine("log4net Configuration file is missing, cloning from example file."); File.Copy(log4netConfigExample, log4netConfig); } else { if (!File.Exists(log4netConfigContainer)) { Console.WriteLine("log4net Configuration file is missing, ACEmulator is running in a container, cloning from docker file."); var log4netConfigDocker = Path.Combine(exeLocation, "log4net.config.docker"); File.Copy(log4netConfigDocker, log4netConfig); File.Copy(log4netConfigDocker, log4netConfigContainer); } else { File.Copy(log4netConfigContainer, log4netConfig); } } } } var logRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, log4netFileInfo); if (Environment.ProcessorCount < 2) { log.Warn("Only one vCPU was detected. ACE may run with limited performance. You should increase your vCPU count for anything more than a single player server."); } // Do system specific initializations here try { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // On many windows systems, the default resolution for Thread.Sleep is 15.6ms. This allows us to command a tighter resolution MM_BeginPeriod(1); } } catch (Exception ex) { log.Error(ex.ToString()); } log.Info("Starting ACEmulator..."); if (IsRunningInContainer) { log.Info("ACEmulator is running in a container..."); } Console.Title = @$ "ACEmulator - v{ServerBuildInfo.FullVersion}"; var configFile = Path.Combine(exeLocation, "Config.js"); var configConfigContainer = Path.Combine(containerConfigDirectory, "Config.js"); if (IsRunningInContainer && File.Exists(configConfigContainer)) { File.Copy(configConfigContainer, configFile, true); } if (!File.Exists(configFile)) { if (!IsRunningInContainer) { DoOutOfBoxSetup(configFile); } else { if (!File.Exists(configConfigContainer)) { DoOutOfBoxSetup(configFile); File.Copy(configFile, configConfigContainer); } else { File.Copy(configConfigContainer, configFile); } } } log.Info("Initializing ConfigManager..."); ConfigManager.Initialize(); if (ConfigManager.Config.Offline.PurgeDeletedCharacters) { log.Info($"Purging deleted characters, and their possessions, older than {ConfigManager.Config.Offline.PurgeDeletedCharactersDays} days ({DateTime.Now.AddDays(-ConfigManager.Config.Offline.PurgeDeletedCharactersDays)})..."); ShardDatabaseOfflineTools.PurgeCharactersInParallel(ConfigManager.Config.Offline.PurgeDeletedCharactersDays, out var charactersPurged, out var playerBiotasPurged, out var possessionsPurged); log.Info($"Purged {charactersPurged:N0} characters, {playerBiotasPurged:N0} player biotas and {possessionsPurged:N0} possessions."); } if (ConfigManager.Config.Offline.PurgeOrphanedBiotas) { log.Info($"Purging orphaned biotas..."); ShardDatabaseOfflineTools.PurgeOrphanedBiotasInParallel(out var numberOfBiotasPurged); log.Info($"Purged {numberOfBiotasPurged:N0} biotas."); } if (ConfigManager.Config.Offline.AutoUpdateWorldDatabase) { CheckForWorldDatabaseUpdate(); if (ConfigManager.Config.Offline.AutoApplyWorldCustomizations) { AutoApplyWorldCustomizations(); } } else { log.Info($"AutoUpdateWorldDatabase is disabled..."); } if (ConfigManager.Config.Offline.AutoApplyDatabaseUpdates) { AutoApplyDatabaseUpdates(); } else { log.Info($"AutoApplyDatabaseUpdates is disabled..."); } // This should only be enabled manually. To enable it, simply uncomment this line //ACE.Database.OfflineTools.Shard.BiotaGuidConsolidator.ConsolidateBiotaGuids(0xC0000000, out int numberOfBiotasConsolidated, out int numberOfErrors); log.Info("Initializing ServerManager..."); ServerManager.Initialize(); log.Info("Initializing DatManager..."); DatManager.Initialize(ConfigManager.Config.Server.DatFilesDirectory, true); log.Info("Initializing DatabaseManager..."); DatabaseManager.Initialize(); log.Info("Starting DatabaseManager..."); DatabaseManager.Start(); log.Info("Starting PropertyManager..."); PropertyManager.Initialize(); log.Info("Initializing GuidManager..."); GuidManager.Initialize(); if (ConfigManager.Config.Server.ServerPerformanceMonitorAutoStart) { log.Info("Server Performance Monitor auto starting..."); ServerPerformanceMonitor.Start(); } if (ConfigManager.Config.Server.WorldDatabasePrecaching) { log.Info("Precaching Weenies..."); DatabaseManager.World.CacheAllWeeniesInParallel(); log.Info("Precaching Cookbooks..."); DatabaseManager.World.CacheAllCookbooksInParallel(); log.Info("Precaching Events..."); DatabaseManager.World.GetAllEvents(); log.Info("Precaching House Portals..."); DatabaseManager.World.CacheAllHousePortals(); log.Info("Precaching Points Of Interest..."); DatabaseManager.World.CacheAllPointsOfInterest(); log.Info("Precaching Spells..."); DatabaseManager.World.CacheAllSpells(); log.Info("Precaching Treasures - Death..."); DatabaseManager.World.CacheAllTreasuresDeath(); log.Info("Precaching Treasures - Material Base..."); DatabaseManager.World.CacheAllTreasuresMaterialBaseInParallel(); log.Info("Precaching Treasures - Material Groups..."); DatabaseManager.World.CacheAllTreasuresMaterialGroupsInParallel(); log.Info("Precaching Treasures - Material Colors..."); DatabaseManager.World.CacheAllTreasuresMaterialColorInParallel(); log.Info("Precaching Treasures - Wielded..."); DatabaseManager.World.CacheAllTreasuresWieldedInParallel(); } else { log.Info("Precaching World Database Disabled..."); } log.Info("Initializing RealmManager..."); RealmManager.Initialize(); log.Info("Initializing PlayerManager..."); PlayerManager.Initialize(); log.Info("Initializing HouseManager..."); HouseManager.Initialize(); log.Info("Initializing InboundMessageManager..."); InboundMessageManager.Initialize(); log.Info("Initializing SocketManager..."); SocketManager.Initialize(); log.Info("Initializing WorldManager..."); WorldManager.Initialize(); log.Info("Initializing EventManager..."); EventManager.Initialize(); // Free up memory before the server goes online. This can free up 6 GB+ on larger servers. log.Info("Forcing .net garbage collection..."); for (int i = 0; i < 10; i++) { GC.Collect(); } // This should be last log.Info("Initializing CommandManager..."); CommandManager.Initialize(); if (!PropertyManager.GetBool("world_closed", false).Item) { WorldManager.Open(null); } }
private static void Main(string[] args) { Console.Title = "Loading..."; XmlConfigurator.ConfigureAndWatch(new FileInfo("_gameserver.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; if (!Directory.Exists(LootCachePath)) { Directory.CreateDirectory(LootCachePath); } if (!Directory.Exists(MonsterCachePath)) { Directory.CreateDirectory(MonsterCachePath); } if (!Directory.Exists(TaskCachePath)) { Directory.CreateDirectory(TaskCachePath); } if (!Directory.Exists(AchievementCachePath)) { Directory.CreateDirectory(AchievementCachePath); } try { var db = new Database(); GameUsage = -1; Manager = new RealmManager(db); AutoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART; Manager.Initialize(); Manager.Run(); var policy = new PolicyServer(); var server = new Server(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); if (AutoRestart) { Chat = Manager.Chat; Uptime = DateTime.Now; Restart(); } Console.Title = Settings.GAMESERVER.TITLE; Console.CancelKeyPress += delegate { Shutdown?.Set(); }; while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Log.Info("Terminating..."); policy?.Stop(); server?.Stop(); Manager?.Stop(); Manager?.Database.Dispose(); Shutdown?.Dispose(); Log.Warn("Terminated GameServer."); Thread.Sleep(1000); Environment.Exit(0); } catch (Exception e) { ForceShutdown(e); } }
private static void Main(string[] args) { Console.Title = "FSOD"; try { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <string>("db_database", "rotmgprod"), Settings.GetValue <string>("db_user", "root"), Settings.GetValue <string>("db_auth", "")); manager = new RealmManager( Settings.GetValue <int>("maxClients", "100"), Settings.GetValue <int>("tps", "20")); WhiteList = Settings.GetValue <bool>("whiteList", "false"); Verify = Settings.GetValue <bool>("verifyEmail", "false"); WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff"); manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt")) { new Thread(autoBroadcastNews).Start(); } log.Info("Server initialized."); foreach (var type in typeof(World).Assembly.GetTypes()) { if (type.IsAbstract || !typeof(World).IsAssignableFrom(type)) { continue; } if (type.GetConstructors().First().GetParameters().Length > 0) { continue; } var world = (World)type.Assembly.CreateInstance(type.FullName); if (world == null) { log.Warn($"Cant make World {type.Name}"); } if (world?.Difficulty == -1) { log.Warn($"World {type.Name} has the default difficulty (-1)"); } world?.Dispose(); } uint key = 0; while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape) { if (key == (2 | 80)) { Settings.Reload(); } } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } catch (Exception e) { log.Fatal(e); foreach (var c in manager.Clients) { c.Value.Disconnect(); } Console.ReadLine(); } }
private static void Main(string[] args) { Console.Title = "Rotux - World Server"; try { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <string>("db_database", "rotmgprod"), Settings.GetValue <string>("db_user", "root"), Settings.GetValue <string>("db_auth", "")); manager = new RealmManager( Settings.GetValue <int>("maxClients", "100"), Settings.GetValue <int>("tps", "20")); WhiteList = Settings.GetValue <bool>("whiteList", "false"); Verify = Settings.GetValue <bool>("verifyEmail", "false"); WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff"); manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt")) { new Thread(autoBroadcastNews).Start(); } Console.WriteLine("Server initialized."); uint key = 0; while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape) { if (key == (2 | 80)) { Settings.Reload(); } } Console.WriteLine("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); Console.WriteLine("Server terminated."); } catch (Exception e) { Console.WriteLine(e); foreach (var c in manager.Clients) { c.Value.Disconnect(); } Console.ReadLine(); } }