diff --git a/OpenRA.Game/Traits/World/ActorMap.cs b/OpenRA.Game/Traits/World/ActorMap.cs index 7bb3911ecf..4511fa174c 100644 --- a/OpenRA.Game/Traits/World/ActorMap.cs +++ b/OpenRA.Game/Traits/World/ActorMap.cs @@ -119,22 +119,31 @@ namespace OpenRA.Traits // NOTE: always includes transients with influence public bool AnyUnitsAt(CPos a) { + if (!map.Contains(a)) + return false; + return influence[a] != null; } // NOTE: can not check aircraft public bool AnyUnitsAt(CPos a, SubCell sub, bool checkTransient = true) { - bool always = sub == SubCell.FullCell || sub == SubCell.Any; + if (!map.Contains(a)) + return false; + + var always = sub == SubCell.FullCell || sub == SubCell.Any; for (var i = influence[a]; i != null; i = i.Next) + { if (always || i.SubCell == sub || i.SubCell == SubCell.FullCell) { if (checkTransient) return true; + var pos = i.Actor.TraitOrDefault(); if (pos == null || !pos.IsLeavingCell(a, i.SubCell)) return true; } + } return false; } @@ -142,7 +151,10 @@ namespace OpenRA.Traits // NOTE: can not check aircraft public bool AnyUnitsAt(CPos a, SubCell sub, Func withCondition) { - bool always = sub == SubCell.FullCell || sub == SubCell.Any; + if (!map.Contains(a)) + return false; + + var always = sub == SubCell.FullCell || sub == SubCell.Any; for (var i = influence[a]; i != null; i = i.Next) if (always || i.SubCell == sub || i.SubCell == SubCell.FullCell) if (withCondition(i.Actor)) diff --git a/OpenRA.Mods.RA/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.RA/Warheads/CreateEffectWarhead.cs index 91bf3af422..43de068c80 100644 --- a/OpenRA.Mods.RA/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.RA/Warheads/CreateEffectWarhead.cs @@ -95,6 +95,9 @@ namespace OpenRA.Mods.RA { var world = firedBy.World; var targetTile = world.Map.CellContaining(pos); + if (!world.Map.Contains(targetTile)) + return false; + var impactType = GetImpactType(world, targetTile, pos); if (!ValidImpactTypes.HasFlag(impactType) || InvalidImpactTypes.HasFlag(impactType)) return false;