Fix diplomacy stance cycling exploit.

This commit is contained in:
Paul Chote
2010-11-28 09:42:37 +13:00
parent 3189a4f457
commit ac82121460
2 changed files with 14 additions and 10 deletions

View File

@@ -118,12 +118,16 @@ namespace OpenRA.Network
SetPlayerStance(world, order.Player, targetPlayer, newStance); 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( Game.Debug("{0} has set diplomatic stance vs {1} to {2}".F(
order.Player.PlayerName, targetPlayer.PlayerName, newStance)); order.Player.PlayerName, targetPlayer.PlayerName, newStance));
// automatically declare war reciprocally
if (newStance == Stance.Enemy && targetPlayer.Stances[order.Player] == Stance.Ally)
{
SetPlayerStance(world, targetPlayer, order.Player, newStance);
Game.Debug("{0} has reciprocated",targetPlayer.PlayerName);
}
break; break;
} }
default: default:
@@ -141,12 +145,12 @@ namespace OpenRA.Network
} }
} }
static void SetPlayerStance(World w, Player a, Player b, Stance s) static void SetPlayerStance(World w, Player p, Player target, Stance s)
{ {
var oldStance = a.Stances[b]; var oldStance = p.Stances[target];
a.Stances[b] = s; p.Stances[target] = s;
if (b == w.LocalPlayer) if (target == w.LocalPlayer)
w.WorldActor.Trait<Shroud>().UpdatePlayerStance(w, b, oldStance, s); w.WorldActor.Trait<Shroud>().UpdatePlayerStance(w, p, oldStance, s);
} }
} }
} }

View File

@@ -108,7 +108,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
{ {
Bounds = new Rectangle( margin + 2 * labelWidth + 20, y, labelWidth, 25), Bounds = new Rectangle( margin + 2 * labelWidth + 20, y, labelWidth, 25),
Id = "DIPLOMACY_PLAYER_LABEL_MY_{0}".F(p.Index), Id = "DIPLOMACY_PLAYER_LABEL_MY_{0}".F(p.Index),
Text = world.LocalPlayer.Stances[ pp ].ToString(), GetText = () => world.LocalPlayer.Stances[ pp ].ToString(),
}; };
myStance.OnMouseDown = mi => { ShowDropDown(pp, myStance); return true; }; myStance.OnMouseDown = mi => { ShowDropDown(pp, myStance); return true; };