diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/map_v2.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/engines/gob/map_v2.cpp b/engines/gob/map_v2.cpp index e2f9207003..83f02bb69b 100644 --- a/engines/gob/map_v2.cpp +++ b/engines/gob/map_v2.cpp @@ -258,17 +258,24 @@ void Map_v2::findNearestToDest(Mult::Mult_Object *obj) { void Map_v2::optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y) { if (obj->nearestWayPoint < obj->nearestDest) { + for (int i = obj->nearestWayPoint; i <= obj->nearestDest; i++) { if (checkDirectPath(obj, x, y, _wayPoints[i].x, _wayPoints[i].y) == 1) obj->nearestWayPoint = i; } + } else { - for (int i = obj->nearestWayPoint; - i >= obj->nearestDest && (_wayPoints[i].notWalkable != 1); i--) { + + for (int i = obj->nearestWayPoint; i >= obj->nearestDest; i++) { + if (_wayPoints[i].notWalkable == 1) + break; + if (checkDirectPath(obj, x, y, _wayPoints[i].x, _wayPoints[i].y) == 1) obj->nearestWayPoint = i; } + } + } } // End of namespace Gob |