예제 #1
0
        public override async Task ConfigureAsync(string configFile)
        {
            Logger.Information($"Created WorldServer on PID {Process.GetCurrentProcess().Id.ToString()}");
            await base.ConfigureAsync(configFile);

            // Update the CDClient database.
            await using var cdContext = new CdClientContext();
            await cdContext.EnsureUpdatedAsync();

            ZoneParser = new ZoneParser(Resources);
            Whitelist  = new Whitelist(Resources);

            await Whitelist.LoadDefaultWhitelist();

            GameMessageReceived += HandleGameMessageAsync;
            ServerStopped       += () =>
            {
                foreach (var zone in Zones)
                {
                    Object.Destroy(zone);
                }
            };

            var instance = await Api.RunCommandAsync <InstanceInfoResponse>(
                Config.ApiConfig.Port, $"instance/target?i={Id}"
                ).ConfigureAwait(false);

            ZoneId = (ZoneId)instance.Info.Zones.First();
#if DEBUG
            if (!Config.DebugConfig.StartInstancesAsThreads)
#endif
            Logger.SetServerTypeInformation("Z" + ZoneId.Id);

            var info = await Api.RunCommandAsync <InstanceInfoResponse>(MasterApi, $"instance/target?i={Id}");

            Api.RegisterCommandCollection <WorldCommands>(this);

            ManagedScriptEngine.AdditionalPaths = Config.ManagedScriptSources.Paths.ToArray();

            _ = Task.Run(async() =>
            {
                Logger.Information("Loading CDClient cache");
                await ClientCache.LoadAsync();
            });

            _ = Task.Run(async() =>
            {
                Logger.Information($"Setting up zones for world server {Id}");
                foreach (var zone in info.Info.Zones)
                {
                    await ZoneParser.LoadZoneDataAsync(zone);
                    await LoadZone(zone);
                }
            });
        }
예제 #2
0
        private static async Task <bool> CheckForDatabaseUpdatesAsync()
        {
            try
            {
                await using var uchuContext = new UchuContext();
                await uchuContext.EnsureUpdatedAsync();

                await using var cdClientContext = new CdClientContext();
                await cdClientContext.EnsureUpdatedAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }