From 4f60b2866b00e30c7766f0217d02956805b3f1c2 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 18 Jan 2010 14:25:59 +1300 Subject: [PATCH] CanPlaceBuilding always takes topleft (instead of topleft when !adjust) --- OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs | 2 +- OpenRa.Game/Orders/UnitOrderGenerator.cs | 2 +- OpenRa.Game/Traits/McvDeploy.cs | 2 +- OpenRa.Game/WorldUtils.cs | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs index c047266d95..696146f037 100644 --- a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs @@ -29,7 +29,7 @@ namespace OpenRa.Orders if (mi.Button == MouseButton.Left) { var topLeft = xy - Footprint.AdjustForBuildingSize( BuildingInfo ); - if (!Game.world.CanPlaceBuilding( Building, BuildingInfo, xy, null, true) + if (!Game.world.CanPlaceBuilding( Building, BuildingInfo, topLeft, null) || !Game.world.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, topLeft)) { Sound.Play("nodeply1.aud"); diff --git a/OpenRa.Game/Orders/UnitOrderGenerator.cs b/OpenRa.Game/Orders/UnitOrderGenerator.cs index 44e2a38ed4..ce8cff226d 100644 --- a/OpenRa.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRa.Game/Orders/UnitOrderGenerator.cs @@ -70,7 +70,7 @@ namespace OpenRa.Orders return Cursor.MoveBlocked; case "DeployMcv": var factBuildingInfo = Rules.ActorInfo["fact"].Traits.Get(); - if (Game.world.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a, false)) + if (Game.world.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a)) return Cursor.Deploy; else return Cursor.DeployBlocked; diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index f570157229..d2b48a9042 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -25,7 +25,7 @@ namespace OpenRa.Traits if( order.OrderString == "DeployMcv" ) { var factBuildingInfo = Rules.ActorInfo[ "fact" ].Traits.Get(); - if( Game.world.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) ) + if( Game.world.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self ) ) { self.CancelActivity(); self.QueueActivity( new Turn( 96 ) ); diff --git a/OpenRa.Game/WorldUtils.cs b/OpenRa.Game/WorldUtils.cs index f661d94ec0..4e734c875f 100755 --- a/OpenRa.Game/WorldUtils.cs +++ b/OpenRa.Game/WorldUtils.cs @@ -99,9 +99,8 @@ namespace OpenRa .FirstOrDefault(); } - public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) + public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore) { - var topLeft = adjust ? xy - Footprint.AdjustForBuildingSize( building ) : xy; return !Footprint.Tiles(name, building, topLeft).Any( t => !world.Map.IsInMap(t.X, t.Y) || world.Map.ContainsResource(t) || !world.IsCellBuildable(t, building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,