From 8ad4e0865164241a179a263093c93a6dce85e420 Mon Sep 17 00:00:00 2001 From: Remco van der Zon Date: Wed, 6 Jun 2012 10:54:21 +0200 Subject: [PATCH] Unit order client != null check fixed (int != null -> always true!) . Removed if-else branch in favour of sugar construct a?b:c. Note: One should (at least) consider to move var client = ... to the start of the switch construct. 4 branches of this switch are using this. (DRY) --- OpenRA.Game/Network/UnitOrders.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 7c7a844f61..a7e1d9c730 100755 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -97,19 +97,13 @@ namespace OpenRA.Network case "PauseGame": { - if(clientId != null) + var client = orderManager.LobbyInfo.ClientWithIndex(clientId); + + if(client != null) { - var client = orderManager.LobbyInfo.ClientWithIndex(clientId); - orderManager.GamePaused = !orderManager.GamePaused; - if(orderManager.GamePaused) - { - Game.AddChatLine(Color.White, "", "The game is paused by "+client.Name); - } - else - { - Game.AddChatLine(Color.White, "", "The game is un-paused by "+client.Name); - } + var pausetext = "The game is {0} by {1}".F( orderManager.GamePaused ? "paused" : "un-paused", client.Name ); + Game.AddChatLine(Color.White, "", pausetext); } break; }