|
@@ -63,12 +63,14 @@
|
|
|
#include "table/sprites.h"
|
|
|
#include "table/elrail_data.h"
|
|
|
#include "vehicle.h"
|
|
|
#include "train.h"
|
|
|
#include "gui.h"
|
|
|
#include "transparency.h"
|
|
|
#include "tunnelbridge_map.h"
|
|
|
|
|
|
|
|
|
static inline TLG GetTLG(TileIndex t)
|
|
|
{
|
|
|
return (TLG)((HasBit(TileX(t), 0) << 1) + HasBit(TileY(t), 0));
|
|
|
}
|
|
|
|
|
@@ -90,20 +92,20 @@ static TrackBits GetRailTrackBitsUnivers
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case MP_TUNNELBRIDGE:
|
|
|
if (IsTunnel(t)) {
|
|
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
|
|
|
if (override != NULL) *override = 1 << GetTunnelDirection(t);
|
|
|
return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t)));
|
|
|
if (override != NULL) *override = 1 << GetTunnelBridgeDirection(t);
|
|
|
return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
|
|
|
} else {
|
|
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
|
|
|
if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) {
|
|
|
*override = 1 << GetBridgeRampDirection(t);
|
|
|
*override = 1 << GetTunnelBridgeDirection(t);
|
|
|
}
|
|
|
return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t)));
|
|
|
return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
|
|
|
}
|
|
|
|
|
|
case MP_ROAD:
|
|
|
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE;
|
|
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
|
|
|
return GetCrossingRailBits(t);
|
|
@@ -128,13 +130,13 @@ static void AdjustTileh(TileIndex tile,
|
|
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
|
|
if (IsTunnel(tile)) {
|
|
|
*tileh = SLOPE_STEEP; // XXX - Hack to make tunnel entrances to always have a pylon
|
|
|
} else if (*tileh != SLOPE_FLAT) {
|
|
|
*tileh = SLOPE_FLAT;
|
|
|
} else {
|
|
|
switch (GetBridgeRampDirection(tile)) {
|
|
|
switch (GetTunnelBridgeDirection(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: NOT_REACHED();
|
|
|
}
|
|
@@ -185,13 +187,13 @@ void DrawCatenaryOnTunnel(const TileInfo
|
|
|
{ 0, 1, 16, 15 }, // SW
|
|
|
{ 1, 0, 15, 16 }, // NW
|
|
|
};
|
|
|
|
|
|
if ((GetRailType(ti->tile) != RAILTYPE_ELECTRIC) || _patches.disable_elrails) return;
|
|
|
|
|
|
DiagDirection dir = GetTunnelDirection(ti->tile);
|
|
|
DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
|
|
|
|
|
|
const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir];
|
|
|
const int *BB_data = _tunnel_wire_BB[dir];
|
|
|
AddSortableSpriteToDraw(
|
|
|
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
|
|
BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1,
|
|
@@ -244,13 +246,13 @@ static void DrawCatenaryRailway(const Ti
|
|
|
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);
|
|
|
if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
|
|
|
if (IsTunnelTile(neighbour) && i != GetTunnelBridgeDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
|
|
|
|
|
|
/* If the neighboured tile does not smoothly connect to the current tile (because of a foundation),
|
|
|
* we have to draw all pillars on the current tile. */
|
|
|
if (GetPCPElevation(ti->tile, i) != GetPCPElevation(neighbour, ReverseDiagDir(i))) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
|
|
|
|
|
|
isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0);
|
|
@@ -261,13 +263,13 @@ static void DrawCatenaryRailway(const Ti
|
|
|
/* We cycle through all the existing tracks at a PCP and see what
|
|
|
* PPPs we want to have, or may not have at all */
|
|
|
for (k = 0; k < NUM_TRACKS_AT_PCP; k++) {
|
|
|
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */
|
|
|
if (TrackSourceTile[i][k] == TS_NEIGHBOUR &&
|
|
|
IsBridgeTile(neighbour) &&
|
|
|
GetBridgeRampDirection(neighbour) == ReverseDiagDir(i)) {
|
|
|
GetTunnelBridgeDirection(neighbour) == ReverseDiagDir(i)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
/* We check whether the track in question (k) is present in the tile
|
|
|
* (TrackSourceTile) */
|
|
|
if (HasBit(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) {
|
|
@@ -288,13 +290,13 @@ static void DrawCatenaryRailway(const Ti
|
|
|
/* A station is always "flat", so adjust the tileh accordingly */
|
|
|
if (IsTileType(neighbour, MP_STATION)) tileh[TS_NEIGHBOUR] = SLOPE_FLAT;
|
|
|
|
|
|
/* Read the foundataions if they are present, and adjust the tileh */
|
|
|
if (trackconfig[TS_NEIGHBOUR] != TRACK_BIT_NONE && IsTileType(neighbour, MP_RAILWAY) && GetRailType(neighbour) == RAILTYPE_ELECTRIC) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]);
|
|
|
if (IsBridgeTile(neighbour)) {
|
|
|
foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour)));
|
|
|
foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetTunnelBridgeDirection(neighbour)));
|
|
|
}
|
|
|
|
|
|
ApplyFoundationToSlope(foundation, &tileh[TS_NEIGHBOUR]);
|
|
|
|
|
|
/* Half tile slopes coincide only with horizontal/vertical track.
|
|
|
* Faking a flat slope results in the correct sprites on positions. */
|
|
@@ -440,13 +442,13 @@ void DrawCatenary(const TileInfo *ti)
|
|
|
{
|
|
|
if (_patches.disable_elrails) return;
|
|
|
|
|
|
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) {
|
|
|
TileIndex head = GetNorthernBridgeEnd(ti->tile);
|
|
|
|
|
|
if (GetBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) {
|
|
|
if (GetTunnelBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) {
|
|
|
DrawCatenaryOnBridge(ti);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
switch (GetTileType(ti->tile)) {
|
|
|
case MP_RAILWAY:
|