summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-09 21:01:45 +0000
committerrubidium <rubidium@openttd.org>2009-09-09 21:01:45 +0000
commit96e2435aa827b9e4af60b7c87fd8da38f9b87cc2 (patch)
treeae66ccf568d694241914c749a9ab34f5bdc547e4 /src/roadveh_cmd.cpp
parent48893c3a97f65f3f97754660d6fbb9cd38494fde (diff)
downloadopenttd-96e2435aa827b9e4af60b7c87fd8da38f9b87cc2.tar.xz
(svn r17491) -Fix [FS#3188]: road vehicles could get lost when the prelimiary destination (for the pathfinder heuristics) is unreachable.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 6f656bb9a..11584d08e 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -689,22 +689,8 @@ TileIndex RoadVehicle::GetOrderStationLocation(StationID station)
{
if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
- TileIndex dest = INVALID_TILE;
- const RoadStop *rs = Station::Get(station)->GetPrimaryRoadStop(this);
- if (rs != NULL) {
- uint mindist = UINT_MAX;
-
- for (; rs != NULL; rs = rs->GetNextRoadStop(this)) {
- uint dist = DistanceManhattan(this->tile, rs->xy);
-
- if (dist < mindist) {
- mindist = dist;
- dest = rs->xy;
- }
- }
- }
-
- if (dest != INVALID_TILE) {
+ TileIndex dest;
+ if (YapfFindNearestRoadVehicleCompatibleStop(this, station, &dest)) {
return dest;
} else {
/* There is no stop left at the station, so don't even TRY to go there */