From e694b6fac9d2956924bc5ad32e6c248b9b26dc14 Mon Sep 17 00:00:00 2001 From: AeonLucid Date: Mon, 2 Nov 2020 19:27:58 +0100 Subject: [PATCH] Small changes --- .../Net/Inner/Objects/IInnerPlayerControl.cs | 5 +++-- .../Net/Inner/Objects/InnerPlayerControl.Api.cs | 9 +++------ src/Impostor.Server/Net/State/Game.Outgoing.cs | 8 +++++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs index b1c1ae6..14c793b 100644 --- a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs +++ b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs @@ -3,7 +3,7 @@ using Impostor.Api.Innersloth.Customization; namespace Impostor.Api.Net.Inner.Objects { - public interface IInnerPlayerControl + public interface IInnerPlayerControl : IInnerNetObject { /// /// Gets the of the . @@ -80,8 +80,9 @@ namespace Impostor.Api.Net.Inner.Objects /// Visible to only the current. /// /// The message to send. + /// The player that should receive this chat message. /// Task that must be awaited. - ValueTask SendChatToPlayerAsync(string text); + ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player); /// /// Sets the current to infected (impostor) . diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs index 1e53974..06fb84c 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs @@ -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() diff --git a/src/Impostor.Server/Net/State/Game.Outgoing.cs b/src/Impostor.Server/Net/State/Game.Outgoing.cs index cd8098f..21b6067 100644 --- a/src/Impostor.Server/Net/State/Game.Outgoing.cs +++ b/src/Impostor.Server/Net/State/Game.Outgoing.cs @@ -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 +} -- 2.39.5