summaryrefslogtreecommitdiff
path: root/train_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
commitc08314a43a9efe5bac657fc66e02d834a09cd567 (patch)
tree7b2ef5a2e3abfe4ae3dba0863c1370b6763e33cb /train_cmd.c
parent1e13bf3d272a37dba078259bfd07481abbb5de8b (diff)
downloadopenttd-c08314a43a9efe5bac657fc66e02d834a09cd567.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 'train_cmd.c')
-rw-r--r--train_cmd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/train_cmd.c b/train_cmd.c
index b10090732..844d09153 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1672,12 +1672,17 @@ static byte ChooseTrainTrack(Vehicle *v, uint tile, int enterdir, byte trackbits
assert(trackdir != 0xff);
ftd = NPFRouteToStationOrTile(tile - TileOffsByDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner);
- if (ftd.best_bird_dist != 0 || ftd.best_trackdir == 0xff) {
- /* Not found, or we are already there. Just do something */
+
+ if (ftd.best_trackdir == 0xff) {
+ /* We are already at our target. Just do something */
//TODO: maybe display error?
//TODO: go straight ahead if possible?
best_track = FIND_FIRST_BIT(bits);
} 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. */
/* Discard enterdir information, making it a normal track */
best_track = ftd.best_trackdir & 7; /* TODO: Wrapper function? */
}