]> git.deb.at Git - rhonda/impostor.git/commitdiff
Address my own comments
authorminiduikboot <mini@duikbo.at>
Wed, 19 Aug 2026 19:33:39 +0000 (21:33 +0200)
committerminiduikboot <mini@duikbo.at>
Sun, 30 Aug 2026 16:48:37 +0000 (18:48 +0200)
src/Impostor.Api/Net/Messages/C2S/Message00HostGameC2S.cs
src/Impostor.Api/Net/Messages/C2S/Message25HostModdedGameC2S.cs [new file with mode: 0644]
src/Impostor.Api/Net/Messages/Rpcs/Rpc23VotingComplete.cs
src/Impostor.Server/Net/Client.cs
src/Impostor.Server/Net/Inner/Objects/InnerMeetingHud.cs

index 76c0bf4f1df8b16d11365c0d91e14acb2442d02b..7388a025c21d737c499e012f4b7a8949a720d366 100644 (file)
@@ -20,11 +20,5 @@ namespace Impostor.Api.Net.Messages.C2S
             crossplayFlags = (CrossplayFlags)reader.ReadInt32();
             gameFilterOptions = GameFilterOptions.Deserialize(reader);
         }
-
-        public static void DeserializeModded(IMessageReader reader, out IGameOptions gameOptions, out CrossplayFlags crossplayFlags, out GameFilterOptions gameFilterOptions, out Guid modGuid)
-        {
-            Deserialize(reader, out gameOptions, out crossplayFlags, out gameFilterOptions);
-            modGuid = new Guid(reader.ReadBytes(16).Span);
-        }
     }
 }
diff --git a/src/Impostor.Api/Net/Messages/C2S/Message25HostModdedGameC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message25HostModdedGameC2S.cs
new file mode 100644 (file)
index 0000000..c32bdc6
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.GameOptions;
+
+namespace Impostor.Api.Net.Messages.C2S
+{
+    /// <summary>
+    /// Special serialization rules for AU MCI HostGame messages.
+    /// <see href="https://github.com/Innersloth-LLC/AmongUsModdingInformation?tab=readme-ov-file#all-client-mod-client-identification"/>
+    /// for more information.
+    /// </summary>
+    public static class Message25HostModdedGameC2S
+    {
+        public static void Serialize(IMessageWriter writer, IGameOptions gameOptions, CrossplayFlags crossplayFlags, GameFilterOptions gameFilterOptions)
+        {
+            Message00HostGameC2S.Serialize(writer, gameOptions, crossplayFlags, gameFilterOptions);
+        }
+
+        public static void Deserialize(IMessageReader reader, out IGameOptions gameOptions, out CrossplayFlags crossplayFlags, out GameFilterOptions gameFilterOptions, out Guid modGuid)
+        {
+            Message00HostGameC2S.Deserialize(reader, out gameOptions, out crossplayFlags, out gameFilterOptions);
+            modGuid = new Guid(reader.ReadBytes(16).Span);
+        }
+    }
+}
index a004bb5623642f8e00f661101f5f9883626bb282..56a1154a89274d7e943b8d75c1f85d163d1a944f 100644 (file)
@@ -2,6 +2,15 @@ namespace Impostor.Api.Net.Messages.Rpcs
 {
     public static class Rpc23VotingComplete
     {
+        // Pre 18.0 version
+        // TODO clean up when 17.4 and below are unsupported
+        public static void Serialize(IMessageWriter writer, byte[] states, byte playerId, bool tie)
+        {
+            writer.WriteBytesAndSize(states);
+            writer.Write(playerId);
+            writer.Write(tie);
+        }
+
         public static void Serialize(IMessageWriter writer, byte[] states, byte playerId, bool tie, bool wasOverruled, ushort overrideId)
         {
             writer.WriteBytesAndSize(states);
@@ -11,7 +20,7 @@ namespace Impostor.Api.Net.Messages.Rpcs
             writer.Write(overrideId);
         }
 
-        public static void Deserialize(IMessageReader reader, bool hasOverruleFields, out IMessageReader[] states, out byte playerId, out bool tie, out bool wasOverruled, out ushort overrideId)
+        public static void Deserialize(IMessageReader reader, out IMessageReader[] states, out byte playerId, out bool tie)
         {
             var length = reader.ReadPackedInt32();
             states = new IMessageReader[length];
@@ -22,17 +31,22 @@ namespace Impostor.Api.Net.Messages.Rpcs
 
             playerId = reader.ReadByte();
             tie = reader.ReadBoolean();
+        }
 
-            if (hasOverruleFields)
-            {
-                wasOverruled = reader.ReadBoolean();
-                overrideId = reader.ReadUInt16();
-            }
-            else
+        public static void Deserialize(IMessageReader reader, out IMessageReader[] states, out byte playerId, out bool tie, out bool wasOverruled, out ushort overrideId)
+        {
+            var length = reader.ReadPackedInt32();
+            states = new IMessageReader[length];
+            for (var i = 0; i < length; i++)
             {
-                wasOverruled = false;
-                overrideId = 0;
+                states[i] = reader.ReadMessage();
             }
+
+            playerId = reader.ReadByte();
+            tie = reader.ReadBoolean();
+
+            wasOverruled = reader.ReadBoolean();
+            overrideId = reader.ReadUInt16();
         }
     }
 }
index f508ee12b9b45c474592cd919271968e566c2b76..a7d65f23a0a8bc5b1bdad0d3100c806aee3ea57e 100644 (file)
@@ -138,7 +138,7 @@ namespace Impostor.Server.Net
 
                     if (flag == MessageFlags.HostModdedGame)
                     {
-                        Message00HostGameC2S.DeserializeModded(reader, out gameOptions, out _, out gameFilterOptions, out var parsedModGuid);
+                        Message25HostModdedGameC2S.Deserialize(reader, out gameOptions, out _, out gameFilterOptions, out var parsedModGuid);
                         modGuid = parsedModGuid;
                     }
                     else
index 1d6d3c589690ddee74ce052b3a5de03bc158189a..0f1a4e455a8ede7f8430b8fe2bf8a553f068c391 100644 (file)
@@ -151,11 +151,23 @@ namespace Impostor.Server.Net.Inner.Objects
                         return false;
                     }
 
-                    var hasOverruleFields = sender.Client.GameVersion >= JudgeMinVersion;
-                    Rpc23VotingComplete.Deserialize(reader, hasOverruleFields, out var states, out var playerId, out var tie, out var wasOverruled, out var overrideId);
-                    foreach (var messageReader in states)
+                    if (sender.Client.GameVersion >= JudgeMinVersion)
                     {
-                        messageReader.Dispose();
+                        Rpc23VotingComplete.Deserialize(reader, out var states, out var playerId, out var tie, out var wasOverruled, out var overrideId);
+
+                        foreach (var messageReader in states)
+                        {
+                            messageReader.Dispose();
+                        }
+                    }
+                    else
+                    {
+                        Rpc23VotingComplete.Deserialize(reader, out var states, out var playerId, out var tie);
+
+                        foreach (var messageReader in states)
+                        {
+                            messageReader.Dispose();
+                        }
                     }
 
                     // This would be a nice place to implement an anti cheat.