summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-05-06 22:08:14 +0000
committerpeter1138 <peter1138@openttd.org>2006-05-06 22:08:14 +0000
commitc778716264b3c269775029143d54c93168957adc (patch)
tree632c341e983c1ff365c6cc9ac2b80ef650c7a24a
parent6b8b8395e46f1771021edf73c2cac6a2f149e12b (diff)
downloadopenttd-c778716264b3c269775029143d54c93168957adc.tar.xz
(svn r4758) - Newstations: add support for 'blocked' station tiles, which no train can pass.
-rw-r--r--newgrf_station.c19
-rw-r--r--newgrf_station.h3
-rw-r--r--station_cmd.c2
-rw-r--r--station_map.h3
4 files changed, 26 insertions, 1 deletions
diff --git a/newgrf_station.c b/newgrf_station.c
index 18a138602..ef4d59ae4 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 bea4535a3..1492d549b 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 b748a9021..9605248f9 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 721d236e3..0e9c949c8 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);
}