Remove the TeamChat order type
This commit is contained in:
@@ -195,12 +195,9 @@ namespace OpenRA
|
||||
|
||||
// Named constructors for Orders.
|
||||
// Now that Orders are resolved by individual Actors, these are weird; you unpack orders manually, but not pack them.
|
||||
public static Order Chat(bool team, string text, int teamNumber = 0)
|
||||
public static Order Chat(string text, uint teamNumber = 0)
|
||||
{
|
||||
if (!team)
|
||||
return new Order("Chat", null, false) { IsImmediate = true, TargetString = text };
|
||||
|
||||
return new Order("TeamChat", null, false) { IsImmediate = true, TargetString = text, ExtraData = (uint)teamNumber };
|
||||
return new Order("Chat", null, false) { IsImmediate = true, TargetString = text, ExtraData = teamNumber };
|
||||
}
|
||||
|
||||
public static Order HandshakeResponse(string text)
|
||||
|
||||
@@ -38,31 +38,6 @@ namespace OpenRA.Network
|
||||
|
||||
switch (order.OrderString)
|
||||
{
|
||||
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;
|
||||
var suffix = (player != null && player.WinState == WinState.Lost) ? " (Dead)" : "";
|
||||
suffix = client.IsObserver ? " (Spectator)" : suffix;
|
||||
|
||||
if (orderManager.LocalClient != null && client != orderManager.LocalClient && client.Team > 0 && client.Team == orderManager.LocalClient.Team)
|
||||
suffix += " (Ally)";
|
||||
|
||||
Game.AddChatLine(client.Color, client.Name + suffix, message);
|
||||
}
|
||||
else
|
||||
Game.AddChatLine(Color.White, "(player {0})".F(clientId), message);
|
||||
break;
|
||||
}
|
||||
|
||||
// Server message
|
||||
case "Message":
|
||||
Game.AddChatLine(Color.White, ServerChatName, order.TargetString);
|
||||
@@ -77,7 +52,7 @@ namespace OpenRA.Network
|
||||
break;
|
||||
}
|
||||
|
||||
case "TeamChat":
|
||||
case "Chat":
|
||||
{
|
||||
var client = orderManager.LobbyInfo.ClientWithIndex(clientId);
|
||||
if (client == null)
|
||||
@@ -88,6 +63,20 @@ namespace OpenRA.Network
|
||||
if (message.Length > ChatMessageMaxLength)
|
||||
message = order.TargetString.Substring(0, ChatMessageMaxLength);
|
||||
|
||||
// ExtraData 0 means this is a normal chat order, everything else is team chat
|
||||
if (order.ExtraData == 0)
|
||||
{
|
||||
var p = world != null ? world.FindPlayerByClient(client) : null;
|
||||
var suffix = (p != null && p.WinState == WinState.Lost) ? " (Dead)" : "";
|
||||
suffix = client.IsObserver ? " (Spectator)" : suffix;
|
||||
|
||||
if (orderManager.LocalClient != null && client != orderManager.LocalClient && client.Team > 0 && client.Team == orderManager.LocalClient.Team)
|
||||
suffix += " (Ally)";
|
||||
|
||||
Game.AddChatLine(client.Color, client.Name + suffix, message);
|
||||
break;
|
||||
}
|
||||
|
||||
// We are still in the lobby
|
||||
if (world == null)
|
||||
{
|
||||
@@ -103,8 +92,8 @@ namespace OpenRA.Network
|
||||
var player = world.FindPlayerByClient(client);
|
||||
var localClientIsObserver = orderManager.LocalClient.IsObserver || (world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined);
|
||||
|
||||
// ExtraData gives us the team number, 0 means Spectators
|
||||
if (order.ExtraData == 0 && (localClientIsObserver || world.IsReplay))
|
||||
// ExtraData gives us the team number, uint.MaxValue means Spectators
|
||||
if (order.ExtraData == uint.MaxValue && (localClientIsObserver || world.IsReplay))
|
||||
{
|
||||
// Validate before adding the line
|
||||
if (client.IsObserver || (player != null && player.WinState != WinState.Undefined))
|
||||
|
||||
@@ -631,7 +631,6 @@ namespace OpenRA.Server
|
||||
}
|
||||
|
||||
case "Chat":
|
||||
case "TeamChat":
|
||||
case "PauseGame":
|
||||
DispatchOrdersToClients(conn, 0, so.Serialize());
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user