OpenTTD Source: src/table/elrail_data.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Macros | Enumerations | Variables
elrail_data.h File Reference

Stores all the data for overhead wire and pylon drawing. More...

Go to the source code of this file.

## Data Structures
struct | SortableSpriteStruct

## Macros
#define | NUM_IGNORE_GROUPS 3

## Enumerations
enum | TileLocationGroup : uint8_t { XEVEN_YEVEN = 0 , XEVEN_YODD = 1 , XODD_YEVEN = 2 , XODD_YODD = 3 , TLG_END }
| Tile Location group. More...
enum | TileSource : uint8_t { TS_HOME = 0 , TS_NEIGHBOUR = 1 , TS_END }
| When determining the pylon configuration on the edge, two tiles are taken into account: the tile being drawn itself (the home tile, the one in ti->tile), and the neighbouring tile. More...
enum | PylonSpriteOffset : uint8_t { PSO_Y_NE , PSO_Y_SW , PSO_X_NW , PSO_X_SE , PSO_EW_N , PSO_EW_S , PSO_NS_W , PSO_NS_E }
| Offset for pylon sprites from the base pylon sprite. More...
enum | WireSpriteOffset : uint8_t { WSO_X_SHORT , WSO_Y_SHORT , WSO_EW_SHORT , WSO_NS_SHORT , WSO_X_SHORT_DOWN , WSO_Y_SHORT_UP , WSO_X_SHORT_UP , WSO_Y_SHORT_DOWN , WSO_X_SW , WSO_Y_SE , WSO_EW_E , WSO_NS_S , WSO_X_SW_DOWN , WSO_Y_SE_UP , WSO_X_SW_UP , WSO_Y_SE_DOWN , WSO_X_NE , WSO_Y_NW , WSO_EW_W , WSO_NS_N , WSO_X_NE_DOWN , WSO_Y_NW_UP , WSO_X_NE_UP , WSO_Y_NW_DOWN , WSO_ENTRANCE_SW , WSO_ENTRANCE_NW , WSO_ENTRANCE_NE , WSO_ENTRANCE_SE }
| Offset for wire sprites from the base wire sprite. More...
enum | RailCatenarySprite : uint8_t { WIRE_X_FLAT_SW , WIRE_X_FLAT_NE , WIRE_X_FLAT_BOTH , WIRE_X_UP_SW , WIRE_X_UP_NE , WIRE_X_UP_BOTH , WIRE_X_DOWN_SW , WIRE_X_DOWN_NE , WIRE_X_DOWN_BOTH , WIRE_Y_FLAT_SE , WIRE_Y_FLAT_NW , WIRE_Y_FLAT_BOTH , WIRE_Y_UP_SE , WIRE_Y_UP_NW , WIRE_Y_UP_BOTH , WIRE_Y_DOWN_SE , WIRE_Y_DOWN_NW , WIRE_Y_DOWN_BOTH , WIRE_NS_W_BOTH , WIRE_NS_E_BOTH , WIRE_NS_W_N , WIRE_NS_E_N , WIRE_NS_W_S , WIRE_NS_E_S , WIRE_EW_N_BOTH , WIRE_EW_S_BOTH , WIRE_EW_N_W , WIRE_EW_S_W , WIRE_EW_N_E , WIRE_EW_S_E , INVALID_CATENARY = 0xFF }
| Refers to a certain element of the catenary. More...

## Variables
static const uint | NUM_TRACKS_AT_PCP = 6
static const Directions | _allowed_ppp_on_pcp [DIAGDIR_END]
| Which PPPs are possible at all on a given PCP.
static const Directions | _owned_ppp_on_pcp [DIAGDIR_END]
| Which of the PPPs are inside the tile.
static const DiagDirection | _pcp_positions [TRACK_END][2]
| Maps a track bit onto two PCP positions.
static const Directions | _preferred_ppp_of_track_at_pcp [TRACK_END][DIAGDIR_END]
| Preferred points of each trackbit.
static const Directions | _ignored_pcp [NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END]
| In case we have a straight line, we place pylon only every two tiles, so there are certain tiles which we ignore.
static const Directions | _disallowed_ppp_of_track_at_pcp [TRACK_END][DIAGDIR_END]
| Which pylons can definitely NOT be built.
static const Track | _tracks_at_pcp [DIAGDIR_END][NUM_TRACKS_AT_PCP]
static const TileSource | _track_source_tile [DIAGDIR_END][NUM_TRACKS_AT_PCP]
static const Direction | _ppp_order [DIAGDIR_END][TLG_END][DIR_END]
static const int8_t | _x_pcp_offsets [DIAGDIR_END] = {0, 8, 16, 8}
static const int8_t | _y_pcp_offsets [DIAGDIR_END] = {8, 16, 8, 0}
static const int8_t | _x_ppp_offsets [DIR_END] = {-2, -4, -2, 0, 2, 4, 2, 0}
static const int8_t | _y_ppp_offsets [DIR_END] = {-2, 0, 2, 4, 2, 0, -2, -4}
static const uint8_t | _pylon_sprites []
static const uint | ELRAIL_ELEVATION = 10
| Distance between wire and rail.
static const uint | ELRAIL_ELEVRAISE = ELRAIL_ELEVATION + TILE_HEIGHT + 1
| Wires that a draw one level higher than the north corner.
static const uint | ELRAIL_ELEVLOWER = ELRAIL_ELEVATION - 1
| Wires that a draw one level lower than the north corner.
static const SortableSpriteStruct | _rail_catenary_sprite_data []
static const SortableSpriteStruct | _rail_catenary_sprite_data_depot []
static const int8_t | ELRAIL_TUNNEL_OFFSET = ELRAIL_ELEVATION - BB_Z_SEPARATOR
| In tunnelheads, the bounding box for wires covers nearly the full tile, and is lowered a bit.
static const SortableSpriteStruct | _rail_catenary_sprite_data_tunnel []
static const RailCatenarySprite | _rail_wires [5][TRACK_END][4]

## Detailed Description

Stores all the data for overhead wire and pylon drawing.

See also
  elrail.c

Definition in file elrail_data.h.

## Macro Definition Documentation

## ◆ NUM_IGNORE_GROUPS

#define NUM_IGNORE_GROUPS 3

Definition at line 117 of file elrail_data.h.

## Enumeration Type Documentation

## ◆ PylonSpriteOffset

enum PylonSpriteOffset : uint8_t

Offset for pylon sprites from the base pylon sprite.

Definition at line 256 of file elrail_data.h.

## ◆ RailCatenarySprite

enum RailCatenarySprite : uint8_t

Refers to a certain element of the catenary.

Identifiers for Wires:

1. Direction of the wire
2. Slope of the tile for diagonals, placement inside the track for horiz/vertical pieces
3. Place where a pylon should be

Identifiers for Pylons:

1. Direction of the wire
2. Slope of the tile
3. Position of the Pylon relative to the track
4. Position of the Pylon inside the tile

Definition at line 425 of file elrail_data.h.

## ◆ TileLocationGroup

enum TileLocationGroup : uint8_t

Tile Location group.

This defines whether the X and or Y coordinate of a tile is even

Definition at line 20 of file elrail_data.h.

## ◆ TileSource

enum TileSource : uint8_t

When determining the pylon configuration on the edge, two tiles are taken into account: the tile being drawn itself (the home tile, the one in ti->tile), and the neighbouring tile.

Definition at line 33 of file elrail_data.h.

## ◆ WireSpriteOffset

enum WireSpriteOffset : uint8_t

Offset for wire sprites from the base wire sprite.

Definition at line 282 of file elrail_data.h.

## Variable Documentation

## ◆ _allowed_ppp_on_pcp

const Directions _allowed_ppp_on_pcp[DIAGDIR_END]
| static

Initial value:
= {
{DIR_N, DIR_E, DIR_SE, DIR_S, DIR_W, DIR_NW},
{DIR_N, DIR_NE, DIR_E, DIR_S, DIR_SW, DIR_W},
{DIR_N, DIR_E, DIR_SE, DIR_S, DIR_W, DIR_NW},
{DIR_N, DIR_NE, DIR_E, DIR_S, DIR_SW, DIR_W},
}
DIR_SW
@ DIR_SW
Southwest.
Definition direction_type.h:31
DIR_NW
@ DIR_NW
Northwest.
Definition direction_type.h:33
DIR_N
@ DIR_N
North.
Definition direction_type.h:26
DIR_SE
@ DIR_SE
Southeast.
Definition direction_type.h:29
DIR_S
@ DIR_S
South.
Definition direction_type.h:30
DIR_NE
@ DIR_NE
Northeast.
Definition direction_type.h:27
DIR_W
@ DIR_W
West.
Definition direction_type.h:32
DIR_E
@ DIR_E
East.
Definition direction_type.h:28

Which PPPs are possible at all on a given PCP.

Definition at line 43 of file elrail_data.h.

Referenced by DrawRailCatenaryRailway().

## ◆ _disallowed_ppp_of_track_at_pcp

const Directions _disallowed_ppp_of_track_at_pcp[TRACK_END][DIAGDIR_END]
| static

Initial value:
= {
{{DIR_SW, DIR_NE}, {}, {DIR_SW, DIR_NE}, {} },
{{}, {DIR_NW, DIR_SE}, {}, {DIR_NW, DIR_SE}},
{{DIR_W, DIR_E}, {}, {}, {DIR_W, DIR_E} },
{{}, {DIR_W, DIR_E}, {DIR_W, DIR_E}, {} },
{{}, {}, {DIR_S, DIR_N}, {DIR_N, DIR_S} },
{{DIR_S, DIR_N}, {DIR_S, DIR_N}, {}, {}, },
}

Which pylons can definitely NOT be built.

Definition at line 196 of file elrail_data.h.

Referenced by DrawRailCatenaryRailway().

## ◆ _ignored_pcp

const Directions _ignored_pcp[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END]
| static

In case we have a straight line, we place pylon only every two tiles, so there are certain tiles which we ignore.

A straight line is found if we have exactly two PPPs.

Definition at line 123 of file elrail_data.h.

Referenced by DrawRailCatenaryRailway().

## ◆ _owned_ppp_on_pcp

const Directions _owned_ppp_on_pcp[DIAGDIR_END]
| static

Initial value:
= {
{DIR_SE, DIR_S, DIR_SW, DIR_W},
{DIR_N, DIR_SW, DIR_W, DIR_NW},
{DIR_N, DIR_NE, DIR_E, DIR_NW},
{DIR_NE, DIR_E, DIR_SE, DIR_S},
}

Which of the PPPs are inside the tile.

For the two PPPs on the tile border the following system is used: if you rotate the PCP so that it is in the north, the eastern PPP belongs to the tile.

Definition at line 55 of file elrail_data.h.

Referenced by DrawRailCatenaryRailway().

## ◆ _pcp_positions

const DiagDirection _pcp_positions[TRACK_END][2]
| static

Initial value:
= {
{DIAGDIR_NE, DIAGDIR_SW},
{DIAGDIR_SE, DIAGDIR_NW},
{DIAGDIR_NW, DIAGDIR_NE},
{DIAGDIR_SE, DIAGDIR_SW},
{DIAGDIR_SW, DIAGDIR_NW},
{DIAGDIR_NE, DIAGDIR_SE},
}
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition direction_type.h:80
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition direction_type.h:83
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition direction_type.h:81
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition direction_type.h:82

Maps a track bit onto two PCP positions.

Definition at line 63 of file elrail_data.h.

Referenced by DrawRailCatenaryRailway().

## ◆ _ppp_order

const Direction _ppp_order[DIAGDIR_END][TLG_END][DIR_END]
| static

Initial value:
= {
{
{DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_N, DIR_E, DIR_S, DIR_W},
{DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_S, DIR_W, DIR_N, DIR_E},
{DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_S, DIR_W, DIR_N, DIR_E},
{DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_N, DIR_E, DIR_S, DIR_W},
}, {
{DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_S, DIR_E, DIR_N, DIR_W},
{DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_N, DIR_W, DIR_S, DIR_E},
{DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_N, DIR_W, DIR_S, DIR_E},
{DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_S, DIR_E, DIR_N, DIR_W},
}, {
{DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_S, DIR_W, DIR_N, DIR_E},
{DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_N, DIR_E, DIR_S, DIR_W},
{DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_N, DIR_E, DIR_S, DIR_W},
{DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_S, DIR_W, DIR_N, DIR_E},
}, {
{DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_N, DIR_W, DIR_S, DIR_E},
{DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_S, DIR_E, DIR_N, DIR_W},
{DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_S, DIR_E, DIR_N, DIR_W},
{DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_N, DIR_W, DIR_S, DIR_E},
}
}

Definition at line 223 of file elrail_data.h.

## ◆ _preferred_ppp_of_track_at_pcp

const Directions _preferred_ppp_of_track_at_pcp[TRACK_END][DIAGDIR_END]
| static

Preferred points of each trackbit.

Those are the ones perpendicular to the track, plus the point in extension of the track (to mark end-of-track). PCPs which are not on either end of the track are fully preferred.

See also
  PCPpositions

Definition at line 78 of file elrail_data.h.

Referenced by DrawRailCatenaryRailway().

## ◆ _pylon_sprites

const uint8_t _pylon_sprites[]
| static

Initial value:
= {
PSO_EW_N,
PSO_Y_NE,
PSO_NS_E,
PSO_X_SE,
PSO_EW_S,
PSO_Y_SW,
PSO_NS_W,
PSO_X_NW,
}

Definition at line 268 of file elrail_data.h.

## ◆ _rail_catenary_sprite_data

const SortableSpriteStruct _rail_catenary_sprite_data[]
| static

Definition at line 331 of file elrail_data.h.

## ◆ _rail_catenary_sprite_data_depot

const SortableSpriteStruct _rail_catenary_sprite_data_depot[]
| static

Initial value:
= {
{ WSO_ENTRANCE_NE, 0, 7, 15, 1, 1, ELRAIL_ELEVATION },
{ WSO_ENTRANCE_SE, 7, 0, 1, 15, 1, ELRAIL_ELEVATION },
{ WSO_ENTRANCE_SW, 0, 7, 15, 1, 1, ELRAIL_ELEVATION },
{ WSO_ENTRANCE_NW, 7, 0, 1, 15, 1, ELRAIL_ELEVATION }
}
ELRAIL_ELEVATION
static const uint ELRAIL_ELEVATION
Distance between wire and rail.
Definition elrail_data.h:325

Definition at line 392 of file elrail_data.h.

## ◆ _rail_catenary_sprite_data_tunnel

const SortableSpriteStruct _rail_catenary_sprite_data_tunnel[]
| static

Initial value:
= {
{ WSO_ENTRANCE_SW, {{0, 0, BB_Z_SEPARATOR}, {16, 15, 1}, {0, 7, ELRAIL_TUNNEL_OFFSET}} },
{ WSO_ENTRANCE_NW, {{0, 0, BB_Z_SEPARATOR}, {15, 16, 1}, {7, 0, ELRAIL_TUNNEL_OFFSET}} },
{ WSO_ENTRANCE_NE, {{0, 0, BB_Z_SEPARATOR}, {16, 15, 1}, {0, 7, ELRAIL_TUNNEL_OFFSET}} },
{ WSO_ENTRANCE_SE, {{0, 0, BB_Z_SEPARATOR}, {15, 16, 1}, {7, 0, ELRAIL_TUNNEL_OFFSET}} }
}
ELRAIL_TUNNEL_OFFSET
static const int8_t ELRAIL_TUNNEL_OFFSET
In tunnelheads, the bounding box for wires covers nearly the full tile, and is lowered a bit.
Definition elrail_data.h:403
BB_Z_SEPARATOR
static constexpr int BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
Definition viewport_type.h:93

Definition at line 405 of file elrail_data.h.

## ◆ _rail_wires

const RailCatenarySprite _rail_wires[5][TRACK_END][4]
| static

Definition at line 477 of file elrail_data.h.

## ◆ _track_source_tile

const TileSource _track_source_tile[DIAGDIR_END][NUM_TRACKS_AT_PCP]
| static

Initial value:
= {
{TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME },
{TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME },
{TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_HOME , TS_NEIGHBOUR},
{TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR},
}

Definition at line 215 of file elrail_data.h.

## ◆ _tracks_at_pcp

const Track _tracks_at_pcp[DIAGDIR_END][NUM_TRACKS_AT_PCP]
| static

Initial value:
= {
{TRACK_X, TRACK_X, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
{TRACK_Y, TRACK_Y, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
{TRACK_X, TRACK_X, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
{TRACK_Y, TRACK_Y, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
}
TRACK_Y
@ TRACK_Y
Track along the y-axis (north-west to south-east)
Definition track_type.h:22
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition track_type.h:24
TRACK_LEFT
@ TRACK_LEFT
Track in the left corner of the tile (west)
Definition track_type.h:25
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition track_type.h:26
TRACK_X
@ TRACK_X
Track along the x-axis (north-east to south-west)
Definition track_type.h:21
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition track_type.h:23

Definition at line 206 of file elrail_data.h.

## ◆ _x_pcp_offsets

const int8_t _x_pcp_offsets[DIAGDIR_END] = {0, 8, 16, 8}
| static

Definition at line 247 of file elrail_data.h.

## ◆ _x_ppp_offsets

const int8_t _x_ppp_offsets[DIR_END] = {-2, -4, -2, 0, 2, 4, 2, 0}
| static

Definition at line 250 of file elrail_data.h.

## ◆ _y_pcp_offsets

const int8_t _y_pcp_offsets[DIAGDIR_END] = {8, 16, 8, 0}
| static

Definition at line 248 of file elrail_data.h.

## ◆ _y_ppp_offsets

const int8_t _y_ppp_offsets[DIR_END] = {-2, 0, 2, 4, 2, 0, -2, -4}
| static

Definition at line 251 of file elrail_data.h.

## ◆ ELRAIL_ELEVATION

const uint ELRAIL_ELEVATION = 10
| static

Distance between wire and rail.

Definition at line 325 of file elrail_data.h.

## ◆ ELRAIL_ELEVLOWER

const uint ELRAIL_ELEVLOWER = ELRAIL_ELEVATION - 1
| static

Wires that a draw one level lower than the north corner.

Definition at line 329 of file elrail_data.h.

## ◆ ELRAIL_ELEVRAISE

const uint ELRAIL_ELEVRAISE = ELRAIL_ELEVATION + TILE_HEIGHT + 1
| static

Wires that a draw one level higher than the north corner.

Definition at line 327 of file elrail_data.h.

## ◆ ELRAIL_TUNNEL_OFFSET

const int8_t ELRAIL_TUNNEL_OFFSET = ELRAIL_ELEVATION - BB_Z_SEPARATOR
| static

In tunnelheads, the bounding box for wires covers nearly the full tile, and is lowered a bit.

ELRAIL_TUNNEL_OFFSET is the difference between visual position and bounding box.

Definition at line 403 of file elrail_data.h.

## ◆ NUM_TRACKS_AT_PCP

const uint NUM_TRACKS_AT_PCP = 6
| static

Definition at line 40 of file elrail_data.h.