From 36e09990cabb279b8da9c82e2782710a624ce64b Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 6 Feb 2016 17:55:27 +0000 Subject: [PATCH] Fix Map.Contains checks for maps with height. If a cell lacked any valid projected cells, then it is off the map entirely. The previous logic would think such a cell was within the map as none of projected cells were out of bounds (as there were no projected cells to fail the check). --- OpenRA.Game/Map/Map.cs | 7 ++++++- OpenRA.Game/Traits/Player/FrozenActorLayer.cs | 8 +++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 45ccb07ec8..ab19cfa208 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -771,7 +771,12 @@ namespace OpenRA if (Grid.MaximumTerrainHeight == 0) return Contains((PPos)uv); - foreach (var puv in ProjectedCellsCovering(uv)) + // If the cell has no valid projection, then we're off the map. + var projectedCells = ProjectedCellsCovering(uv); + if (projectedCells.Length == 0) + return false; + + foreach (var puv in projectedCells) if (!Contains(puv)) return false; return true; diff --git a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs index 3b2ce7709e..494a7bb699 100644 --- a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs +++ b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs @@ -65,17 +65,15 @@ namespace OpenRA.Traits .ToArray(); if (Footprint.Length == 0) - throw new ArgumentException(("This frozen actor has no footprint! Please report a bug!\n" + + throw new ArgumentException(("This frozen actor has no footprint.\n" + "Actor Name: {0}\n" + "Actor Location: {1}\n" + "Input footprint: [{2}]\n" + - "Input footprint (shroud.Contains): [{3}]\n" + - "Input footprint (map.Contains): [{4}]") + "Input footprint (after shroud.Contains): [{3}]") .F(actor.Info.Name, actor.Location.ToString(), footprint.Select(p => p.ToString()).JoinWith("|"), - footprint.Select(p => shroud.Contains(p).ToString()).JoinWith("|"), - footprint.Select(p => actor.World.Map.Contains(p).ToString()).JoinWith("|"))); + footprint.Select(p => shroud.Contains(p).ToString()).JoinWith("|"))); CenterPosition = self.CenterPosition; Bounds = self.Bounds;