Fix a crash with not space occupying actors granting support powers

This commit is contained in:
abcdefg30
2016-06-24 15:30:57 +02:00
parent eccdc47544
commit dd5e229886

View File

@@ -236,7 +236,14 @@ namespace OpenRA.Mods.Common.Traits
return; return;
var power = Instances.Where(i => !InstanceDisabled(i)) var power = Instances.Where(i => !InstanceDisabled(i))
.MinByOrDefault(a => (a.Self.CenterPosition - a.Self.World.Map.CenterOfCell(order.TargetLocation)).HorizontalLengthSquared); .MinByOrDefault(a =>
{
if (a.Self.OccupiesSpace == null)
return 0;
return (a.Self.CenterPosition - a.Self.World.Map.CenterOfCell(order.TargetLocation)).HorizontalLengthSquared;
});
if (power == null) if (power == null)
return; return;