From 58f9347cb77c2ac85e72f3df61921ae729222ce6 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 27 Oct 2009 17:58:57 +1300 Subject: [PATCH] fixed attack causing units to vanish --- OpenRa.Game/PathFinder.cs | 2 ++ OpenRa.Game/Traits/Mobile.cs | 16 ++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs index 27237d0c70..aa8216ca92 100644 --- a/OpenRa.Game/PathFinder.cs +++ b/OpenRa.Game/PathFinder.cs @@ -113,6 +113,8 @@ namespace OpenRa.Game pathNode = cellInfo[ pathNode.X, pathNode.Y ].Path; } + ret.Add(pathNode - offset); + return ret; } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index a537707c35..18a45e83e7 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -136,17 +136,9 @@ namespace OpenRa.Game.Traits public MoveTo(Actor target, int range) { - this.getPath = (self, mobile) => - { - var p = Game.pathFinder.FindUnitPathToRange( - self.Location, target.Location, - mobile.GetMovementType(), range); - - if (p.Count == 1 && self.Location == p[0]) - return new List(); /* hackety hack... Mobile doesn't like degenerate paths much */ - - return p; - }; + this.getPath = (self, mobile) => Game.pathFinder.FindUnitPathToRange( + self.Location, target.Location, + mobile.GetMovementType(), range); this.destination = null; } @@ -170,7 +162,7 @@ namespace OpenRa.Game.Traits return; } - if (path == null) path = getPath(self, mobile); + if (path == null) path = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList(); if (path.Count == 0) {