]> git.deb.at Git - rhonda/impostor.git/commitdiff
Log unsupported version
authorjs6pak <kubastaron@hotmail.com>
Wed, 7 Jul 2021 17:01:31 +0000 (19:01 +0200)
committerjs6pak <kubastaron@hotmail.com>
Wed, 7 Jul 2021 17:01:48 +0000 (19:01 +0200)
src/Impostor.Api/Innersloth/GameVersion.cs
src/Impostor.Server/Net/Manager/ClientManager.cs

index 5015589596b36721f8dc28fe8b55983959ba18c5..5df8deaf0117998c16cf020ed51e263b2a1cf721 100644 (file)
@@ -1,10 +1,20 @@
 namespace Impostor.Api.Innersloth
 {
-    public class GameVersion
+    public static class GameVersion
     {
-        public static int GetVersion(int year, int month, int day, int rev = 0)
+        public static int GetVersion(int year, int month, int day, int revision = 0)
         {
-            return (year * 25000) + (month * 1800) + (day * 50) + rev;
+            return (year * 25000) + (month * 1800) + (day * 50) + revision;
+        }
+
+        public static void ParseVersion(int version, out int year, out int month, out int day, out int revision)
+        {
+            year = version / 25000;
+            version %= 25000;
+            month = version / 1800;
+            version %= 1800;
+            day = version / 50;
+            revision = version % 50;
         }
     }
 }
index bd5ff51c711075f32fb3a83206de82c73df927fc..db9edea7b5b13b86cbea52ebae2c6dee769a3497 100644 (file)
@@ -59,6 +59,9 @@ namespace Impostor.Server.Net.Manager
         {
             if (!SupportedVersions.Contains(clientVersion))
             {
+                GameVersion.ParseVersion(clientVersion, out var year, out var month, out var day, out var revision);
+                _logger.LogTrace("Client connected using unsupported version: {clientVersion} ({version})", clientVersion, $"{year}.{month}.{day}{(revision == 0 ? string.Empty : "." + revision)}");
+
                 using var packet = MessageWriter.Get(MessageType.Reliable);
                 Message01JoinGameS2C.SerializeError(packet, false, DisconnectReason.IncorrectVersion);
                 await connection.SendAsync(packet);