From 5a2f91be1c81496f098212b07169c5a6b9961059 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 27 Nov 2020 14:45:02 +0000 Subject: [PATCH] Fix building bibs not blocking placement. --- .../Traits/Buildings/BuildingUtils.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs index e899e49fe3..183a848f80 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs @@ -53,8 +53,9 @@ namespace OpenRA.Mods.Common.Traits } } - // Replacements are enabled and the cell contained at least one (not ignored) actor - if (foundActors) + // Replacements are enabled and the cell contained at least one (not ignored) actor or building bib + var building = world.WorldActor.Trait().GetBuildingAt(cell); + if (foundActors || building != null) { // The cell contains at least one actor, and none were replaceable if (acceptedReplacements == null) @@ -68,6 +69,14 @@ namespace OpenRA.Mods.Common.Traits return false; } } + else + { + // HACK: To preserve legacy behaviour, AllowInvalidPlacement should display red placement indicators + // if (and only if) there is a building or bib in the cell + var building = world.WorldActor.Trait().GetBuildingAt(cell); + if (building != null) + return false; + } // Buildings can never be placed on ramps return world.Map.Ramp[cell] == 0 && bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type);