--- a/elrail.c Mon May 08 17:47:35 2006 +0000
+++ b/elrail.c Mon May 08 21:59:36 2006 +0000
@@ -111,6 +111,7 @@
case MP_STATION:
if (!IsRailwayStation(t)) return 0;
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
+ if (!IsStationTileElectrifiable(t)) return 0;
return TrackToTrackBits(GetRailStationTrack(t));
default:
return 0;
--- a/newgrf_station.c Mon May 08 17:47:35 2006 +0000
+++ b/newgrf_station.c Mon May 08 21:59:36 2006 +0000
@@ -702,3 +702,23 @@
return HASBIT(statspec->blocked, GetStationGfx(tile));
}
+
+/* Check if a rail station tile is electrifiable.
+ * XXX This could be cached (during build) in the map array to save on all the dereferencing */
+bool IsStationTileElectrifiable(TileIndex tile)
+{
+ const Station *st;
+ const StationSpec *statspec;
+ uint specindex;
+
+ if (!IsCustomStationSpecIndex(tile)) return true;
+
+ 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->pylons, GetStationGfx(tile));
+}
--- a/newgrf_station.h Mon May 08 17:47:35 2006 +0000
+++ b/newgrf_station.h Mon May 08 21:59:36 2006 +0000
@@ -112,6 +112,9 @@
/* Check if a rail station tile is traversable. */
bool IsStationTileBlocked(TileIndex tile);
+/* Check if a rail station tile is electrifiable. */
+bool IsStationTileElectrifiable(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 Mon May 08 17:47:35 2006 +0000
+++ b/station_cmd.c Mon May 08 21:59:36 2006 +0000
@@ -2049,7 +2049,7 @@
// but this is something else. If AI builds station with 114 it looks all weird
DrawGroundSprite(image);
- if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
+ if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
foreach_draw_tile_seq(dtss, t->seq) {
image = dtss->image;