diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 9258d8229a..a537707c35 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -128,16 +128,25 @@ namespace OpenRa.Game.Traits public MoveTo( int2 destination ) { - this.getPath = (self, mobile) => Game.pathFinder.FindUnitPath(self.Location, destination, + this.getPath = (self, mobile) => Game.pathFinder.FindUnitPath( + self.Location, destination, mobile.GetMovementType()); this.destination = destination; } public MoveTo(Actor target, int range) { - this.getPath = (self, mobile) => Game.pathFinder.FindUnitPathToRange( - self.Location, target.Location, - mobile.GetMovementType(), 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.destination = null; } @@ -153,15 +162,15 @@ namespace OpenRa.Game.Traits { move.TickMove( self, mobile, this ); return; - } + } if( destination == self.Location ) { mobile.currentActivity = NextActivity; return; - } - - if( path == null ) path = getPath(self, mobile); + } + + if (path == null) path = getPath(self, mobile); if (path.Count == 0) {