diff --git a/roadveh_cmd.c b/roadveh_cmd.c index e750554276..535aced709 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -1006,17 +1006,15 @@ static int RoadFindPathToDest(Vehicle *v, TileIndex tile, int enterdir) /* Road depot */ bitmask |= _road_veh_fp_ax_or[GB(_m[tile].m5, 0, 2)]; } - } else if (IsTileType(tile, MP_STATION)) { - if (IsTileOwner(tile, OWNER_NONE) || IsTileOwner(tile, v->owner)) { + } else if (IsTileType(tile, MP_STATION) && IsRoadStationTile(tile)) { + if (IsTileOwner(tile, v->owner)) { /* Our station */ - const Station* st = GetStation(_m[tile].m2); - byte val = _m[tile].m5; - if (v->cargo_type != CT_PASSENGERS) { - if (IS_BYTE_INSIDE(val, 0x43, 0x47) && (_patches.roadveh_queue || st->truck_stops->status&3)) - bitmask |= _road_veh_fp_ax_or[(val-0x43)&3]; - } else { - if (IS_BYTE_INSIDE(val, 0x47, 0x4B) && (_patches.roadveh_queue || st->bus_stops->status&3)) - bitmask |= _road_veh_fp_ax_or[(val-0x47)&3]; + RoadStopType rstype = (v->cargo_type == CT_PASSENGERS) ? RS_BUS : RS_TRUCK; + if (GetRoadStopType(tile) == rstype) { + const RoadStop *rs = GetRoadStopByTile(tile, rstype); + if (rs != NULL && (_patches.roadveh_queue || GB(rs->status, 0, 2) != 0)) { + bitmask |= _road_veh_fp_ax_or[GetRoadStationDir(tile)]; + } } } } diff --git a/station.h b/station.h index 0f2393913c..cec496b223 100644 --- a/station.h +++ b/station.h @@ -202,7 +202,7 @@ void StationPickerDrawSprite(int x, int y, RailType railtype, int image); uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype); RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type); -static inline int GetRoadStopType(TileIndex tile) +static inline RoadStopType GetRoadStopType(TileIndex tile) { return (_m[tile].m5 < 0x47) ? RS_TRUCK : RS_BUS; }