]> git.deb.at Git - rhonda/impostor.git/commitdiff
Add NetId to SetName and SetColor
authorminiduikboot <mini@duikbo.at>
Thu, 20 Jun 2024 16:37:10 +0000 (18:37 +0200)
committerminiduikboot <mini@duikbo.at>
Tue, 20 Aug 2024 19:41:38 +0000 (21:41 +0200)
2024.6.18 adds a NetId field *in front* of the existing fields to help link back to the PlayerInfo. We don't actually need this NetId and assume it's called on the correct PlayerControl, so we ignore it.

src/Impostor.Api/Net/Messages/Rpcs/Rpc06SetName.cs
src/Impostor.Api/Net/Messages/Rpcs/Rpc08SetColor.cs
src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs
src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs

index e2e8ae48835245afe6904ea40af4e514c97921e8..3aca0ef39a22a9dc734b440aa33794e01e889c39 100644 (file)
@@ -2,13 +2,15 @@ namespace Impostor.Api.Net.Messages.Rpcs
 {
     public static class Rpc06SetName
     {
-        public static void Serialize(IMessageWriter writer, string name)
+        public static void Serialize(IMessageWriter writer, uint netId, string name)
         {
+            writer.Write(netId);
             writer.Write(name);
         }
 
-        public static void Deserialize(IMessageReader reader, out string name)
+        public static void Deserialize(IMessageReader reader, out uint netId, out string name)
         {
+            netId = reader.ReadUInt32();
             name = reader.ReadString();
         }
     }
index 50ea3d6958e869a4f74252c56ea33cd2dc30c330..6cab399ea68a8e53e3b0dca1682a2ac99bd27a69 100644 (file)
@@ -4,13 +4,15 @@ namespace Impostor.Api.Net.Messages.Rpcs
 {
     public static class Rpc08SetColor
     {
-        public static void Serialize(IMessageWriter writer, ColorType color)
+        public static void Serialize(IMessageWriter writer, uint netId, ColorType color)
         {
+            writer.Write(netId);
             writer.Write((byte)color);
         }
 
-        public static void Deserialize(IMessageReader reader, out ColorType color)
+        public static void Deserialize(IMessageReader reader, out uint netId, out ColorType color)
         {
+            netId = reader.ReadUInt32();
             color = (ColorType)reader.ReadByte();
         }
     }
index e4bd50a0f208f27494c45723f3999e1795f5762c..bd711618e7b1b276e3e23d4de246b3f22fccae31 100644 (file)
@@ -32,7 +32,7 @@ namespace Impostor.Server.Net.Inner.Objects
             PlayerInfo.CurrentOutfit.Color = color;
 
             using var writer = Game.StartRpc(NetId, RpcCalls.SetColor);
-            Rpc08SetColor.Serialize(writer, color);
+            Rpc08SetColor.Serialize(writer, PlayerInfo.NetId, color);
             await Game.FinishRpcAsync(writer);
         }
 
index ff8d9bc87b3a42520689fcb826bee4ad5ea27e4f..16fa42ed7510cf03160bf0565473f876ce0c29e8 100644 (file)
@@ -167,7 +167,7 @@ namespace Impostor.Server.Net.Inner.Objects
                         return false;
                     }
 
-                    Rpc06SetName.Deserialize(reader, out var name);
+                    Rpc06SetName.Deserialize(reader, out var _, out var name);
                     return await HandleSetName(sender, name);
                 }
 
@@ -191,7 +191,7 @@ namespace Impostor.Server.Net.Inner.Objects
                         return false;
                     }
 
-                    Rpc08SetColor.Deserialize(reader, out var color);
+                    Rpc08SetColor.Deserialize(reader, out var _, out var color);
                     return await HandleSetColor(sender, color);
                 }