From 4a021d89808e24713b8d4dd9669529f147882178 Mon Sep 17 00:00:00 2001 From: sven-n Date: Tue, 24 Sep 2024 19:55:38 +0200 Subject: [PATCH] Added second client definition and endpoints for the new protocol --- .../Configuration/ConnectServerDefinition.cs | 16 +++++++++ .../Initialization/DataInitializationBase.cs | 34 ++++++++----------- .../VersionSeasonSix/DataInitialization.cs | 25 +++++++++----- 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/DataModel/Configuration/ConnectServerDefinition.cs b/src/DataModel/Configuration/ConnectServerDefinition.cs index 9edcdcc1e..82028a1d5 100644 --- a/src/DataModel/Configuration/ConnectServerDefinition.cs +++ b/src/DataModel/Configuration/ConnectServerDefinition.cs @@ -112,4 +112,20 @@ public partial class ConnectServerDefinition : IConnectServerSettings /// Gets or sets the maximum server list requests per connection. /// public int MaxServerListRequests { get; set; } + + public void InitializeDefaults() + { + this.DisconnectOnUnknownPacket = true; + this.MaximumReceiveSize = 6; + this.Timeout = new TimeSpan(0, 1, 0); + this.CurrentPatchVersion = new byte[] { 1, 3, 0x2B }; + this.PatchAddress = "patch.muonline.webzen.com"; + this.MaxConnectionsPerAddress = 30; + this.CheckMaxConnectionsPerAddress = true; + this.MaxConnections = 10000; + this.ListenerBacklog = 100; + this.MaxFtpRequests = 1; + this.MaxIpRequests = 5; + this.MaxServerListRequests = 20; + } } \ No newline at end of file diff --git a/src/Persistence/Initialization/DataInitializationBase.cs b/src/Persistence/Initialization/DataInitializationBase.cs index c6123f546..74346c185 100644 --- a/src/Persistence/Initialization/DataInitializationBase.cs +++ b/src/Persistence/Initialization/DataInitializationBase.cs @@ -227,28 +227,23 @@ private void AddAllUpdateEntries(PlugInManager plugInManager) private async ValueTask CreateConnectServerDefinitionAsync() { - var client = (await this.Context.GetAsync().ConfigureAwait(false)).First(); - var connectServer = this.Context.CreateNew(); - connectServer.SetGuid(1); - connectServer.Client = client; - connectServer.ClientListenerPort = 44405; - connectServer.Description = $"Connect Server ({new ClientVersion(client.Season, client.Episode, client.Language)})"; - connectServer.DisconnectOnUnknownPacket = true; - connectServer.MaximumReceiveSize = 6; - connectServer.Timeout = new TimeSpan(0, 1, 0); - connectServer.CurrentPatchVersion = new byte[] { 1, 3, 0x2B }; - connectServer.PatchAddress = "patch.muonline.webzen.com"; - connectServer.MaxConnectionsPerAddress = 30; - connectServer.CheckMaxConnectionsPerAddress = true; - connectServer.MaxConnections = 10000; - connectServer.ListenerBacklog = 100; - connectServer.MaxFtpRequests = 1; - connectServer.MaxIpRequests = 5; - connectServer.MaxServerListRequests = 20; + var port = 44405; + var clients = await this.Context.GetAsync().ConfigureAwait(false); + foreach (var client in clients.OrderBy(c => c.Season)) + { + var connectServer = this.Context.CreateNew(); + connectServer.InitializeDefaults(); + connectServer.SetGuid(client.Season, client.Episode); + connectServer.Client = client; + connectServer.ClientListenerPort = port; + connectServer.Description = $"Connect Server ({client.Description})"; + port++; + } } private async ValueTask CreateGameServerDefinitionsAsync(GameServerConfiguration gameServerConfiguration, int numberOfServers) { + var port = 50901; for (int i = 0; i < numberOfServers; i++) { var server = this.Context!.CreateNew(); @@ -264,8 +259,9 @@ private async ValueTask CreateGameServerDefinitionsAsync(GameServerConfiguration var endPoint = this.Context.CreateNew(); endPoint.SetGuid((short)i, (short)server.Endpoints.Count); endPoint.Client = client; - endPoint.NetworkPort = 55901 + i; + endPoint.NetworkPort = port; server.Endpoints.Add(endPoint); + port++; } } } diff --git a/src/Persistence/Initialization/VersionSeasonSix/DataInitialization.cs b/src/Persistence/Initialization/VersionSeasonSix/DataInitialization.cs index 32eb786bd..a46743c15 100644 --- a/src/Persistence/Initialization/VersionSeasonSix/DataInitialization.cs +++ b/src/Persistence/Initialization/VersionSeasonSix/DataInitialization.cs @@ -51,13 +51,22 @@ public DataInitialization(IPersistenceContextProvider persistenceContextProvider /// protected override void CreateGameClientDefinition() { - var clientDefinition = this.Context.CreateNew(); - clientDefinition.SetGuid(0x104D); - clientDefinition.Season = 6; - clientDefinition.Episode = 3; - clientDefinition.Language = ClientLanguage.English; - clientDefinition.Version = new byte[] { 0x31, 0x30, 0x34, 0x30, 0x34 }; - clientDefinition.Serial = Encoding.ASCII.GetBytes("k1Pk2jcET48mxL3b"); - clientDefinition.Description = "Season 6 Episode 3 GMO Client"; + var season6GmoClient = this.Context.CreateNew(); + season6GmoClient.SetGuid(0x104D); + season6GmoClient.Season = 6; + season6GmoClient.Episode = 3; + season6GmoClient.Language = ClientLanguage.English; + season6GmoClient.Version = [0x31, 0x30, 0x34, 0x30, 0x34]; + season6GmoClient.Serial = "k1Pk2jcET48mxL3b"u8.ToArray(); + season6GmoClient.Description = "Season 6 Episode 3 GMO Client"; + + var season6OpenSource = this.Context.CreateNew(); + season6OpenSource.SetGuid(0x204D); + season6OpenSource.Season = 106; + season6OpenSource.Episode = 3; + season6OpenSource.Language = ClientLanguage.English; + season6OpenSource.Version = new byte[] { 0x32, 0x30, 0x34, 0x30, 0x34 }; + season6OpenSource.Serial = "k1Pk2jcET48mxL3b"u8.ToArray(); + season6OpenSource.Description = "Season 6 Episode 3 Open Source Client"; } } \ No newline at end of file