From 10f8364b99e8e54439e510d544576983af63c8f2 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Oct 2010 17:13:13 +1300 Subject: [PATCH] #240 declaring war should set the reciprocal state too --- OpenRA.Game/Network/UnitOrders.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index d38a4afab6..f1908e455d 100755 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -93,13 +93,16 @@ namespace OpenRA.Network { var targetPlayer = order.Player.World.players[order.TargetLocation.X]; var oldStance = order.Player.Stances[targetPlayer]; - order.Player.Stances[targetPlayer] = (Stance)order.TargetLocation.Y; - - if (targetPlayer == world.LocalPlayer) - world.WorldActor.Trait().UpdatePlayerStance(world, order.Player, oldStance, order.Player.Stances[targetPlayer]); - + var newStance = (Stance)order.TargetLocation.Y; + + SetPlayerStance(world, order.Player, targetPlayer, newStance); + + // automatically declare war reciprocally + if (newStance == Stance.Enemy) + SetPlayerStance(world, targetPlayer, order.Player, newStance); + Game.Debug("{0} has set diplomatic stance vs {1} to {2}".F( - order.Player.PlayerName, targetPlayer.PlayerName, order.Player.Stances[targetPlayer])); + order.Player.PlayerName, targetPlayer.PlayerName, newStance)); break; } default: @@ -111,5 +114,13 @@ namespace OpenRA.Network } } } + + static void SetPlayerStance(World w, Player a, Player b, Stance s) + { + var oldStance = a.Stances[b]; + a.Stances[b] = s; + if (b == w.LocalPlayer) + w.WorldActor.Trait().UpdatePlayerStance(w, b, oldStance, s); + } } }