Beispiel #1
0
        public override async Task ConfigureAsync(string configFile)
        {
            await base.ConfigureAsync(configFile);

            ZoneParser = new ZoneParser(Resources);

            Whitelist = new Whitelist(Resources);

            await Whitelist.LoadDefaultWhitelist();

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

            RakNetServer.ClientDisconnected += HandleDisconnect;

            var _ = Task.Run(async() =>
            {
                await ZoneParser.LoadZoneDataAsync((int)ServerSpecification.ZoneId);

                await LoadZone(ServerSpecification);
            });

            Logger.Information($"Setting up world server: {ServerSpecification.Id}");
        }
Beispiel #2
0
        public void TestSetup()
        {
            directory = new TemporaryDirectory();

            fileParserImpl = info => new ObjectNode(info.Name);
            fileParser     = Substitute.For <IFileParser>();
            fileParser.Parse(Arg.Any <FileInfo>()).Returns(info => fileParserImpl(info.Arg <FileInfo>()));

            zoneParser = new ZoneParser(fileParser);
        }
Beispiel #3
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);
                }
            });
        }
Beispiel #4
0
        public override async Task ConfigureAsync(string configFile)
        {
            Logger.Information($"Created WorldServer on PID {Process.GetCurrentProcess().Id.ToString()}");

            await base.ConfigureAsync(configFile);

            ZoneParser = new ZoneParser(Resources);

            Whitelist = new Whitelist(Resources);

            await Whitelist.LoadDefaultWhitelist();

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

            RakNetServer.ClientDisconnected += HandleDisconnect;

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

            ZoneId = (ZoneId)instance.Info.Zones.First();

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

            Api.RegisterCommandCollection <WorldCommands>(this);

            var _ = Task.Run(async() =>
            {
                foreach (var zone in info.Info.Zones)
                {
                    await ZoneParser.LoadZoneDataAsync(zone);

                    await LoadZone(zone);
                }
            });

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

            Logger.Information($"Setting up world server: {Id}");
        }
Beispiel #5
0
        private async Task LoadZone(int zone)
        {
            if (ZoneParser.Zones == default)
            {
                await ZoneParser.LoadZoneDataAsync(zone);
            }

            Logger.Information($"Starting {zone}");

            if (ZoneParser?.Zones == default || !ZoneParser.Zones.TryGetValue(zone, out var info))
            {
                throw new Exception($"Failed to find info for {(ZoneId) zone}");
            }

            var zoneInstance = new Zone(info, this, 0, 0); // TODO Instance/Clone

            Zones.Add(zoneInstance);

            await zoneInstance.InitializeAsync();
        }
Beispiel #6
0
        private async Task LoadZone(ServerSpecification zone)
        {
            if (ZoneParser.Zones == default)
            {
                await ZoneParser.LoadZoneDataAsync((int)zone.ZoneId);
            }

            Logger.Information($"Starting {zone.ZoneId}");

            var info = ZoneParser.Zones?[zone.ZoneId];

            if (info == default)
            {
                throw new Exception($"Failed to find info for {zone.ZoneId}");
            }

            var zoneInstance = new Zone(info, this, zone.ZoneInstanceId, zone.ZoneCloneId);

            Zones.Add(zoneInstance);

            await zoneInstance.InitializeAsync();
        }
Beispiel #7
0
        private async Task LoadZone(int zoneId)
        {
            if (ZoneParser.Zones == default)
            {
                await ZoneParser.LoadZoneDataAsync(zoneId);
            }

            Logger.Information($"Starting {zoneId}");

            if (ZoneParser?.Zones == default || !ZoneParser.Zones.TryGetValue(zoneId, out var info))
            {
                throw new Exception($"Failed to find info for {(ZoneId) zoneId}");
            }

            // Ensure the correct Zone ID is used later on, this differs from the value in the .luz for eg. Moonbase and Deep Freeze
            info.LuzFile.WorldId = (ZoneId)zoneId;

            // TODO instance / clone
            var zone = new Zone(info, this, 0, 0);

            Zones.Add(zone);

            await zone.InitializeAsync();
        }