diff --git a/.gitignore b/.gitignore index dfcfd56..7725192 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,4 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ +/BeatTogether.DedicatedServer/appsettings.LocalDevelopment.json diff --git a/BeatTogether.DedicatedServer.Instancing/Abstractions/IInstanceRegistry.cs b/BeatTogether.DedicatedServer.Instancing/Abstractions/IInstanceRegistry.cs index 0511418..bd42a86 100644 --- a/BeatTogether.DedicatedServer.Instancing/Abstractions/IInstanceRegistry.cs +++ b/BeatTogether.DedicatedServer.Instancing/Abstractions/IInstanceRegistry.cs @@ -1,6 +1,7 @@ using BeatTogether.Core.Enums; using BeatTogether.DedicatedServer.Kernel.Abstractions; using System.Diagnostics.CodeAnalysis; +using BeatTogether.Core.Models; namespace BeatTogether.DedicatedServer.Instancing.Abstractions { @@ -10,6 +11,6 @@ public interface IInstanceRegistry public bool RemoveInstance(IDedicatedInstance instance); public bool TryGetInstance(string secret, [MaybeNullWhen(false)] out IDedicatedInstance instance); public bool TryGetInstanceByCode(string code, [MaybeNullWhen(false)] out IDedicatedInstance instance); - public bool TryGetAvailablePublicServer(InvitePolicy invitePolicy, GameplayServerMode serverMode, SongSelectionMode songMode, GameplayServerControlSettings serverControlSettings, BeatmapDifficultyMask difficultyMask, GameplayModifiersMask modifiersMask, string songPackMasks, [MaybeNullWhen(false)] out IDedicatedInstance instance); + public bool TryGetAvailablePublicServer(InvitePolicy invitePolicy, GameplayServerMode serverMode, SongSelectionMode songMode, GameplayServerControlSettings serverControlSettings, BeatmapDifficultyMask difficultyMask, GameplayModifiersMask modifiersMask, string songPackMasks, VersionRange versionRange, [MaybeNullWhen(false)] out IDedicatedInstance instance); } } diff --git a/BeatTogether.DedicatedServer.Instancing/BeatTogether.DedicatedServer.Instancing.csproj b/BeatTogether.DedicatedServer.Instancing/BeatTogether.DedicatedServer.Instancing.csproj index 9dd0305..ebae974 100644 --- a/BeatTogether.DedicatedServer.Instancing/BeatTogether.DedicatedServer.Instancing.csproj +++ b/BeatTogether.DedicatedServer.Instancing/BeatTogether.DedicatedServer.Instancing.csproj @@ -7,12 +7,12 @@ BeatTogether Team BeatTogether https://github.com/beattogether/BeatTogether.DedicatedServer - 1.0.0 + 1.1.0 enable - + diff --git a/BeatTogether.DedicatedServer.Instancing/Implimentations/ServerInstance.cs b/BeatTogether.DedicatedServer.Instancing/Implimentations/ServerInstance.cs index 77e1e24..f5a4551 100644 --- a/BeatTogether.DedicatedServer.Instancing/Implimentations/ServerInstance.cs +++ b/BeatTogether.DedicatedServer.Instancing/Implimentations/ServerInstance.cs @@ -42,5 +42,6 @@ public ServerInstance(IDedicatedInstance serverInstance, IPEndPoint instanceEndP public bool AllowChroma { get => _ServerInstance._configuration.AllowChroma; set => throw new NotImplementedException(); } public bool AllowME { get => _ServerInstance._configuration.AllowMappingExtensions; set => throw new NotImplementedException(); } public bool AllowNE { get => _ServerInstance._configuration.AllowNoodleExtensions; set => throw new NotImplementedException(); } - } + public VersionRange SupportedVersionRange { get => _ServerInstance._configuration.SupportedVersionRange; set => throw new NotImplementedException(); } + } } diff --git a/BeatTogether.DedicatedServer.Instancing/InstanceRegistry.cs b/BeatTogether.DedicatedServer.Instancing/InstanceRegistry.cs index edf8f68..79e3823 100644 --- a/BeatTogether.DedicatedServer.Instancing/InstanceRegistry.cs +++ b/BeatTogether.DedicatedServer.Instancing/InstanceRegistry.cs @@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis; using BeatTogether.Core.Enums; using System.Linq; +using BeatTogether.Core.Models; namespace BeatTogether.DedicatedServer.Instancing { @@ -23,7 +24,7 @@ public bool AddInstance(IDedicatedInstance instance){ public bool RemoveInstance(IDedicatedInstance instance) => _instances.TryRemove(instance._configuration.Secret, out _) && _instancesByCode.TryRemove(instance._configuration.Code, out _); - public bool TryGetAvailablePublicServer(InvitePolicy invitePolicy, GameplayServerMode serverMode, SongSelectionMode songMode, GameplayServerControlSettings serverControlSettings, BeatmapDifficultyMask difficultyMask, GameplayModifiersMask modifiersMask, string songPackMasks, [MaybeNullWhen(false)] out IDedicatedInstance instance) + public bool TryGetAvailablePublicServer(InvitePolicy invitePolicy, GameplayServerMode serverMode, SongSelectionMode songMode, GameplayServerControlSettings serverControlSettings, BeatmapDifficultyMask difficultyMask, GameplayModifiersMask modifiersMask, string songPackMasks, VersionRange versionRange, [MaybeNullWhen(false)] out IDedicatedInstance instance) { instance = null; var AvaliableServers = _instances.Values.Where(s => @@ -33,7 +34,8 @@ public bool TryGetAvailablePublicServer(InvitePolicy invitePolicy, GameplayServe s._configuration.GameplayServerConfiguration.GameplayServerControlSettings == serverControlSettings && s._configuration.BeatmapDifficultyMask == difficultyMask && s._configuration.GameplayModifiersMask == modifiersMask && - s._configuration.SongPacksMask == songPackMasks + s._configuration.SongPacksMask == songPackMasks && + s._configuration.SupportedVersionRange == versionRange ); if (!AvaliableServers.Any()) return false; diff --git a/BeatTogether.DedicatedServer.Instancing/LayerService.cs b/BeatTogether.DedicatedServer.Instancing/LayerService.cs index fd496a7..6926348 100644 --- a/BeatTogether.DedicatedServer.Instancing/LayerService.cs +++ b/BeatTogether.DedicatedServer.Instancing/LayerService.cs @@ -6,6 +6,7 @@ using Serilog; using System.Net; using System.Threading.Tasks; +using BeatTogether.Core.Models; namespace BeatTogether.DedicatedServer.Instancing { @@ -50,10 +51,10 @@ public Task DisconnectPlayer(string InstanceSecret, string PlayerUserId) return Task.CompletedTask; } - public Task GetAvailablePublicServer(InvitePolicy invitePolicy, GameplayServerMode serverMode, SongSelectionMode songMode, GameplayServerControlSettings serverControlSettings, BeatmapDifficultyMask difficultyMask, GameplayModifiersMask modifiersMask, string songPackMasks) + public Task GetAvailablePublicServer(InvitePolicy invitePolicy, GameplayServerMode serverMode, SongSelectionMode songMode, GameplayServerControlSettings serverControlSettings, BeatmapDifficultyMask difficultyMask, GameplayModifiersMask modifiersMask, string songPackMasks, VersionRange versionRange) { IServerInstance? serverInstance = null; - if (_instanceRegistry.TryGetAvailablePublicServer(invitePolicy, serverMode, songMode, serverControlSettings, difficultyMask, modifiersMask, songPackMasks, out var instance)) + if (_instanceRegistry.TryGetAvailablePublicServer(invitePolicy, serverMode, songMode, serverControlSettings, difficultyMask, modifiersMask, songPackMasks, versionRange, out var instance)) { serverInstance = new ServerInstance(instance, IPEndPoint.Parse($"{_instancingConfiguration.HostEndpoint}:{instance._configuration.Port}")); } diff --git a/BeatTogether.DedicatedServer.Interface/BeatTogether.DedicatedServer.Interface.csproj b/BeatTogether.DedicatedServer.Interface/BeatTogether.DedicatedServer.Interface.csproj index 991752d..c829173 100644 --- a/BeatTogether.DedicatedServer.Interface/BeatTogether.DedicatedServer.Interface.csproj +++ b/BeatTogether.DedicatedServer.Interface/BeatTogether.DedicatedServer.Interface.csproj @@ -7,7 +7,7 @@ BeatTogether Team BeatTogether https://github.com/beattogether/BeatTogether.DedicatedServer - 2.0.2 + 2.1.0 enable @@ -17,7 +17,7 @@ - + diff --git a/BeatTogether.DedicatedServer.Kernel/BeatTogether.DedicatedServer.Kernel.csproj b/BeatTogether.DedicatedServer.Kernel/BeatTogether.DedicatedServer.Kernel.csproj index 93c36d4..30710f3 100644 --- a/BeatTogether.DedicatedServer.Kernel/BeatTogether.DedicatedServer.Kernel.csproj +++ b/BeatTogether.DedicatedServer.Kernel/BeatTogether.DedicatedServer.Kernel.csproj @@ -7,7 +7,7 @@ - + diff --git a/BeatTogether.DedicatedServer.Kernel/Configuration/InstanceConfiguration.cs b/BeatTogether.DedicatedServer.Kernel/Configuration/InstanceConfiguration.cs index 60aa612..f4faa17 100644 --- a/BeatTogether.DedicatedServer.Kernel/Configuration/InstanceConfiguration.cs +++ b/BeatTogether.DedicatedServer.Kernel/Configuration/InstanceConfiguration.cs @@ -16,6 +16,8 @@ public sealed class InstanceConfiguration public string SetConstantManagerFromUserId { get; set; } = string.Empty; //If a user creates a server using the api and enteres there userId (eg uses discord bot with linked account)) public bool AllowPerPlayerDifficulties { get; set; } = false; public bool AllowPerPlayerModifiers { get; set; } = false; + + public VersionRange SupportedVersionRange { get; set; } = new(); public CountdownConfig CountdownConfig { get; set; } = new(); public GameplayServerConfiguration GameplayServerConfiguration { get; set; } = new(); diff --git a/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs b/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs index 872580f..25a185e 100644 --- a/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs +++ b/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs @@ -472,12 +472,14 @@ private bool PlayerMapCheck(IPlayer p) int Votes = 0; foreach (var item in voteDictionary) { + _logger.Verbose($"Checking Votes for map '{item.Key.LevelId}' on characteristic '{item.Key.Characteristic}' and difficulty '{item.Key.Difficulty}' votes: {item.Value}"); if (item.Value > Votes) { Selected = item.Key; Votes = item.Value; } } + _logger.Verbose($"Vote: selected map '{Selected.LevelId}' characteristic '{Selected.Characteristic}' difficulty '{Selected.Difficulty}'"); return Selected; case SongSelectionMode.RandomPlayerPicks: if (CountDownState == CountdownState.CountingDown || CountDownState == CountdownState.NotCountingDown) diff --git a/BeatTogether.DedicatedServer.Messaging/BeatTogether.DedicatedServer.Messaging.csproj b/BeatTogether.DedicatedServer.Messaging/BeatTogether.DedicatedServer.Messaging.csproj index 95a2114..4894a99 100644 --- a/BeatTogether.DedicatedServer.Messaging/BeatTogether.DedicatedServer.Messaging.csproj +++ b/BeatTogether.DedicatedServer.Messaging/BeatTogether.DedicatedServer.Messaging.csproj @@ -7,7 +7,7 @@ - + diff --git a/BeatTogether.DedicatedServer.Node/Configuration/NodeConfiguration.cs b/BeatTogether.DedicatedServer.Node/Configuration/NodeConfiguration.cs index 13d80cb..3c27c12 100644 --- a/BeatTogether.DedicatedServer.Node/Configuration/NodeConfiguration.cs +++ b/BeatTogether.DedicatedServer.Node/Configuration/NodeConfiguration.cs @@ -5,6 +5,6 @@ namespace BeatTogether.DedicatedServer.Node.Configuration public sealed class NodeConfiguration { public string HostEndpoint { get; set; } = "127.0.0.1"; - public Version NodeVersion { get; } = new Version(2,0,0); + public Version NodeVersion { get; } = new Version(2,1,0); } } diff --git a/BeatTogether.DedicatedServer.Node/Models/ServerFromMessage.cs b/BeatTogether.DedicatedServer.Node/Models/ServerFromMessage.cs index 45c6907..6066020 100644 --- a/BeatTogether.DedicatedServer.Node/Models/ServerFromMessage.cs +++ b/BeatTogether.DedicatedServer.Node/Models/ServerFromMessage.cs @@ -50,6 +50,8 @@ public class ServerFromMessage : IServerInstance public bool AllowNE { get; set; } + public VersionRange SupportedVersionRange { get; set; } + public IPEndPoint InstanceEndPoint { get; set; } = null!; public HashSet PlayerHashes { get; set; } = null!; @@ -76,6 +78,7 @@ public ServerFromMessage(Core.ServerMessaging.Models.Server instance) AllowChroma = instance.AllowChroma; AllowME = instance.AllowME; AllowNE = instance.AllowNE; + SupportedVersionRange = instance.SupportedVersionRange; } } } diff --git a/BeatTogether.DedicatedServer/BeatTogether.DedicatedServer.csproj b/BeatTogether.DedicatedServer/BeatTogether.DedicatedServer.csproj index d2e91a7..7ff2c59 100644 --- a/BeatTogether.DedicatedServer/BeatTogether.DedicatedServer.csproj +++ b/BeatTogether.DedicatedServer/BeatTogether.DedicatedServer.csproj @@ -1,4 +1,4 @@ - + Exe @@ -8,7 +8,7 @@ - + Always @@ -19,7 +19,7 @@ - + Always diff --git a/BeatTogether.DedicatedServer/Properties/launchSettings.json b/BeatTogether.DedicatedServer/Properties/launchSettings.json new file mode 100644 index 0000000..3e03400 --- /dev/null +++ b/BeatTogether.DedicatedServer/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "BeatTogether.DedicatedServer": { + "commandName": "Project", + "environmentVariables": { + "DOTNET_ENVIRONMENT": "LocalDevelopment" + }, + "remoteDebugEnabled": false + } + } +} \ No newline at end of file diff --git a/BeatTogether.DedicatedServer/appsettings.Development.json b/BeatTogether.DedicatedServer/appsettings.Development.json index 27727fa..3feb243 100644 --- a/BeatTogether.DedicatedServer/appsettings.Development.json +++ b/BeatTogether.DedicatedServer/appsettings.Development.json @@ -1,4 +1,7 @@ { + "RabbitMQ": { + "HostName": "127.0.0.1" + }, "Serilog": { "MinimumLevel": { "Default": "Verbose", diff --git a/BeatTogether.DedicatedServer/appsettings.json b/BeatTogether.DedicatedServer/appsettings.json index 12a9f2b..2e30668 100644 --- a/BeatTogether.DedicatedServer/appsettings.json +++ b/BeatTogether.DedicatedServer/appsettings.json @@ -1,10 +1,13 @@ { + "RabbitMQ": { + "HostName": "127.0.0.1" + }, "Serilog": { "File": { "Path": "logs/BeatTogether.DedicatedServer-{Date}.log" - }, - "ServerConfiguration": { - "HostEndpoint": "127.0.0.1" } + }, + "ServerConfiguration": { + "HostEndpoint": "127.0.0.1" } }