From db37b14392c4f3efdeae54ca8ceef4354adf1c95 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 15 Oct 2015 15:05:17 +0200 Subject: [PATCH 1/2] Minor code (style) cleanup --- OpenRA.Game/Network/UnitOrders.cs | 3 +-- .../Widgets/Logic/Ingame/IngameChatLogic.cs | 15 ++++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 0264d37978..7e1ef0a17f 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -76,8 +76,7 @@ namespace OpenRA.Network if (world == null) { if (orderManager.LocalClient != null && client.Team == orderManager.LocalClient.Team) - Game.AddChatLine(client.Color.RGB, client.Name + " (Team)", - order.TargetString); + Game.AddChatLine(client.Color.RGB, client.Name + " (Team)", order.TargetString); } else { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index ad6b1da00f..f5658c525c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -71,15 +71,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var team = teamChat && !disableTeamChat; if (chatText.Text != "") + { if (!chatText.Text.StartsWith("/")) orderManager.IssueOrder(Order.Chat(team, chatText.Text.Trim())); - else - if (chatTraits != null) - { - var text = chatText.Text.Trim(); - foreach (var trait in chatTraits) - trait.OnChat(orderManager.LocalClient.Name, text); - } + else if (chatTraits != null) + { + var text = chatText.Text.Trim(); + foreach (var trait in chatTraits) + trait.OnChat(orderManager.LocalClient.Name, text); + } + } chatText.Text = ""; CloseChat(); From cd628730033b3a76389a3439c3942a383430eaa9 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 15 Oct 2015 16:20:17 +0200 Subject: [PATCH 2/2] Add team chat for spectators --- OpenRA.Game/Network/UnitOrders.cs | 6 +++--- OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 7e1ef0a17f..53cff53af5 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -81,13 +81,13 @@ namespace OpenRA.Network else { var player = world.FindPlayerByClient(client); - if (player == null) return; - - if ((world.LocalPlayer != null && player.Stances[world.LocalPlayer] == Stance.Ally) || player.WinState == WinState.Lost) + if (player != null && ((world.LocalPlayer != null && player.Stances[world.LocalPlayer] == Stance.Ally) || player.WinState == WinState.Lost)) { var suffix = player.WinState == WinState.Lost ? " (Dead)" : " (Team)"; Game.AddChatLine(client.Color.RGB, client.Name + suffix, order.TargetString); } + else if (orderManager.LocalClient != null && orderManager.LocalClient.IsObserver && client.IsObserver) + Game.AddChatLine(client.Color.RGB, client.Name + " (Spectators)", order.TargetString); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index f5658c525c..ede4b0164e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic chatTraits = world.WorldActor.TraitsImplementing().ToArray(); var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant && !p.IsBot); - disableTeamChat = world.LocalPlayer == null || world.LobbyInfo.IsSinglePlayer || !players.Any(p => p.IsAlliedWith(world.LocalPlayer)); + disableTeamChat = world.IsReplay || world.LobbyInfo.IsSinglePlayer || (world.LocalPlayer != null && !players.Any(p => p.IsAlliedWith(world.LocalPlayer))); teamChat = !disableTeamChat; tabCompletion.Commands = chatTraits.OfType().SelectMany(x => x.Commands.Keys).ToList();