Limit chat messages to 2500 characters.
This commit is contained in:
@@ -16,8 +16,9 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Network
|
||||
{
|
||||
static class UnitOrders
|
||||
public static class UnitOrders
|
||||
{
|
||||
public const int ChatMessageMaxLength = 2500;
|
||||
const string ServerChatName = "Battlefield Control";
|
||||
|
||||
static Player FindPlayerByClient(this World world, Session.Client c)
|
||||
@@ -28,7 +29,7 @@ namespace OpenRA.Network
|
||||
p => (p.ClientIndex == c.Index && p.PlayerReference.Playable));
|
||||
}
|
||||
|
||||
public static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order)
|
||||
internal static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
@@ -42,6 +43,12 @@ namespace OpenRA.Network
|
||||
case "Chat":
|
||||
{
|
||||
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)
|
||||
{
|
||||
var player = world != null ? world.FindPlayerByClient(client) : null;
|
||||
@@ -51,10 +58,10 @@ namespace OpenRA.Network
|
||||
if (orderManager.LocalClient != null && client != orderManager.LocalClient && client.Team > 0 && client.Team == orderManager.LocalClient.Team)
|
||||
suffix += " (Ally)";
|
||||
|
||||
Game.AddChatLine(client.Color.RGB, client.Name + suffix, order.TargetString);
|
||||
Game.AddChatLine(client.Color.RGB, client.Name + suffix, message);
|
||||
}
|
||||
else
|
||||
Game.AddChatLine(Color.White, "(player {0})".F(clientId), order.TargetString);
|
||||
Game.AddChatLine(Color.White, "(player {0})".F(clientId), message);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user