Beispiel #1
0
        protected override void Setup()
        {
            try {
                Instance = this;
                this.InitLogging();
                log.InfoFormat("Setup: serverId={0}", ServerId);
#if LOCAL
                string databaseConnectionFile = System.IO.Path.Combine(BinaryPath, "assets/database_connection_local.txt");
#else
                string databaseConnectionFile = System.IO.Path.Combine(BinaryPath, "assets/database_connection.txt");
#endif
                string databaseConnectionString = File.ReadAllText(databaseConnectionFile).Trim();

                this.DbUserLogins = new DbReader();
                this.DbUserLogins.Setup(databaseConnectionString, GameServerSettings.Default.DatabaseName, GameServerSettings.Default.DbLoginCollectionName);

                this.LogedInUsers = new LoggedInUserCollection(this);
                stats             = new StatCollection(this);

                //passManager = new PassManager(this);

                serverSettings = new ServerInputsRes();
                serverSettings.Load(BinaryPath, GameServerSettings.Default.assets.SERVER_INPUTS_FILE);

                inapResource = new InapCollection();
                inapResource.Load(System.IO.Path.Combine(BinaryPath, "assets/game_inaps.xml"));
                log.InfoFormat("inaps loaded: {0}", inapResource.inaps.Count);

                inaps = new InapManager(this);

                Protocol.AllowRawCustomValues = true;
                this.PublicIpAddress          = PublicIPAddressReader.ParsePublicIpAddress(GameServerSettings.Default.PublicIPAddress);
                this.ConnectToMaster();

                this.executionFiber = new PoolFiber();
                this.executionFiber.Start();
                this.executionFiber.ScheduleOnInterval(this.Update, 60000, 60000);
            } catch (Exception ex) {
                log.Error(ex);
                log.Error(ex.StackTrace);
            }
        }
        protected override void Setup()
        {
            try {
                Instance = this;
                this.InitLogging();
                log.InfoFormat("Setup: serverId={0}", ServerId);

                Clients       = new ClientCollection();
                Notifications = new NotificationService(this);

#if LOCAL
                string databaseConnectionFile = System.IO.Path.Combine(BinaryPath, "assets/database_connection_local.txt");
#else
                string databaseConnectionFile = System.IO.Path.Combine(BinaryPath, "assets/database_connection.txt");
#endif

                string databaseConnectionString = File.ReadAllText(databaseConnectionFile).Trim();
                this.DB = new DbReader();
                this.DB.Setup(databaseConnectionString, SelectCharacterSettings.Default.DatabaseName, SelectCharacterSettings.Default.DatabaseCollectionName);

                Mail         = new MailManager(this);
                Guilds       = new GuildService(this);
                Chat         = new ChatService(this);
                Groups       = new GroupService(this);
                Stores       = new PlayerStoreService(this);
                Auction      = new AuctionService(this);
                RaceCommands = new RaceCommandService(this);

                this.Players = new PlayerService(this);

                this.StartModules = new StartPlayerModuleRes();
                this.StartModules.LoadFromFile(Path.Combine(this.BinaryPath, "assets/start_player_modules.xml"));

                bankSlotPrices = new BankSlotPriceCollection();
                bankSlotPrices.LoadFromFile(Path.Combine(this.BinaryPath, "assets/bank_slot_price.xml"));

                leveling = new Leveling();
                leveling.Load(Path.Combine(BinaryPath, "assets"));

                itemPriceCollection = new ItemPriceCollection();
                itemPriceCollection.Load(BinaryPath);

                consumableItems = new ConsumableItemCollection();
                consumableItems.Load(BinaryPath);

                StartLocations = new StartLocationCollection();
                StartLocations.LoadFromFile(Path.Combine(BinaryPath, "assets/start_locations.xml"));
                log.Info(StartLocations.GetWorld(Race.Humans, Workshop.DarthTribe));

                pvpStoreItems = new PvpStoreItemCollection();
                pvpStoreItems.Load(Path.Combine(BinaryPath, "assets/pvp_store.xml"));
                log.InfoFormat("store items loaded = {0} [red]", pvpStoreItems.count);

                serverSettings = new ServerInputsRes();
                serverSettings.Load(BinaryPath, "Data/server_inputs.xml");

                resource = new Res(BinaryPath);
                resource.Load();

                Election  = new CommanderElection(this);
                raceStats = new RaceStatsService(this);

                friends = new FriendService(this);

                pvpStore = new PvpStoreManager(this);

                achievmentCache = new Achievments.AchievmentCache(this);

                Protocol.AllowRawCustomValues = true;
                this.PublicIpAddress          = PublicIPAddressReader.ParsePublicIpAddress(SelectCharacterSettings.Default.PublicIPAddress);
                this.ConnectToMaster();

                this.executionFiber = new PoolFiber();
                this.executionFiber.Start();
                this.executionFiber.ScheduleOnInterval(this.Update,
                                                       SelectCharacterSettings.Default.DatabaseSaveInterval * 1000,
                                                       SelectCharacterSettings.Default.DatabaseSaveInterval * 1000);
            }catch (Exception ex) {
                log.Error(ex);
                log.Error(ex.StackTrace);
            }
        }