diff --git a/OpenRa.Game/BuildingInfluenceMap.cs b/OpenRa.Game/BuildingInfluenceMap.cs index b6742b158e..1d7bc89bad 100644 --- a/OpenRa.Game/BuildingInfluenceMap.cs +++ b/OpenRa.Game/BuildingInfluenceMap.cs @@ -24,7 +24,7 @@ namespace OpenRa if( IsValid( u ) ) blocked[ u.X, u.Y ] = isAdd; - foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location, false ) ) + foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location ) ) if( IsValid( u ) ) influence[ u.X, u.Y ] = isAdd ? a : null; } diff --git a/OpenRa.Game/GameRules/Footprint.cs b/OpenRa.Game/GameRules/Footprint.cs index 165ab82b5d..fa113453a9 100644 --- a/OpenRa.Game/GameRules/Footprint.cs +++ b/OpenRa.Game/GameRules/Footprint.cs @@ -7,7 +7,7 @@ namespace OpenRa.GameRules { static class Footprint { - public static IEnumerable Tiles( string name, BuildingInfo buildingInfo, int2 position, bool adjustForPlacement ) + public static IEnumerable Tiles( string name, BuildingInfo buildingInfo, int2 position ) { var dim = buildingInfo.Dimensions; @@ -18,15 +18,12 @@ namespace OpenRa.GameRules footprint = footprint.Concat(new char[dim.X]); } - var adjustment = adjustForPlacement ? AdjustForBuildingSize(buildingInfo) : int2.Zero; - - var tiles = TilesWhere(name, dim, footprint.ToArray(), a => a != '_'); - return tiles.Select(t => t + position - adjustment); + return TilesWhere( name, dim, footprint.ToArray(), a => a != '_' ).Select( t => t + position ); } public static IEnumerable Tiles(Actor a, Traits.Building building) { - return Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location, false ); + return Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location ); } public static IEnumerable UnpathableTiles( string name, BuildingInfo buildingInfo, int2 position ) diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs index 97642bebcb..3042179706 100644 --- a/OpenRa.Game/UiOverlay.cs +++ b/OpenRa.Game/UiOverlay.cs @@ -49,7 +49,7 @@ namespace OpenRa var topLeft = position - Footprint.AdjustForBuildingSize( bi ); var isCloseEnough = Game.world.IsCloseEnoughToBase(Game.LocalPlayer, name, bi, position); - foreach( var t in Footprint.Tiles( name, bi, topLeft, false ) ) + foreach( var t in Footprint.Tiles( name, bi, topLeft ) ) spriteRenderer.DrawSprite( ( isCloseEnough && Game.world.IsCellBuildable( t, bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.world.Map.ContainsResource( t ) ) ? buildOk : buildBlocked, Game.CellSize * t, 0 ); diff --git a/OpenRa.Game/WorldUtils.cs b/OpenRa.Game/WorldUtils.cs index 500e25f013..13d82a8833 100755 --- a/OpenRa.Game/WorldUtils.cs +++ b/OpenRa.Game/WorldUtils.cs @@ -101,7 +101,8 @@ namespace OpenRa public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) { - return !Footprint.Tiles(name, building, xy, adjust).Any( + 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, toIgnore)); @@ -126,7 +127,7 @@ namespace OpenRa }; var topLeft = position - Footprint.AdjustForBuildingSize( bi ); - foreach (var t in Footprint.Tiles(buildingName, bi, topLeft, false)) search.AddInitialCell(t); + foreach (var t in Footprint.Tiles(buildingName, bi, topLeft)) search.AddInitialCell(t); return world.PathFinder.FindPath(search).Count != 0; }