diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 8d1e5f1dfa..f248c40f35 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -280,18 +280,18 @@ namespace OpenRa.Game return null; } - public static bool CanPlaceBuilding(string name, int2 xy, Actor toIgnore) + public static bool CanPlaceBuilding(string name, int2 xy, Actor toIgnore, bool adjust) { - var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo["fact"]; - return !Footprint.Tiles(bi, xy).Any( + var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[name]; + return !Footprint.Tiles(bi, xy, adjust).Any( t => !Game.IsCellBuildable(t, bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, toIgnore)); } - public static bool CanPlaceBuilding(string name, int2 xy) + public static bool CanPlaceBuilding(string name, int2 xy, bool adjust) { - return CanPlaceBuilding(name, xy, null); + return CanPlaceBuilding(name, xy, null, adjust); } public static void BuildUnit(Player player, string name) diff --git a/OpenRa.Game/GameRules/Footprint.cs b/OpenRa.Game/GameRules/Footprint.cs index d4a1cd2d11..47ae6fd693 100644 --- a/OpenRa.Game/GameRules/Footprint.cs +++ b/OpenRa.Game/GameRules/Footprint.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.GameRules return Tiles(unitInfo, position, true); } - static IEnumerable Tiles(UnitInfo unitInfo, int2 position, bool adjustForPlacement) + public static IEnumerable Tiles(UnitInfo unitInfo, int2 position, bool adjustForPlacement) { var buildingInfo = unitInfo as UnitInfo.BuildingInfo; var dim = buildingInfo.Dimensions; diff --git a/OpenRa.Game/PlaceBuilding.cs b/OpenRa.Game/PlaceBuilding.cs index 5f4b8835d1..53d53adf3c 100644 --- a/OpenRa.Game/PlaceBuilding.cs +++ b/OpenRa.Game/PlaceBuilding.cs @@ -21,12 +21,10 @@ namespace OpenRa.Game { if( lmb ) { - var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[ Name ]; - if( Footprint.Tiles( bi, xy ).Any( - t => !Game.IsCellBuildable( t, - bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel ) ) ) + if (!Game.CanPlaceBuilding(Name, xy, true)) yield break; + var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[Name]; var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */ if( !Footprint.Tiles( bi, xy ).Any( t => Game.GetDistanceToBase( t, Owner ) < maxDistance ) ) diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index de8fac5ce2..db0ce7fa96 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -17,7 +17,7 @@ namespace OpenRa.Game.Traits if (lmb) return null; if (xy == self.Location) - return OpenRa.Game.Order.DeployMcv(self, !Game.CanPlaceBuilding("fact", xy, self)); + return OpenRa.Game.Order.DeployMcv(self, !Game.CanPlaceBuilding("fact", xy - new int2(1,1), self, false)); return null; } diff --git a/OpenRa.Game/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs index e46b091790..953d6ff5cb 100755 --- a/OpenRa.Game/UnitOrders.cs +++ b/OpenRa.Game/UnitOrders.cs @@ -45,7 +45,7 @@ namespace OpenRa.Game } case "DeployMcv": { - if (!Game.CanPlaceBuilding("fact", order.Subject.Location, order.Subject)) + if (!Game.CanPlaceBuilding("fact", order.Subject.Location - new int2(1,1), order.Subject, false)) break; /* throw the order on the floor */ var mobile = order.Subject.traits.Get();