summaryrefslogtreecommitdiff
path: root/ship_cmd.c
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-04-15 13:48:08 +0000
committermatthijs <matthijs@openttd.org>2005-04-15 13:48:08 +0000
commit4eeac3ea75232b5d5805c9b2d6b846eb5c50be15 (patch)
tree7b2ef5a2e3abfe4ae3dba0863c1370b6763e33cb /ship_cmd.c
parent174030a15f0b67bde1e62ad2d092197c8a722fa0 (diff)
downloadopenttd-4eeac3ea75232b5d5805c9b2d6b846eb5c50be15.tar.xz
(svn r2202) - Fix: [NPF] When a vehicle could not reach its target, it would choose a random direction. It will now try to get as close as possible.
Diffstat (limited to 'ship_cmd.c')
-rw-r--r--ship_cmd.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ship_cmd.c b/ship_cmd.c
index 3ccf8c11c..b988d50f1 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -576,12 +576,14 @@ static int ChooseShipTrack(Vehicle *v, uint tile, int enterdir, uint tracks)
ftd = NPFRouteToStationOrTile(src_tile, _track_direction_to_trackdir[track][v->direction], &fstd, TRANSPORT_WATER, v->owner);
- if (ftd.best_bird_dist == 0 && ftd.best_trackdir != 0xff)
- /* Found the target, and it is not our current tile */
+ if (ftd.best_trackdir != 0xff)
+ /* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
+ the direction we need to take to get there, if ftd.best_bird_dist is not 0,
+ we did not find our target, but ftd.best_trackdir contains the direction leading
+ to the tile closest to our target. */
return ftd.best_trackdir & 7; /* TODO: Wrapper function? */
else
- return -1; /* Couldn't find target, reverse */
- /* TODO: When the target is unreachable, the ship will keep reversing */
+ return -1; /* Already at target, reverse? */
} else {
uint b;
uint tot_dist, dist;