Send the designated team number as extra data in the order
This commit is contained in:
@@ -195,9 +195,12 @@ 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)
|
||||
public static Order Chat(bool team, string text, int teamNumber = 0)
|
||||
{
|
||||
return new Order(team ? "TeamChat" : "Chat", null, false) { IsImmediate = true, TargetString = text };
|
||||
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 };
|
||||
}
|
||||
|
||||
public static Order HandshakeResponse(string text)
|
||||
|
||||
@@ -100,14 +100,25 @@ namespace OpenRA.Network
|
||||
if (orderManager.LocalClient == null)
|
||||
break;
|
||||
|
||||
if (client.IsObserver && (orderManager.LocalClient.IsObserver || world.IsReplay))
|
||||
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))
|
||||
{
|
||||
Game.AddChatLine(client.Color, "[Spectators] " + client.Name, message);
|
||||
// Validate before adding the line
|
||||
if (client.IsObserver || (player != null && player.WinState != WinState.Undefined))
|
||||
Game.AddChatLine(client.Color, "[Spectators] " + client.Name, message);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (client.Team == orderManager.LocalClient.Team || world.IsReplay)
|
||||
Game.AddChatLine(client.Color, "[Team" + (world.IsReplay ? " " + client.Team : "") + "] " + client.Name, message);
|
||||
var valid = client.Team == order.ExtraData && player != null && player.WinState == WinState.Undefined;
|
||||
var isSameTeam = order.ExtraData == orderManager.LocalClient.Team && world.LocalPlayer != null
|
||||
&& world.LocalPlayer.WinState == WinState.Undefined;
|
||||
|
||||
if (valid && (isSameTeam || world.IsReplay))
|
||||
Game.AddChatLine(client.Color, "[Team" + (world.IsReplay ? " " + order.ExtraData : "") + "] " + client.Name, message);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user