From 8fe0eb73e257b18809e5834439cd47f77542157b Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 7 Jul 2013 11:14:25 +1200 Subject: [PATCH] Ensure a valid target in move. --- OpenRA.Mods.RA/Move/Move.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.RA/Move/Move.cs b/OpenRA.Mods.RA/Move/Move.cs index 097e1ab51f..5e5cec526b 100755 --- a/OpenRA.Mods.RA/Move/Move.cs +++ b/OpenRA.Mods.RA/Move/Move.cs @@ -58,11 +58,18 @@ namespace OpenRA.Mods.RA.Move this.ignoreBuilding = ignoreBuilding; } + static readonly List NoPath = new List(); public Move(Target target, int range) { - this.getPath = (self,mobile) => self.World.WorldActor.Trait().FindUnitPathToRange( - mobile.toCell, target.CenterPosition.ToCPos(), - range, self); + this.getPath = (self, mobile) => + { + if (!target.IsValid) + return NoPath; + + return self.World.WorldActor.Trait().FindUnitPathToRange( + mobile.toCell, target.CenterPosition.ToCPos(), range, self); + }; + this.destination = null; this.nearEnough = range; }