#240 declaring war should set the reciprocal state too

This commit is contained in:
Chris Forbes
2010-10-12 17:13:13 +13:00
parent 7c31f72db6
commit 10f8364b99

View File

@@ -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;
var newStance = (Stance)order.TargetLocation.Y;
if (targetPlayer == world.LocalPlayer)
world.WorldActor.Trait<Shroud>().UpdatePlayerStance(world, order.Player, oldStance, order.Player.Stances[targetPlayer]);
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<Shroud>().UpdatePlayerStance(w, b, oldStance, s);
}
}
}