From e6ad6aeb23cd31133cdf522dfb99339a1337069e Mon Sep 17 00:00:00 2001 From: js6pak Date: Wed, 14 Oct 2020 14:13:36 +0200 Subject: [PATCH] Add SupportedVersions --- src/Impostor.Server/Net/Manager/ClientManager.cs | 12 +++++++++--- src/Impostor.Shared/Innersloth/GameVersion.cs | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 src/Impostor.Shared/Innersloth/GameVersion.cs diff --git a/src/Impostor.Server/Net/Manager/ClientManager.cs b/src/Impostor.Server/Net/Manager/ClientManager.cs index a1a5ae4..7e75c77 100644 --- a/src/Impostor.Server/Net/Manager/ClientManager.cs +++ b/src/Impostor.Server/Net/Manager/ClientManager.cs @@ -1,8 +1,10 @@ using System.Collections.Concurrent; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Impostor.Server.Net.Factories; using Impostor.Server.Net.Messages; +using Impostor.Shared.Innersloth; using Impostor.Shared.Innersloth.Data; using Microsoft.Extensions.Logging; @@ -10,6 +12,12 @@ namespace Impostor.Server.Net.Manager { internal class ClientManager : IClientManager { + public static HashSet SupportedVersions { get; } = new HashSet + { + GameVersion.GetVersion(2020, 09, 07), // 2020.09.07 - 2020.09.22 + GameVersion.GetVersion(2020, 10, 08), // 2020.10.08 + }; + private readonly ILogger _logger; private readonly ConcurrentDictionary _clients; private readonly IClientFactory _clientFactory; @@ -40,9 +48,7 @@ namespace Impostor.Server.Net.Manager public async ValueTask RegisterConnectionAsync(IConnection connection, string name, int clientVersion) { - // 50516550 = 2020.09.22 - // 50518400 = 2020.10.08 - if (clientVersion != 50516550 && clientVersion != 50518400) + if (!SupportedVersions.Contains(clientVersion)) { using var packet = connection.CreateMessage(MessageType.Reliable); Message01JoinGame.SerializeError(packet, false, DisconnectReason.IncorrectVersion); diff --git a/src/Impostor.Shared/Innersloth/GameVersion.cs b/src/Impostor.Shared/Innersloth/GameVersion.cs new file mode 100644 index 0000000..7377b79 --- /dev/null +++ b/src/Impostor.Shared/Innersloth/GameVersion.cs @@ -0,0 +1,10 @@ +namespace Impostor.Shared.Innersloth +{ + public class GameVersion + { + public static int GetVersion(int year, int month, int day, int rev = 0) + { + return (year * 25000) + (month * 1800) + (day * 50) + rev; + } + } +} \ No newline at end of file -- 2.39.5