]> git.deb.at Git - rhonda/impostor.git/commitdiff
Add SupportedVersions
authorjs6pak <kubastaron@hotmail.com>
Wed, 14 Oct 2020 12:13:36 +0000 (14:13 +0200)
committerjs6pak <kubastaron@hotmail.com>
Wed, 14 Oct 2020 12:13:36 +0000 (14:13 +0200)
src/Impostor.Server/Net/Manager/ClientManager.cs
src/Impostor.Shared/Innersloth/GameVersion.cs [new file with mode: 0644]

index a1a5ae47829f022aac6283bde34e7c4c89a73108..7e75c772204de72362f9ee9b7fce77766f473fa2 100644 (file)
@@ -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<int> SupportedVersions { get; } = new HashSet<int>
+        {
+            GameVersion.GetVersion(2020, 09, 07), // 2020.09.07 - 2020.09.22
+            GameVersion.GetVersion(2020, 10, 08), // 2020.10.08
+        };
+
         private readonly ILogger<ClientManager> _logger;
         private readonly ConcurrentDictionary<int, IClient> _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 (file)
index 0000000..7377b79
--- /dev/null
@@ -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