diff --git a/newgrf_station.c b/newgrf_station.c index 18a1386024..ef4d59ae4b 100644 --- a/newgrf_station.c +++ b/newgrf_station.c @@ -640,3 +640,22 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID return true; } +/* Check if a rail station tile is traversable. + * XXX This could be cached (during build) in the map array to save on all the dereferencing */ +bool IsStationTileBlocked(TileIndex tile) +{ + const Station *st; + const StationSpec *statspec; + uint specindex; + + if (!IsCustomStationSpecIndex(tile)) return false; + + st = GetStationByTile(tile); + specindex = GetCustomStationSpecIndex(tile); + if (specindex >= st->num_specs) return false; + + statspec = st->speclist[specindex].spec; + if (statspec == NULL) return false; + + return HASBIT(statspec->blocked, GetStationGfx(tile)); +} diff --git a/newgrf_station.h b/newgrf_station.h index bea4535a3a..1492d549b3 100644 --- a/newgrf_station.h +++ b/newgrf_station.h @@ -102,6 +102,9 @@ const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx); SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile); uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile); +/* Check if a rail station tile is traversable. */ +bool IsStationTileBlocked(TileIndex tile); + /* Allocate a StationSpec to a Station. This is called once per build operation. */ int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec); diff --git a/station_cmd.c b/station_cmd.c index b748a90213..9605248f9a 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -2124,6 +2124,8 @@ static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode) switch (mode) { case TRANSPORT_RAIL: if (IsRailwayStation(tile)) { + if (IsStationTileBlocked(tile)) return 0; + return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101; } break; diff --git a/station_map.h b/station_map.h index 721d236e36..0e9c949c86 100644 --- a/station_map.h +++ b/station_map.h @@ -187,7 +187,8 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2) return IsRailwayStationTile(t1) && IsCompatibleRail(GetRailType(t1), GetRailType(t2)) && - GetRailStationAxis(t1) == GetRailStationAxis(t2); + GetRailStationAxis(t1) == GetRailStationAxis(t2) && + !IsStationTileBlocked(t1); }