summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-05-02 17:52:35 +0000
committermatthijs <matthijs@openttd.org>2005-05-02 17:52:35 +0000
commit5a692014514f3108be2aed43a611d6e5b1c3b03d (patch)
tree5e5a8b6624ba8d7c60e6ed58151481756d19e609
parent63784c5b5a57f571f23fa1c6a5a830d44864894e (diff)
downloadopenttd-5a692014514f3108be2aed43a611d6e5b1c3b03d.tar.xz
(svn r2249) - Fix: [ 1187703 ] [NPF] Road vehicles cannot find a depot when in a roadstop
-rw-r--r--roadveh_cmd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 0d668de20..b349bd8cc 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -310,7 +310,14 @@ static Depot *FindClosestRoadDepot(Vehicle *v)
if (_patches.new_pathfinding_all) {
NPFFoundTargetData ftd;
/* See where we are now */
- byte trackdir = _dir_to_diag_trackdir[(v->direction>>1)&3];
+ byte trackdir;
+ if (IsRoadStationTile(tile))
+ /* if we are in a station, simulate leaving the station (since
+ * v->direction won't contain anything usefule than */
+ trackdir = _dir_to_diag_trackdir[GetRoadStationDir(tile)];
+ else
+ trackdir = _dir_to_diag_trackdir[(v->direction>>1)&3];
+
ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->owner);
if (ftd.best_bird_dist == 0)
return GetDepotByTile(ftd.node.tile); /* Target found */