Fix bogus ClampToWorld behavior (allowed helicopters to fly outside map)

This commit is contained in:
Paul Chote
2011-03-19 21:00:20 +13:00
parent 41a6e94e87
commit 0d53346138
4 changed files with 5 additions and 4 deletions

View File

@@ -74,7 +74,8 @@ namespace OpenRA
public static int2 ClampToWorld( this World world, int2 xy )
{
return xy.Clamp(world.Map.Bounds);
var r = world.Map.Bounds;
return xy.Clamp(new Rectangle(r.X,r.Y,r.Width-1, r.Height-1));
}
public static int2 ChooseRandomEdgeCell(this World w)

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA.Air
if (order.OrderString == "Move")
{
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
var target = self.World.ClampToWorld(order.TargetLocation);
self.SetTargetLine(Target.FromCell(target), Color.Green);
self.CancelActivity();

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Air
{
UnReserve();
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
var target = self.World.ClampToWorld(order.TargetLocation);
self.SetTargetLine(Target.FromCell(target), Color.Green);
self.CancelActivity();
self.QueueActivity(Fly.ToCell(target));

View File

@@ -276,7 +276,7 @@ namespace OpenRA.Mods.RA.Move
{
if (order.OrderString == "Move")
{
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
var target = self.World.ClampToWorld(order.TargetLocation);
PerformMove(self, target, order.Queued && !self.IsIdle);
}