summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2006-05-08 21:59:36 +0000
committerglx <glx@openttd.org>2006-05-08 21:59:36 +0000
commitcd3c14133640fde8d6d12ab59f869baa6d6f5724 (patch)
tree87873445dadc459a7e9897c13eba0899ad07422a
parent8fa9ff068fcfc030ffaf6ecc62d97ffbe66abe5a (diff)
downloadopenttd-cd3c14133640fde8d6d12ab59f869baa6d6f5724.tar.xz
(svn r4785) - Newstations: don't draw catenary on non-track tiles
-rw-r--r--elrail.c1
-rw-r--r--newgrf_station.c20
-rw-r--r--newgrf_station.h3
-rw-r--r--station_cmd.c2
4 files changed, 25 insertions, 1 deletions
diff --git a/elrail.c b/elrail.c
index ada534046..78ae2437d 100644
--- a/elrail.c
+++ b/elrail.c
@@ -111,6 +111,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
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;
diff --git a/newgrf_station.c b/newgrf_station.c
index aa5b32a53..d35ffc51f 100644
--- a/newgrf_station.c
+++ b/newgrf_station.c
@@ -702,3 +702,23 @@ bool IsStationTileBlocked(TileIndex tile)
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));
+}
diff --git a/newgrf_station.h b/newgrf_station.h
index b7ec6063e..33f3d732a 100644
--- a/newgrf_station.h
+++ b/newgrf_station.h
@@ -112,6 +112,9 @@ uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const S
/* 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);
diff --git a/station_cmd.c b/station_cmd.c
index e9910b8cd..ea46f0f5c 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2049,7 +2049,7 @@ static void DrawTile_Station(TileInfo *ti)
// 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;