OpenTTD Source
20241108-master-g80f628063a
|
This file deals with displaying wires and pylons for electric railways. More...
#include "stdafx.h"
#include "station_map.h"
#include "viewport_func.h"
#include "train.h"
#include "rail_gui.h"
#include "tunnelbridge_map.h"
#include "tunnelbridge.h"
#include "elrail_func.h"
#include "company_base.h"
#include "newgrf_railtype.h"
#include "table/elrail_data.h"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
static TLG | GetTLG (TileIndex t) |
Get the tile location group of a tile. More... | |
static TrackBits | GetRailTrackBitsUniversal (TileIndex t, uint8_t *override) |
Finds which Electrified Rail Bits are present on a given tile. More... | |
static TrackBits | MaskWireBits (TileIndex t, TrackBits tracks) |
Masks out track bits when neighbouring tiles are unelectrified. | |
static SpriteID | GetWireBase (TileIndex tile, TileContext context=TCX_NORMAL) |
Get the base wire sprite to use. | |
static SpriteID | GetPylonBase (TileIndex tile, TileContext context=TCX_NORMAL) |
Get the base pylon sprite to use. | |
static void | AdjustTileh (TileIndex tile, Slope *tileh) |
Corrects the tileh for certain tile types. More... | |
static int | GetPCPElevation (TileIndex tile, DiagDirection PCPpos) |
Returns the Z position of a Pylon Control Point. More... | |
void | DrawRailCatenaryOnTunnel (const TileInfo *ti) |
Draws wires on a tunnel tile. More... | |
static void | DrawRailCatenaryRailway (const TileInfo *ti) |
Draws wires and, if required, pylons on a given tile. More... | |
void | DrawRailCatenaryOnBridge (const TileInfo *ti) |
Draws wires on a tunnel tile. More... | |
void | DrawRailCatenary (const TileInfo *ti) |
Draws overhead wires and pylons for electric railways. More... | |
void | SettingsDisableElrail (int32_t new_value) |
_settings_game.disable_elrail callback | |
void | UpdateDisableElrailSettingState (bool disable, bool update_vehicles) |
This file deals with displaying wires and pylons for electric railways.
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).
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 coordinate.
A Pylon Control Point (PCP) is a position where a wire (or rather two) is mounted onto a pylon. Each NRT does contain 4 PCPs which are bitmapped to a byte variable and are represented by the DiagDirection enum
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.
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 position in question, both tiles get it).
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).
Definition in file elrail.cpp.
Corrects the tileh for certain tile types.
Returns an effective tileh for the track on the tile.
tile | The tile to analyse |
*tileh | the tileh |
Definition at line 199 of file elrail.cpp.
References GetTunnelBridgeDirection(), InclinedSlope(), IsTileType(), IsTunnel(), MP_TUNNELBRIDGE, SLOPE_FLAT, and SLOPE_STEEP.
void DrawRailCatenary | ( | const TileInfo * | ti | ) |
Draws overhead wires and pylons for electric railways.
ti | The TileInfo struct of the tile being drawn |
Definition at line 568 of file elrail.cpp.
References GetTileType(), IsRailDepot(), MP_RAILWAY, and TileInfo::tile.
void DrawRailCatenaryOnBridge | ( | const TileInfo * | ti | ) |
Draws wires on a tunnel tile.
DrawTile_TunnelBridge() calls this function to draw the wires on the bridge.
ti | The Tileinfo to draw the tile for |
Definition at line 506 of file elrail.cpp.
References AXIS_X, GetBridgeAxis(), GetOtherBridgeEnd(), GetSouthernBridgeEnd(), GetTLG(), GetTunnelBridgeLength(), and TileInfo::tile.
void DrawRailCatenaryOnTunnel | ( | const TileInfo * | ti | ) |
Draws wires on a tunnel tile.
DrawTile_TunnelBridge() calls this function to draw the wires as SpriteCombine with the tunnel roof.
ti | The Tileinfo to draw the tile for |
Definition at line 249 of file elrail.cpp.
References GetTunnelBridgeDirection(), GetWireBase(), and TileInfo::tile.
|
static |
Draws wires and, if required, pylons on a given tile.
ti | The Tileinfo to draw the tile for |
Definition at line 278 of file elrail.cpp.
|
static |
Returns the Z position of a Pylon Control Point.
tile | The tile the pylon should stand on. |
PCPpos | The PCP of the tile. |
Definition at line 219 of file elrail.cpp.
References GetSlopePixelZ(), TILE_SIZE, and TileX().
Finds which Electrified Rail Bits are present on a given tile.
t | tile to check |
override | pointer to PCP override, can be nullptr |
Definition at line 86 of file elrail.cpp.
References DiagDirToDiagTrackBits(), GetCrossingRailBits(), GetOtherBridgeEnd(), GetRailStationTrack(), GetRailTileType(), GetRailType(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasRailCatenary(), HasStationRail(), IsLevelCrossing(), IsTunnel(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, RAIL_TILE_NORMAL, RAIL_TILE_SIGNALS, TRACK_BIT_NONE, TrackToTrackBits(), and TRANSPORT_RAIL.
Get the tile location group of a tile.
t | The tile to get the tile location group of. |
Definition at line 75 of file elrail.cpp.
References HasBit(), TileX(), and TileY().
Referenced by DrawRailCatenaryOnBridge().