From e7f60a1e254aa458a4772bb96be8662983bb8891 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sat, 13 Apr 2019 14:57:49 +0200 Subject: [PATCH] Don't ignore the message limit in team chat --- OpenRA.Game/Network/UnitOrders.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index e61c590fb1..91e20fb382 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -81,22 +81,27 @@ namespace OpenRA.Network { var client = orderManager.LobbyInfo.ClientWithIndex(clientId); + // Cut chat messages to the hard limit to avoid exploits + var message = order.TargetString; + if (message.Length > ChatMessageMaxLength) + message = order.TargetString.Substring(0, ChatMessageMaxLength); + if (client != null) { if (world == null) { if (orderManager.LocalClient != null && client.Team == orderManager.LocalClient.Team) - Game.AddChatLine(client.Color, "[Team] " + client.Name, order.TargetString); + Game.AddChatLine(client.Color, "[Team] " + client.Name, message); } else { var player = world.FindPlayerByClient(client); if (player != null && player.WinState == WinState.Lost) - Game.AddChatLine(client.Color, client.Name + " (Dead)", order.TargetString); + Game.AddChatLine(client.Color, client.Name + " (Dead)", message); else if ((player != null && world.LocalPlayer != null && player.Stances[world.LocalPlayer] == Stance.Ally) || (world.IsReplay && player != null)) - Game.AddChatLine(client.Color, "[Team" + (world.IsReplay ? " " + client.Team : "") + "] " + client.Name, order.TargetString); + Game.AddChatLine(client.Color, "[Team" + (world.IsReplay ? " " + client.Team : "") + "] " + client.Name, message); else if ((orderManager.LocalClient != null && orderManager.LocalClient.IsObserver && client.IsObserver) || (world.IsReplay && client.IsObserver)) - Game.AddChatLine(client.Color, "[Spectators] " + client.Name, order.TargetString); + Game.AddChatLine(client.Color, "[Spectators] " + client.Name, message); } }