(svn r4758) - Newstations: add support for 'blocked' station tiles, which no train can pass.
--- a/newgrf_station.c Sat May 06 21:46:26 2006 +0000
+++ b/newgrf_station.c Sat May 06 22:08:14 2006 +0000
@@ -640,3 +640,22 @@
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));
+}
--- a/newgrf_station.h Sat May 06 21:46:26 2006 +0000
+++ b/newgrf_station.h Sat May 06 22:08:14 2006 +0000
@@ -102,6 +102,9 @@
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);
--- a/station_cmd.c Sat May 06 21:46:26 2006 +0000
+++ b/station_cmd.c Sat May 06 22:08:14 2006 +0000
@@ -2124,6 +2124,8 @@
switch (mode) {
case TRANSPORT_RAIL:
if (IsRailwayStation(tile)) {
+ if (IsStationTileBlocked(tile)) return 0;
+
return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101;
}
break;
--- a/station_map.h Sat May 06 21:46:26 2006 +0000
+++ b/station_map.h Sat May 06 22:08:14 2006 +0000
@@ -187,7 +187,8 @@
return
IsRailwayStationTile(t1) &&
IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
- GetRailStationAxis(t1) == GetRailStationAxis(t2);
+ GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
+ !IsStationTileBlocked(t1);
}