]> git.deb.at Git - rhonda/impostor.git/commitdiff
Small changes
authorAeonLucid <aeonlucid@outlook.com>
Mon, 2 Nov 2020 18:27:58 +0000 (19:27 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Mon, 2 Nov 2020 18:27:58 +0000 (19:27 +0100)
src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs
src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs
src/Impostor.Server/Net/State/Game.Outgoing.cs

index b1c1ae68b6b4ee8e2186a28fc64ba37e0c764ba3..14c793b6c9b5a6eb3d519095066ae9957241a1be 100644 (file)
@@ -3,7 +3,7 @@ using Impostor.Api.Innersloth.Customization;
 
 namespace Impostor.Api.Net.Inner.Objects
 {
-    public interface IInnerPlayerControl
+    public interface IInnerPlayerControl : IInnerNetObject
     {
         /// <summary>
         ///     Gets the <see cref="IInnerPlayerInfo"/> of the <see cref="IInnerPlayerControl"/>.
@@ -80,8 +80,9 @@ namespace Impostor.Api.Net.Inner.Objects
         ///     Visible to only the current.
         /// </summary>
         /// <param name="text">The message to send.</param>
+        /// <param name="player">The player that should receive this chat message.</param>
         /// <returns>Task that must be awaited.</returns>
-        ValueTask SendChatToPlayerAsync(string text);
+        ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player);
 
         /// <summary>
         ///     Sets the current to infected (impostor) <see cref="IInnerPlayerControl"/>.
index 1e53974736b90283eef0d16bcce987daf87437bb..06fb84ce6e81d432c3740f8a6cab0d5a8956f5b3 100644 (file)
@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using Impostor.Api.Innersloth.Customization;
+using Impostor.Api.Net;
 using Impostor.Api.Net.Inner.Objects;
 
 namespace Impostor.Server.Net.Inner.Objects
@@ -80,15 +81,11 @@ namespace Impostor.Server.Net.Inner.Objects
             await _game.FinishRpcAsync(writer);
         }
 
-        public async ValueTask SendChatToPlayerAsync(string text)
+        public async ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player)
         {
             using var writer = _game.StartRpc(NetId, RpcCalls.SendChat);
             writer.Write(text);
-
-            writer.EndMessage();
-            writer.EndMessage();
-
-            await _game.SendToAsync(writer, OwnerId);
+            await _game.FinishRpcAsync(writer, player.OwnerId);
         }
 
         public async ValueTask SetMurderedAsync()
index cd8098f9b9e56a51a2fb0b0e21551f0dc859f3ea..21b606701a416d3d99116aa08ac4d3e781f176d0 100644 (file)
@@ -60,12 +60,14 @@ namespace Impostor.Server.Net.State
             return writer;
         }
 
-        internal ValueTask FinishRpcAsync(IMessageWriter writer)
+        internal ValueTask FinishRpcAsync(IMessageWriter writer, int? targetClientId = null)
         {
             writer.EndMessage();
             writer.EndMessage();
 
-            return SendToAllAsync(writer);
+            return targetClientId.HasValue
+                ? SendToAsync(writer, targetClientId.Value)
+                : SendToAllAsync(writer);
         }
 
         private void WriteRemovePlayerMessage(IMessageWriter message, bool clear, int playerId, DisconnectReason reason)
@@ -98,4 +100,4 @@ namespace Impostor.Server.Net.State
             Message12WaitForHostS2C.Serialize(message, clear, Code, player.Client.Id);
         }
     }
-}
\ No newline at end of file
+}