2006-03-29 16:30:26 +00:00
|
|
|
/* $Id$ */
|
|
|
|
/** @file elrail.c
|
2006-04-05 08:28:03 +00:00
|
|
|
This file deals with displaying wires and pylons for electric railways.
|
2006-03-29 16:30:26 +00:00
|
|
|
<h2>Basics</h2>
|
|
|
|
|
|
|
|
<h3>Tile Types</h3>
|
|
|
|
|
|
|
|
We have two different types of tiles in the drawing code:
|
|
|
|
Normal Railway Tiles (NRTs) which can have more than one track on it, and
|
|
|
|
Special Railways tiles (SRTs) which have only one track (like crossings, depots
|
|
|
|
stations, etc).
|
|
|
|
|
|
|
|
<h3>Location Categories</h3>
|
|
|
|
|
|
|
|
All tiles are categorized into three location groups (TLG):
|
|
|
|
Group 0: Tiles with both an even X coordinate and an even Y coordinate
|
|
|
|
Group 1: Tiles with an even X and an odd Y coordinate
|
|
|
|
Group 2: Tiles with an odd X and an even Y coordinate
|
|
|
|
Group 3: Tiles with both an odd X and Y coordnate.
|
|
|
|
|
|
|
|
<h3>Pylon Points</h3>
|
|
|
|
<h4>Control Points</h4>
|
|
|
|
A Pylon Control Point (PCP) is a position where a wire (or rather two)
|
|
|
|
is mounted onto a pylon.
|
2006-04-05 08:28:03 +00:00
|
|
|
Each NRT does contain 4 PCPs which are bitmapped to a byte
|
|
|
|
variable and are represented by the DiagDirection enum
|
2006-03-29 16:30:26 +00:00
|
|
|
|
2006-04-05 08:28:03 +00:00
|
|
|
Each track ends on two PCPs and thus requires one pylon on each end. However,
|
|
|
|
there is one exception: Straight-and-level tracks only have one pylon every
|
|
|
|
other tile.
|
2006-03-29 16:30:26 +00:00
|
|
|
|
2006-04-05 08:28:03 +00:00
|
|
|
Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs
|
|
|
|
are merged using an OR operation (i. e. if one tile needs a PCP at the postion
|
|
|
|
in question, both tiles get it).
|
2006-03-29 16:30:26 +00:00
|
|
|
|
|
|
|
<h4>Position Points</h4>
|
2006-04-05 08:28:03 +00:00
|
|
|
A Pylon Position Point (PPP) is a position where a pylon is located on the
|
|
|
|
ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around
|
|
|
|
it. PPPs are represented using the Direction enum. Each track bit has PPPs
|
|
|
|
that are impossible (because the pylon would be situated on the track) and
|
|
|
|
some that are preferred (because the pylon would be rectangular to the track).
|
2006-03-29 16:30:26 +00:00
|
|
|
|
|
|
|
<img src="../../elrail_tile.png">
|
|
|
|
<img src="../../elrail_track.png">
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "openttd.h"
|
2006-03-30 09:08:43 +00:00
|
|
|
#include "station_map.h"
|
2006-03-29 16:30:26 +00:00
|
|
|
#include "tile.h"
|
|
|
|
#include "viewport.h"
|
|
|
|
#include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */
|
|
|
|
#include "variables.h" /* ... same here */
|
|
|
|
#include "rail.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "tunnel_map.h"
|
|
|
|
#include "road_map.h"
|
|
|
|
#include "bridge_map.h"
|
|
|
|
#include "bridge.h"
|
|
|
|
#include "rail_map.h"
|
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/elrail_data.h"
|
|
|
|
|
|
|
|
static inline TLG GetTLG(TileIndex t)
|
|
|
|
{
|
|
|
|
return (HASBIT(TileX(t), 0) << 1) + HASBIT(TileY(t), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Finds which Rail Bits are present on a given tile. For bridge tiles,
|
|
|
|
* returns track bits under the bridge
|
|
|
|
*/
|
|
|
|
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
|
|
|
{
|
|
|
|
switch (GetTileType(t)) {
|
|
|
|
case MP_RAILWAY:
|
|
|
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
|
|
|
switch (GetRailTileType(t)) {
|
2006-05-09 08:17:33 +00:00
|
|
|
case RAIL_TILE_NORMAL: case RAIL_TILE_SIGNALS:
|
2006-03-29 16:30:26 +00:00
|
|
|
return GetTrackBits(t);
|
2006-05-09 08:17:33 +00:00
|
|
|
case RAIL_TILE_DEPOT_WAYPOINT:
|
2006-03-30 13:12:36 +00:00
|
|
|
if (GetRailTileSubtype(t) == RAIL_SUBTYPE_WAYPOINT) return GetRailWaypointBits(t);
|
2006-03-29 16:30:26 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
case MP_TUNNELBRIDGE:
|
|
|
|
if (IsTunnel(t)) {
|
|
|
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
|
|
|
if (override != NULL) *override = 1 << GetTunnelDirection(t);
|
2006-07-22 08:59:52 +00:00
|
|
|
return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t)));
|
2006-03-29 16:30:26 +00:00
|
|
|
} else {
|
|
|
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
2006-06-07 19:35:21 +00:00
|
|
|
if (IsBridgeMiddle(t)) {
|
|
|
|
if (IsTransportUnderBridge(t) &&
|
|
|
|
GetTransportTypeUnderBridge(t) == TRANSPORT_RAIL) {
|
|
|
|
return GetRailBitsUnderBridge(t);
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) *override = 1 << GetBridgeRampDirection(t);
|
|
|
|
|
2006-07-22 08:59:52 +00:00
|
|
|
return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t)));
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
case MP_STREET:
|
2006-05-09 08:25:31 +00:00
|
|
|
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return 0;
|
2006-03-30 09:08:43 +00:00
|
|
|
if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return 0;
|
2006-03-29 16:30:26 +00:00
|
|
|
return GetCrossingRailBits(t);
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
case MP_STATION:
|
2006-03-31 19:01:57 +00:00
|
|
|
if (!IsRailwayStation(t)) return 0;
|
2006-03-29 16:30:26 +00:00
|
|
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
2006-05-08 21:59:36 +00:00
|
|
|
if (!IsStationTileElectrifiable(t)) return 0;
|
2006-03-30 13:06:16 +00:00
|
|
|
return TrackToTrackBits(GetRailStationTrack(t));
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
/** Corrects the tileh for certain tile types. Returns an effective tileh for the track on the tile.
|
|
|
|
* @param tile The tile to analyse
|
|
|
|
* @param *tileh the tileh
|
|
|
|
*/
|
2006-07-26 03:33:12 +00:00
|
|
|
static void AdjustTileh(TileIndex tile, Slope *tileh)
|
2006-04-05 09:17:43 +00:00
|
|
|
{
|
2006-06-27 21:25:53 +00:00
|
|
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
|
|
|
if (IsTunnel(tile)) {
|
2006-04-23 13:48:16 +00:00
|
|
|
*tileh = SLOPE_FLAT;
|
2006-04-05 09:17:43 +00:00
|
|
|
} else {
|
2006-06-27 21:25:53 +00:00
|
|
|
if (IsBridgeRamp(tile)) {
|
|
|
|
if (*tileh != SLOPE_FLAT) {
|
|
|
|
*tileh = SLOPE_FLAT;
|
|
|
|
} else {
|
|
|
|
switch (GetBridgeRampDirection(tile)) {
|
|
|
|
case DIAGDIR_NE: *tileh = SLOPE_NE; break;
|
|
|
|
case DIAGDIR_SE: *tileh = SLOPE_SE; break;
|
|
|
|
case DIAGDIR_SW: *tileh = SLOPE_SW; break;
|
|
|
|
case DIAGDIR_NW: *tileh = SLOPE_NW; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2006-04-05 09:17:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
/** Draws wires and, if required, pylons on a given tile
|
|
|
|
* @param ti The Tileinfo to draw the tile for
|
|
|
|
*/
|
|
|
|
static void DrawCatenaryRailway(const TileInfo *ti)
|
|
|
|
{
|
|
|
|
/* Pylons are placed on a tile edge, so we need to take into account
|
|
|
|
the track configuration of 2 adjacent tiles. trackconfig[0] stores the
|
|
|
|
current tile (home tile) while [1] holds the neighbour */
|
|
|
|
TrackBits trackconfig[TS_END];
|
|
|
|
bool isflat[TS_END];
|
|
|
|
/* Note that ti->tileh has already been adjusted for Foundations */
|
2006-04-23 13:48:16 +00:00
|
|
|
Slope tileh[TS_END] = { ti->tileh, SLOPE_FLAT };
|
2006-03-29 16:30:26 +00:00
|
|
|
|
|
|
|
TLG tlg = GetTLG(ti->tile);
|
|
|
|
byte PCPstatus = 0;
|
|
|
|
byte OverridePCP = 0;
|
2006-03-31 16:01:59 +00:00
|
|
|
byte PPPpreferred[DIAGDIR_END];
|
|
|
|
byte PPPallowed[DIAGDIR_END];
|
2006-03-29 16:30:26 +00:00
|
|
|
DiagDirection i;
|
|
|
|
Track t;
|
|
|
|
|
|
|
|
/* Find which rail bits are present, and select the override points.
|
|
|
|
We don't draw a pylon:
|
|
|
|
1) INSIDE a tunnel (we wouldn't see it anyway)
|
|
|
|
2) on the "far" end of a bridge head (the one that connects to bridge middle),
|
|
|
|
because that one is drawn on the bridge. Exception is for length 0 bridges
|
|
|
|
which have no middle tiles */
|
|
|
|
trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP);
|
|
|
|
/* If a track bit is present that is not in the main direction, the track is level */
|
2006-04-07 07:19:14 +00:00
|
|
|
isflat[TS_HOME] = trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT);
|
2006-03-29 16:30:26 +00:00
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
AdjustTileh(ti->tile, &tileh[TS_HOME]);
|
2006-03-29 16:30:26 +00:00
|
|
|
|
|
|
|
for (i = DIAGDIR_NE; i < DIAGDIR_END; i++) {
|
|
|
|
TileIndex neighbour = ti->tile + TileOffsByDir(i);
|
|
|
|
uint foundation = 0;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
/* Here's one of the main headaches. GetTileSlope does not correct for possibly
|
|
|
|
existing foundataions, so we do have to do that manually later on.*/
|
|
|
|
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL);
|
|
|
|
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
|
2006-04-05 09:28:57 +00:00
|
|
|
if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0;
|
2006-04-07 07:19:14 +00:00
|
|
|
isflat[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT);
|
2006-03-29 16:30:26 +00:00
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
PPPpreferred[i] = 0xFF; /* We start with preferring everything (end-of-line in any direction) */
|
|
|
|
PPPallowed[i] = AllowedPPPonPCP[i];
|
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
/* We cycle through all the existing tracks at a PCP and see what
|
|
|
|
PPPs we want to have, or may not have at all */
|
2006-04-05 09:17:43 +00:00
|
|
|
for (k = 0; k < NUM_TRACKS_AT_PCP; k++) {
|
2006-03-29 16:30:26 +00:00
|
|
|
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */
|
2006-04-05 09:17:43 +00:00
|
|
|
if (TrackSourceTile[i][k] == TS_NEIGHBOUR &&
|
2006-06-07 19:35:21 +00:00
|
|
|
IsBridgeTile(neighbour) && IsBridgeRamp(neighbour) &&
|
2006-06-10 08:37:41 +00:00
|
|
|
GetBridgeRampDirection(neighbour) == ReverseDiagDir(i)) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-03-29 16:30:26 +00:00
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
/* We check whether the track in question (k) is present in the tile
|
|
|
|
(TrackSourceTile) */
|
|
|
|
if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) {
|
|
|
|
/* track found, if track is in the neighbour tile, adjust the number
|
|
|
|
of the PCP for preferred/allowed determination*/
|
|
|
|
DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i);
|
|
|
|
SETBIT(PCPstatus, i); /* This PCP is in use */
|
|
|
|
|
|
|
|
PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos];
|
|
|
|
PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos];
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Deactivate all PPPs if PCP is not used */
|
|
|
|
PPPpreferred[i] *= HASBIT(PCPstatus, i);
|
|
|
|
PPPallowed[i] *= HASBIT(PCPstatus, i);
|
|
|
|
|
2006-05-20 21:04:43 +00:00
|
|
|
/* A station is always "flat", so adjust the tileh accordingly */
|
|
|
|
if (IsTileType(neighbour, MP_STATION)) tileh[TS_NEIGHBOUR] = SLOPE_FLAT;
|
2006-03-29 16:30:26 +00:00
|
|
|
|
|
|
|
/* Read the foundataions if they are present, and adjust the tileh */
|
|
|
|
if (IsTileType(neighbour, MP_RAILWAY)) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]);
|
2006-06-07 19:35:21 +00:00
|
|
|
if (IsBridgeTile(neighbour) && IsBridgeRamp(neighbour)) {
|
2006-03-30 09:26:17 +00:00
|
|
|
foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour)));
|
|
|
|
}
|
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
if (foundation != 0) {
|
|
|
|
if (foundation < 15) {
|
2006-04-23 13:48:16 +00:00
|
|
|
tileh[TS_NEIGHBOUR] = SLOPE_FLAT;
|
2006-03-29 16:30:26 +00:00
|
|
|
} else {
|
|
|
|
tileh[TS_NEIGHBOUR] = _inclined_tileh[foundation - 15];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]);
|
2006-03-29 16:30:26 +00:00
|
|
|
|
|
|
|
/* If we have a straight (and level) track, we want a pylon only every 2 tiles
|
|
|
|
Delete the PCP if this is the case. */
|
|
|
|
/* Level means that the slope is the same, or the track is flat */
|
|
|
|
if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) {
|
|
|
|
for (k = 0; k < NUM_IGNORE_GROUPS; k++)
|
2006-04-05 09:17:43 +00:00
|
|
|
if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) CLRBIT(PCPstatus, i);
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist.
|
2006-03-29 16:30:26 +00:00
|
|
|
In that case, we try the any of the allowed ones. if they don't exist either, don't draw
|
2006-04-05 09:17:43 +00:00
|
|
|
anything. Note that the preferred PPPs still contain the end-of-line markers.
|
|
|
|
Remove those (simply by ANDing with allowed, since these markers are never allowed) */
|
2006-06-27 21:25:53 +00:00
|
|
|
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i];
|
2006-03-29 16:30:26 +00:00
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
|
2006-03-29 16:30:26 +00:00
|
|
|
for (k = 0; k < DIR_END; k++) {
|
|
|
|
byte temp = PPPorder[i][GetTLG(ti->tile)][k];
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2006-04-05 09:17:43 +00:00
|
|
|
if (HASBIT(PPPallowed[i], temp)) {
|
2006-03-29 16:30:26 +00:00
|
|
|
uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[temp];
|
|
|
|
uint y = ti->y + y_pcp_offsets[i] + y_ppp_offsets[temp];
|
|
|
|
|
|
|
|
/* Don't build the pylon if it would be outside the tile */
|
|
|
|
if (!HASBIT(OwnedPPPonPCP[i], temp)) {
|
|
|
|
/* We have a neighour that will draw it, bail out */
|
|
|
|
if (trackconfig[TS_NEIGHBOUR] != 0) break;
|
|
|
|
continue; /* No neighbour, go looking for a better position */
|
|
|
|
}
|
|
|
|
|
|
|
|
AddSortableSpriteToDraw(pylons_normal[temp], x, y, 1, 1, 10,
|
|
|
|
GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]));
|
|
|
|
break; /* We already have drawn a pylon, bail out */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Drawing of pylons is finished, now draw the wires */
|
|
|
|
for (t = 0; t < TRACK_END; t++) {
|
|
|
|
if (HASBIT(trackconfig[TS_HOME], t)) {
|
|
|
|
|
|
|
|
byte PCPconfig = HASBIT(PCPstatus, PCPpositions[t][0]) +
|
|
|
|
(HASBIT(PCPstatus, PCPpositions[t][1]) << 1);
|
|
|
|
|
|
|
|
const SortableSpriteStruct *sss;
|
|
|
|
int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; /* tileh for the slopes, 0 otherwise */
|
|
|
|
|
2006-06-07 19:35:21 +00:00
|
|
|
if ( /* We are not drawing a wire under a low bridge */
|
|
|
|
IsBridgeTile(ti->tile) &&
|
|
|
|
IsBridgeMiddle(ti->tile) &&
|
|
|
|
!(_display_opt & DO_TRANS_BUILDINGS) &&
|
2006-06-14 09:01:21 +00:00
|
|
|
GetBridgeHeight(ti->tile) <= TilePixelHeight(ti->tile) + TILE_HEIGHT
|
2006-06-07 19:35:21 +00:00
|
|
|
) return;
|
2006-03-29 16:30:26 +00:00
|
|
|
|
|
|
|
assert(PCPconfig != 0); /* We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) */
|
2006-04-23 13:48:16 +00:00
|
|
|
assert(!IsSteepSlope(tileh[TS_HOME]));
|
2006-03-29 16:30:26 +00:00
|
|
|
sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
|
|
|
|
|
|
|
|
AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
2006-04-23 19:35:36 +00:00
|
|
|
sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset);
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DrawCatenaryOnBridge(const TileInfo *ti)
|
|
|
|
{
|
2006-04-04 12:31:29 +00:00
|
|
|
TileIndex end = GetSouthernBridgeEnd(ti->tile);
|
|
|
|
TileIndex start = GetOtherBridgeEnd(end);
|
|
|
|
|
|
|
|
uint length = GetBridgeLength(start, end);
|
2006-03-29 16:30:26 +00:00
|
|
|
uint num = DistanceMax(ti->tile, start);
|
2006-07-22 09:08:34 +00:00
|
|
|
uint height;
|
2006-04-04 12:31:29 +00:00
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
const SortableSpriteStruct *sss;
|
|
|
|
Axis axis = GetBridgeAxis(ti->tile);
|
|
|
|
TLG tlg = GetTLG(ti->tile);
|
|
|
|
|
|
|
|
CatenarySprite offset = axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH;
|
|
|
|
|
|
|
|
if ((length % 2) && num == length) {
|
2006-04-04 12:31:29 +00:00
|
|
|
/* Draw the "short" wire on the southern end of the bridge
|
|
|
|
* only needed if the length of the bridge is odd */
|
2006-03-29 16:30:26 +00:00
|
|
|
sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset];
|
|
|
|
} else {
|
2006-04-04 12:31:29 +00:00
|
|
|
/* Draw "long" wires on all other tiles of the bridge (one pylon every two tiles) */
|
2006-03-29 16:30:26 +00:00
|
|
|
sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset];
|
|
|
|
}
|
|
|
|
|
2006-07-22 09:08:34 +00:00
|
|
|
height = GetBridgeHeight(ti->tile);
|
|
|
|
|
2006-04-04 12:31:29 +00:00
|
|
|
AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
2006-07-22 09:08:34 +00:00
|
|
|
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset
|
|
|
|
);
|
2006-04-04 12:31:29 +00:00
|
|
|
|
|
|
|
/* Finished with wires, draw pylons */
|
|
|
|
/* every other tile needs a pylon on the northern end */
|
2006-03-29 16:30:26 +00:00
|
|
|
if (num % 2) {
|
|
|
|
if (axis == AXIS_X) {
|
2006-07-22 09:08:34 +00:00
|
|
|
AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
|
2006-03-29 16:30:26 +00:00
|
|
|
} else {
|
2006-07-22 09:08:34 +00:00
|
|
|
AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height);
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-04 12:31:29 +00:00
|
|
|
/* need a pylon on the southern end of the bridge */
|
|
|
|
if (DistanceMax(ti->tile, start) == length) {
|
2006-03-29 16:30:26 +00:00
|
|
|
if (axis == AXIS_X) {
|
2006-07-22 09:08:34 +00:00
|
|
|
AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
|
2006-03-29 16:30:26 +00:00
|
|
|
} else {
|
2006-07-22 09:08:34 +00:00
|
|
|
AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height);
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawCatenary(const TileInfo *ti)
|
|
|
|
{
|
|
|
|
switch (GetTileType(ti->tile)) {
|
|
|
|
case MP_RAILWAY:
|
2006-07-27 05:30:53 +00:00
|
|
|
if (IsRailDepot(ti->tile)) {
|
2006-03-29 16:30:26 +00:00
|
|
|
const SortableSpriteStruct *sss = &CatenarySpriteData[WIRE_DEPOT_SW + ReverseDiagDir(GetRailDepotDirection(ti->tile))];
|
|
|
|
AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
|
|
|
sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x, ti->y) + sss->z_offset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-09 15:24:04 +00:00
|
|
|
|
|
|
|
case MP_TUNNELBRIDGE:
|
|
|
|
if (IsBridge(ti->tile) && IsBridgeMiddle(ti->tile) && GetRailTypeOnBridge(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenaryOnBridge(ti);
|
2006-03-29 16:30:26 +00:00
|
|
|
break;
|
2006-06-09 15:24:04 +00:00
|
|
|
|
|
|
|
case MP_STREET: break;
|
|
|
|
case MP_STATION: break;
|
|
|
|
|
|
|
|
default: return;
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|
2006-06-09 15:24:04 +00:00
|
|
|
DrawCatenaryRailway(ti);
|
2006-03-29 16:30:26 +00:00
|
|
|
}
|