public void Start() { if (Global.IsRunningOnMono()) { ThreadPool.SetMaxThreads(200, 50); ThreadPool.SetMinThreads(100, 50); } Logger.Info(@" _________ _______ _________ ______ _______ _ \__ __/( ____ )\__ __/( ___ \ ( ___ )( \ ) ( | ( )| ) ( | ( ) )| ( ) || ( | | | (____)| | | | (__/ / | (___) || | | | | __) | | | __ ( | ___ || | | | | (\ ( | | | ( \ \ | ( ) || | | | | ) \ \_____) (___| )___) )| ) ( || (____/\ )_( |/ \__/\_______/|/ \___/ |/ \|(_______/ _______ _______ _______ |\ /|( ____ \( ____ )( ___ ) | ) ( || ( \/| ( )|| ( ) | | (___) || (__ | (____)|| | | | | ___ || __) | __)| | | | | ( ) || ( | (\ ( | | | | | ) ( || (____/\| ) \ \__| (___) | |/ \|(_______/|/ \__/(_______)"); if (State != EngineState.Stopped) { throw new Exception("Server is not stopped"); } State = EngineState.Starting; // Load map using (var mapFile = new FileStream(Config.maps_folder + "map.dat", FileMode.Open)) using (var map = new GZipStream(mapFile, CompressionMode.Decompress)) { // Create region changes file or open it depending on config settings string regionChangesPath = Config.regions_folder + "region_changes.dat"; #if DEBUG bool createRegionChanges = Config.database_empty || !File.Exists(regionChangesPath); #else bool createRegionChanges = !File.Exists(regionChangesPath); #endif FileStream regionChanges = File.Open(regionChangesPath, createRegionChanges ? FileMode.Create : FileMode.Open, FileAccess.ReadWrite); // Load map world.Regions.Load(map, regionChanges, createRegionChanges, Config.map_width, Config.map_height, Config.region_width, Config.region_height, Config.minimap_region_width, Config.minimap_region_height); } #if DEBUG if (Config.server_production) { throw new Exception("Trying to run debug on production server"); } #endif // Empty database if specified #if DEBUG if (Config.database_empty) { dbManager.EmptyDatabase(); } #endif // Initiate city channel cityChannel.Register(world.Cities); // Load database dbLoader.LoadFromDatabase(); // Initialize stronghold if (Config.stronghold_generate > 0 && strongholdManager.Count == 0) // Only generate if there is none. { strongholdManager.Generate(Config.stronghold_generate); } strongholdActivationChecker.Start(TimeSpan.FromSeconds(Config.stronghold_activation_check_interval_in_sec)); strongholdChecker.Start(); strongholdManagerLogger.Listen(strongholdManager); // Initialize barbarian tribes barbarianTribeChecker.Start(TimeSpan.FromSeconds(Config.barbariantribe_idle_check_interval_in_sec)); // Initialize game market Market.Init(); // Start listening for queue events if (!Config.queue_disabled) { queueListener.Start(Config.api_domain); } // Start store sync storeSync.Start(); // Start command processor server.Start(Config.server_listen_address, Config.server_port); // Start policy server policyServer.Start(Config.server_listen_address, 843); // Start thrift server ThreadPool.QueueUserWorkItem(o => thriftServer.Serve()); // Schedule player deletions if (Config.players_remove_idle) { playersRemoverFactory.CreatePlayersRemover(playerSelector.CreateNewbieIdleSelector()).Start(); } // Start data export mapDataExport.Start(TimeSpan.FromMinutes(30)); State = EngineState.Started; }