From c6ed6dbeb9f9f4a43520cee34ade1525f815c94a Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 10 Jul 2014 20:34:17 +1200 Subject: [PATCH] Remove redundant overload and return early if outside map. --- OpenRA.Mods.RA/Buildings/Util.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.RA/Buildings/Util.cs b/OpenRA.Mods.RA/Buildings/Util.cs index 285ece10a2..1d7a55a2ca 100644 --- a/OpenRA.Mods.RA/Buildings/Util.cs +++ b/OpenRA.Mods.RA/Buildings/Util.cs @@ -16,20 +16,18 @@ namespace OpenRA.Mods.RA.Buildings { public static class BuildingUtils { - public static bool IsCellBuildable(this World world, CPos a, BuildingInfo bi) + public static bool IsCellBuildable(this World world, CPos cell, BuildingInfo bi, Actor toIgnore = null) { - return world.IsCellBuildable(a, bi, null); - } - - public static bool IsCellBuildable(this World world, CPos a, BuildingInfo bi, Actor toIgnore) - { - if (world.WorldActor.Trait().GetBuildingAt(a) != null) + if (!world.Map.Contains(cell)) return false; - if (!bi.AllowInvalidPlacement && world.ActorMap.GetUnitsAt(a).Any(b => b != toIgnore)) + if (world.WorldActor.Trait().GetBuildingAt(cell) != null) return false; - return world.Map.Contains(a) && bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(a).Type); + if (!bi.AllowInvalidPlacement && world.ActorMap.GetUnitsAt(cell).Any(a => a != toIgnore)) + return false; + + return bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type); } public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, CPos topLeft, Actor toIgnore)