summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-30 18:22:56 +0000
committerrubidium <rubidium@openttd.org>2007-05-30 18:22:56 +0000
commit734a302fd18d49a390549fa357236bcb50d6ab60 (patch)
tree253a9753be4672ff16754117a76c51f42afac695 /src/roadveh_cmd.cpp
parent9d7be92bf4cefb7cacf7e9e98d1fca128db235dc (diff)
downloadopenttd-734a302fd18d49a390549fa357236bcb50d6ab60.tar.xz
(svn r9989) -Fix [FS#817]: trams/road vehicles did go to the closest road stop regardless whether they could actually "drive" on there.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index d411e92a7..ba731b9e9 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -729,11 +729,14 @@ static void ProcessRoadVehOrder(Vehicle *v)
IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK
);
+ TileIndex dest = INVALID_TILE;
if (rs != NULL) {
- TileIndex dest = rs->xy;
- uint mindist = DistanceManhattan(v->tile, rs->xy);
+ uint mindist = MAX_UVALUE(uint);
+
+ for (; rs != NULL; rs = rs->next) {
+ /* The vehicle cannot go to this roadstop */
+ if ((GetRoadTypes(rs->xy) & v->u.road.compatible_roadtypes) == ROADTYPES_NONE) continue;
- for (rs = rs->next; rs != NULL; rs = rs->next) {
uint dist = DistanceManhattan(v->tile, rs->xy);
if (dist < mindist) {
@@ -741,7 +744,10 @@ static void ProcessRoadVehOrder(Vehicle *v)
dest = rs->xy;
}
}
- v->dest_tile = dest;
+ }
+
+ if (dest != INVALID_TILE) {
+ v->dest_tile = dest;
} else {
/* There is no stop left at the station, so don't even TRY to go there */
v->cur_order_index++;