summaryrefslogtreecommitdiff
path: root/roadveh_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 /roadveh_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 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 7106ce3d1..d5d42ba2b 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -1090,12 +1090,16 @@ static int RoadFindPathToDest(Vehicle *v, uint tile, int enterdir)
//debug("Finding path. Enterdir: %d, Trackdir: %d", enterdir, trackdir);
ftd = NPFRouteToStationOrTile(tile - TileOffsByDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->owner);
- if (ftd.best_bird_dist != 0 || ftd.best_trackdir == 0xff) {
- /* Not found, just do something, or we are already there */
+ if (ftd.best_trackdir == 0xff) {
+ /* We are already at our target. Just do something */
//TODO: maybe display error?
//TODO: go straight ahead if possible?
return_track(FindFirstBit2x64(bitmask));
} else {
+ /* 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_track(ftd.best_trackdir);
}
} else {