OpenTTD Source 20260311-master-g511d3794ce
rail_cmd.cpp File Reference

Handling of rail tiles. More...

#include "stdafx.h"
#include "viewport_func.h"
#include "command_func.h"
#include "depot_base.h"
#include "pathfinder/yapf/yapf_cache.h"
#include "newgrf_debug.h"
#include "newgrf_railtype.h"
#include "train.h"
#include "autoslope.h"
#include "water.h"
#include "tunnelbridge_map.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "tunnelbridge.h"
#include "elrail_func.h"
#include "town.h"
#include "pbs.h"
#include "company_base.h"
#include "core/backup_type.hpp"
#include "core/container_func.hpp"
#include "timer/timer_game_calendar.h"
#include "strings_func.h"
#include "company_gui.h"
#include "object_map.h"
#include "rail_cmd.h"
#include "landscape_cmd.h"
#include "table/strings.h"
#include "table/railtypes.h"
#include "table/track_land.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  FenceOffset
 Offsets for drawing fences. More...

Typedefs

typedef std::vector< Train * > TrainList
 Helper type for lists/vectors of trains.

Enumerations

enum  SignalOffsets {
  SIGNAL_TO_SOUTHWEST , SIGNAL_TO_NORTHEAST , SIGNAL_TO_SOUTHEAST , SIGNAL_TO_NORTHWEST ,
  SIGNAL_TO_EAST , SIGNAL_TO_WEST , SIGNAL_TO_SOUTH , SIGNAL_TO_NORTH
}
 Enum holding the signal offset in the sprite sheet according to the side it is representing. More...

Functions

void ResetRailTypes ()
 Reset all rail type information to its default values.
void ResolveRailTypeGUISprites (RailTypeInfo *rti)
static bool CompareRailTypes (const RailType &first, const RailType &second)
 Compare railtypes based on their sorting order.
void InitRailTypes ()
 Resolve sprites of custom rail types.
RailType AllocateRailType (RailTypeLabel label)
 Allocate a new rail type label.
static CommandCost EnsureNoTrainOnTrack (TileIndex tile, Track track)
 Tests if a vehicle interacts with the specified track.
static CommandCost CheckTrackCombination (TileIndex tile, TrackBits to_build)
 Check that the new track bits may be built.
Foundation GetRailFoundation (Slope tileh, TrackBits bits)
 Checks if a track combination is valid on a specific slope and returns the needed foundation.
static CommandCost CheckRailSlope (Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile)
 Tests if a track can be build on a tile.
static bool ValParamTrackOrientation (Track track)
CommandCost CmdBuildSingleRail (DoCommandFlags flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals)
 Build a single piece of rail.
CommandCost CmdRemoveSingleRail (DoCommandFlags flags, TileIndex tile, Track track)
 Remove a single piece of track.
bool FloodHalftile (TileIndex t)
 Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.
static CommandCost ValidateAutoDrag (Trackdir *trackdir, TileIndex start, TileIndex end)
static CommandCost CmdRailTrackHelper (DoCommandFlags flags, TileIndex tile, TileIndex end_tile, RailType railtype, Track track, bool remove, bool auto_remove_signals, bool fail_on_obstacle)
 Build or remove a stretch of railroad tracks.
CommandCost CmdBuildRailroadTrack (DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
 Build rail on a stretch of track.
CommandCost CmdRemoveRailroadTrack (DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, Track track)
 Build rail on a stretch of track.
CommandCost CmdBuildTrainDepot (DoCommandFlags flags, TileIndex tile, RailType railtype, DiagDirection dir)
 Build a train depot.
CommandCost CmdBuildSingleSignal (DoCommandFlags flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, uint8_t signals_copy)
 Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals, and what-else not.
static bool AdvanceSignalAutoFill (TileIndex &tile, Trackdir &trackdir, bool remove)
static CommandCost CmdSignalTrackHelper (DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool remove, bool autofill, bool minimise_gaps, int signal_density)
 Build many signals by dragging; AutoSignals.
CommandCost CmdBuildSignalTrack (DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, uint8_t signal_density)
 Build signals on a stretch of track.
CommandCost CmdRemoveSingleSignal (DoCommandFlags flags, TileIndex tile, Track track)
 Remove signals.
CommandCost CmdRemoveSignalTrack (DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill)
 Remove signals on a stretch of track.
CommandCost CmdConvertRail (DoCommandFlags flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal)
 Convert one rail type to the other.
static CommandCost RemoveTrainDepot (TileIndex tile, DoCommandFlags flags)
static CommandCost ClearTile_Rail (TileIndex tile, DoCommandFlags flags)
 Tile callback function signature for clearing a tile.
static uint GetSafeSlopeZ (uint x, uint y, Track track)
 Get surface height in point (x,y) On tiles with halftile foundations move (x,y) to a safe point wrt.
static void DrawSingleSignal (TileIndex tile, const RailTypeInfo *rti, Track track, SignalState condition, SignalOffsets image, uint pos)
static void DrawTrackFence (const TileInfo *ti, const PalSpriteID &psid, uint num_sprites, RailFenceOffset rfo)
 Draw a track fence.
static void DrawTrackFence_NW (const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
 Draw fence at NW border matching the tile slope.
static void DrawTrackFence_SE (const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
 Draw fence at SE border matching the tile slope.
static void DrawTrackFence_NE (const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
 Draw fence at NE border matching the tile slope.
static void DrawTrackFence_SW (const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
 Draw fence at SW border matching the tile slope.
static void DrawTrackDetails (const TileInfo *ti, const RailTypeInfo *rti, PaletteID pal)
 Draw track fences.
static void DrawTrackSprite (SpriteID sprite, PaletteID pal, const TileInfo *ti, Slope s)
static void DrawTrackBitsOverlay (TileInfo *ti, TrackBits track, const RailTypeInfo *rti)
static int GetJunctionGroundSpriteOffset (TrackBits track)
 Returns which of the 5 junction-'Rail underlays' to use for the given track bits.
static void DrawTrackBits (TileInfo *ti, TrackBits track)
 Draw ground sprite and track bits.
static void DrawSignals (TileIndex tile, TrackBits rails, const RailTypeInfo *rti)
static void DrawTile_Rail (TileInfo *ti)
 Tile callback function signature for drawing a tile and its contents to the screen.
void DrawTrainDepotSprite (int x, int y, int dir, RailType railtype)
static int GetSlopePixelZ_Rail (TileIndex tile, uint x, uint y, bool ground_vehicle)
 Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.
static Foundation GetFoundation_Rail (TileIndex tile, Slope tileh)
 Tile callback function signature for getting the foundation of a tile.
static void TileLoop_Rail (TileIndex tile)
 Tile callback function signature for running periodic tile updates.
static TrackStatus GetTileTrackStatus_Rail (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 Tile callback function signature for getting the possible tracks that can be taken on a given tile by a given transport.
static bool ClickTile_Rail (TileIndex tile)
 Tile callback function signature for clicking a tile.
static void GetTileDesc_Rail (TileIndex tile, TileDesc &td)
 Tile callback function signature for obtaining a tile description.
static void ChangeTileOwner_Rail (TileIndex tile, Owner old_owner, Owner new_owner)
 Tile callback function signature for changing the owner of a tile.
int TicksToLeaveDepot (const Train *v)
 Compute number of ticks when next wagon will leave a depot.
static VehicleEnterTileStates VehicleEnterTile_Rail (Vehicle *v, TileIndex tile, int x, int y)
 Tile callback function for a vehicle entering a tile.
static CommandCost TestAutoslopeOnRailTile (TileIndex tile, DoCommandFlags flags, int z_old, Slope tileh_old, int z_new, Slope tileh_new, TrackBits rail_bits)
 Tests if autoslope is allowed.
static CommandCost TerraformTile_Rail (TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
 Tile callback function signature of the terraforming callback.
static CommandCost CheckBuildAbove_Rail (TileIndex tile, DoCommandFlags flags, Axis axis, int height)
 Tile callback function signature to test if a bridge can be built above a tile.

Variables

RailTypeInfo _railtypes [RAILTYPE_END]
std::vector< RailType_sorted_railtypes
 Sorted list of rail types.
RailTypes _railtypes_hidden_mask
static const uint8_t _track_sloped_sprites [14]
static const TrackBits _valid_tracks_without_foundation [15]
 Valid TrackBits on a specific (non-steep)-slope without foundation.
static const TrackBits _valid_tracks_on_leveled_foundation [15]
 Valid TrackBits on a specific (non-steep)-slope with leveled foundation.
static const TileIndexDiffC _trackdelta []
static const FenceOffset _fence_offsets []
 Offsets for drawing fences.
static const int INF = 1000
 Big number compared to tilesprite size.
static const SubSprite _halftile_sub_sprite [4]
static const uint8_t _fractcoords_behind [4] = { 0x8F, 0x8, 0x80, 0xF8 }
static const uint8_t _fractcoords_enter [4] = { 0x8A, 0x48, 0x84, 0xA8 }
static const int8_t _deltacoord_leaveoffset [8]
const TileTypeProcs _tile_type_rail_procs
 TileTypeProcs definitions for TileType::Rail tiles.

Detailed Description

Handling of rail tiles.

Definition in file rail_cmd.cpp.

Typedef Documentation

◆ TrainList

typedef std::vector<Train *> TrainList

Helper type for lists/vectors of trains.

Definition at line 44 of file rail_cmd.cpp.

Enumeration Type Documentation

◆ SignalOffsets

Enum holding the signal offset in the sprite sheet according to the side it is representing.

Definition at line 51 of file rail_cmd.cpp.

Function Documentation

◆ AdvanceSignalAutoFill()

bool AdvanceSignalAutoFill ( TileIndex & tile,
Trackdir & trackdir,
bool remove )
static

Definition at line 1193 of file rail_cmd.cpp.

◆ AllocateRailType()

RailType AllocateRailType ( RailTypeLabel label)

Allocate a new rail type label.

Parameters
labelThe label of the rail type.
Returns
The allocated type, or INVALID_RAILTYPE upon failures.

Definition at line 150 of file rail_cmd.cpp.

References _original_railtypes, RailTypeInfo::alternate_labels, RailTypeInfo::compatible_railtypes, RailTypeInfo::Index(), RailTypeInfo::introduces_railtypes, INVALID_RAILTYPE, RailTypeInfo::label, RailTypeInfo::powered_railtypes, RAILTYPE_RAIL, and RailTypeInfo::sorting_order.

◆ ChangeTileOwner_Rail()

void ChangeTileOwner_Rail ( TileIndex tile,
Owner old_owner,
Owner new_owner )
static

Tile callback function signature for changing the owner of a tile.

Parameters
tileThe tile to process.
old_ownerThe owner to replace.
new_ownerThe owner to replace with.
See also
ChangeTileOwner

Definition at line 2909 of file rail_cmd.cpp.

References Bankrupt, CountBits(), Execute, GetPresentSignals(), GetRailType(), GetTrackBits(), HasSignals(), INVALID_OWNER, IsPlainRail(), IsTileOwner(), SetTileOwner(), and TracksOverlap().

◆ CheckBuildAbove_Rail()

CommandCost CheckBuildAbove_Rail ( TileIndex tile,
DoCommandFlags flags,
Axis axis,
int height )
static

Tile callback function signature to test if a bridge can be built above a tile.

Parameters
tileThe involved tile.
flagsCommand flags passed to the build command.
axisAxis of bridge being built.
heightAbsolute height of bridge platform.
Returns
Error code or extra cost for building bridge above the tile.
See also
CheckBuildAbove

Definition at line 3115 of file rail_cmd.cpp.

References IsPlainRail().

◆ CheckRailSlope()

CommandCost CheckRailSlope ( Slope tileh,
TrackBits rail_bits,
TrackBits existing,
TileIndex tile )
static

Tests if a track can be build on a tile.

Parameters
tilehTile slope.
rail_bitsTracks to build.
existingTracks already built.
tileTile (used for water test)
Returns
Error message or cost for foundation building.

Definition at line 391 of file rail_cmd.cpp.

References _price, _settings_game, _valid_tracks_on_leveled_foundation, BuildFoundation, EXPENSES_CONSTRUCTION, FLOOD_NONE, FOUNDATION_INVALID, FOUNDATION_NONE, GetFloodingBehaviour(), GetRailFoundation(), and IsSteepSlope().

Referenced by CmdBuildSingleRail(), and TestAutoslopeOnRailTile().

◆ CheckTrackCombination()

CommandCost CheckTrackCombination ( TileIndex tile,
TrackBits to_build )
static

Check that the new track bits may be built.

Parameters
tileTile to build on.
to_buildNew track bits.
Returns
Succeeded or failed command.

Definition at line 240 of file rail_cmd.cpp.

References GetTrackBits(), and IsPlainRail().

Referenced by CmdBuildSingleRail().

◆ ClearTile_Rail()

CommandCost ClearTile_Rail ( TileIndex tile,
DoCommandFlags flags )
static

◆ ClickTile_Rail()

bool ClickTile_Rail ( TileIndex tile)
static

Tile callback function signature for clicking a tile.

Parameters
tileThe tile that was clicked.
Returns
Whether any action was taken.
See also
ClickTile

Definition at line 2806 of file rail_cmd.cpp.

References IsRailDepot(), ShowDepotWindow(), and VEH_TRAIN.

◆ CmdBuildRailroadTrack()

CommandCost CmdBuildRailroadTrack ( DoCommandFlags flags,
TileIndex end_tile,
TileIndex start_tile,
RailType railtype,
Track track,
bool auto_remove_signals,
bool fail_on_obstacle )

Build rail on a stretch of track.

Stub for the unified rail builder/remover

Parameters
flagsoperation to perform
end_tileend tile of drag
start_tilestart tile of drag
railtyperailroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
tracktrack-orientation
auto_remove_signalsfalse = build up to an obstacle, true = fail if an obstacle is found (used for AIs).
fail_on_obstaclefalse = error on signal in the way, true = auto remove signals when in the way
Returns
The cost of this operation or an error.
See also
CmdRailTrackHelper

Definition at line 932 of file rail_cmd.cpp.

References CmdRailTrackHelper().

◆ CmdBuildSignalTrack()

CommandCost CmdBuildSignalTrack ( DoCommandFlags flags,
TileIndex tile,
TileIndex end_tile,
Track track,
SignalType sigtype,
SignalVariant sigvar,
bool mode,
bool autofill,
bool minimise_gaps,
uint8_t signal_density )

Build signals on a stretch of track.

Stub for the unified signal builder/remover

Parameters
flagsoperation to perform
tilestart tile of drag
end_tileend tile of drag
tracktrack-orientation
sigtypedefault signal type
sigvarsignal variant to build
modetrue = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
autofillfill beyond selected stretch?
minimise_gapsfalse = keep fixed distance, true = minimise gaps between signals
signal_densityuser defined signals_density
Returns
the cost of this operation or an error
See also
CmdSignalTrackHelper

Definition at line 1443 of file rail_cmd.cpp.

References CmdSignalTrackHelper().

◆ CmdBuildSingleRail()

CommandCost CmdBuildSingleRail ( DoCommandFlags flags,
TileIndex tile,
RailType railtype,
Track track,
bool auto_remove_signals )

Build a single piece of rail.

Parameters
flagsoperation to perform
tiletile to build on
railtyperailtype of being built piece (normal, mono, maglev)
tracktrack-orientation
auto_remove_signalsfalse = error on signal in the way, true = auto remove signals when in the way
Returns
the cost of this operation or an error

Definition at line 425 of file rail_cmd.cpp.

References _current_company, _price, _settings_game, CommandCost::AddCost(), AddTrackToSignalBuffer(), AXIS_X, AXIS_Y, Barren, CheckForDockingTile(), CheckOwnership(), CheckRailSlope(), CheckTileOwnership(), CheckTrackCombination(), ClearRough, ClearWater, CMD_ERROR, CountBits(), DirtyCompanyInfrastructureWindows(), DRD_NONE, EnsureNoTrainOnTrack(), EnsureNoVehicleOnGround(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetCost(), GetCrossingRailBits(), GetCrossingRoadAxis(), GetDisallowedRoadDirections(), GetRailType(), GetRoadBits(), GetRoadOwner(), GetRoadTypeRoad(), GetRoadTypeTram(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), HalfTileWater, HasBit(), HasExactlyOneBit(), HasPowerOnRail(), HasRoadWorks(), HasSignalOnTrack(), HasSignals(), HasTrack(), INVALID_ROADTYPE, IsCompatibleRail(), IsLevelCrossing(), IsNormalRoad(), IsPlainRail(), IsPossibleDockingTile(), IsSlopeWithOneCornerRaised(), IsTileType(), LEVELCROSSING_TRACKBIT_FACTOR, MakeRailNormal(), MakeRoadCrossing(), MarkDirtyAdjacentLevelCrossingTiles(), MarkTileDirtyByTile(), OWNER_DEITY, RailBuildCost(), RailNoLevelCrossings(), Railway, Road, ROAD_NONE, ROAD_X, ROAD_Y, RoadBuildCost(), RoadNoLevelCrossing(), RTT_ROAD, RTT_TRAM, SetRailGroundType(), SetTrackBits(), CommandCost::Succeeded(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TRACK_BEGIN, TRACK_BIT_NONE, TRACK_END, TRACK_X, TRACK_Y, TracksOverlap(), TrackToTrackBits(), UpdateLevelCrossing(), VALID_LEVEL_CROSSING_SLOPES, ValParamRailType(), Water, and YapfNotifyTrackLayoutChange().

◆ CmdBuildSingleSignal()

CommandCost CmdBuildSingleSignal ( DoCommandFlags flags,
TileIndex tile,
Track track,
SignalType sigtype,
SignalVariant sigvar,
bool convert_signal,
bool skip_existing_signals,
bool ctrl_pressed,
SignalType cycle_start,
SignalType cycle_stop,
uint8_t num_dir_cycle,
uint8_t signals_copy )

Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals, and what-else not.

If the rail piece does not have any signals, signal cycling is ignored

Parameters
flagsoperation to perform
tiletile where to build the signals
tracktrack-orientation
sigtypetype of the signal
sigvarvariant of signal type (normal/semaphore)
ctrl_pressedtrue = override signal/semaphore, or pre/exit/combo signal or toggle variant (CTRL-toggle)
convert_signalconvert the present signal type and variant
cycle_startstart cycle from this signal type
cycle_stopwrap around after this signal type
num_dir_cyclecycle the signal direction this many times
skip_existing_signalstrue = don't modify an existing signal but don't fail either, false = always set new signal type
signals_copyused for CmdBuildManySignals() to copy direction of first signal
Returns
the cost of this operation or an error

Definition at line 1046 of file rail_cmd.cpp.

References _current_company, _price, _settings_game, AddTrackToSignalBuffer(), BuildSignals, CheckTileOwnership(), ClearSignals, CMD_ERROR, CountBits(), Vehicle::cur_speed, Vehicle::current_order, CycleSignalSide(), DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), FreeTrainTrackReservation(), GetPresentSignals(), GetRailReservationTrackBits(), GetSignalStates(), GetSignalType(), GetSignalVariant(), GetTileOwner(), GetTrackBits(), GetTrainForReservation(), Train::GetVehicleTrackdir(), HasBit(), HasReservedTracks(), HasSignalOnTrack(), HasSignals(), HasTrack(), IsPbsSignal(), IsPlainRailTile(), IsSafeWaitingPosition(), Order::IsType(), KillFirstBit(), MarkTileDirtyByTile(), SetHasSignals(), SetPresentSignals(), SetSignalStates(), SetSignalType(), SetSignalVariant(), SIG_ELECTRIC, SIG_SEMAPHORE, SignalOnTrack(), Stopped, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, Train::track, TRACK_BIT_DEPOT, TracksOverlap(), TrackToTrackBits(), TryPathReserve(), Vehicle::vehstatus, and YapfNotifyTrackLayoutChange().

◆ CmdBuildTrainDepot()

◆ CmdConvertRail()

CommandCost CmdConvertRail ( DoCommandFlags flags,
TileIndex tile,
TileIndex area_start,
RailType totype,
bool diagonal )

Convert one rail type to the other.

You can convert normal rail to monorail/maglev easily or vice-versa.

Parameters
flagsoperation to perform
tileend tile of rail conversion drag
area_startstart tile of drag
totypenew railtype to convert to.
diagonalbuild diagonally or not.
Returns
the cost of this operation or an error

Definition at line 1536 of file rail_cmd.cpp.

References _settings_game, CommandCost::AddCost(), CCF_TRACK, CheckTileOwnership(), CMD_ERROR, CountBits(), TileIterator::Create(), Depot, DiagDirToDiagTrack(), DirtyCompanyInfrastructureWindows(), EnsureNoTrainOnTrackBits(), EnsureNoVehicleOnGround(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), FreeTrainTrackReservation(), SpecializedVehicle< Train, Type >::From(), GetCrossingRailTrack(), GetOtherTunnelBridgeEnd(), GetRailDepotTrack(), GetRailStationTrack(), GetRailTileType(), GetRailType(), GetReservedTrackbits(), GetTileOwner(), GetTileType(), GetTrackBits(), GetTrainForReservation(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasPowerOnRail(), HasStationRail(), HasTunnelBridgeReservation(), include(), Company::infrastructure, INVALID_TILE, INVALID_TRACK, InvalidateWindowData(), IsBridge(), IsCompatibleRail(), IsLevelCrossing(), IsLevelCrossingTile(), IsPlainRailTile(), IsRailStationTile(), IsStationTileBlocked(), LEVELCROSSING_TRACKBIT_FACTOR, CommandCost::MakeError(), MarkBridgeDirty(), MarkTileDirtyByTile(), CompanyInfrastructure::rail, RailConvertCost(), RailNoLevelCrossings(), RAILTYPE_ELECTRIC, RAILTYPE_RAIL, Train::railtypes, Railway, RemoveFirstTrack(), Road, SetRailType(), Map::Size(), Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TRACK_BIT_NONE, TracksOverlap(), TRANSPORT_RAIL, TryPathReserve(), TunnelBridge, TUNNELBRIDGE_TRACKBIT_FACTOR, TunnelBridgeIsFree(), ValParamRailType(), VEH_TRAIN, WC_BUILD_VEHICLE, WC_VEHICLE_DEPOT, and YapfNotifyTrackLayoutChange().

◆ CmdRailTrackHelper()

CommandCost CmdRailTrackHelper ( DoCommandFlags flags,
TileIndex tile,
TileIndex end_tile,
RailType railtype,
Track track,
bool remove,
bool auto_remove_signals,
bool fail_on_obstacle )
static

Build or remove a stretch of railroad tracks.

Parameters
flagsoperation to perform
tilestart tile of drag
end_tileend tile of drag
railtyperailroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
tracktrack-orientation
removeremove tracks?
auto_remove_signalsfalse = error on signal in the way, true = auto remove signals when in the way, only used for building
fail_on_obstaclefalse = build starting from and up to an obstacle, true = fail if an obstacle is found (used for AIs)
Returns
the cost of this operation or an error

Definition at line 875 of file rail_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), IsDiagonalTrackdir(), Map::Size(), ToggleBit(), ToTileIndexDiff(), TrackdirToTrack(), TrackToTrackdir(), and ValParamRailType().

Referenced by CmdBuildRailroadTrack(), and CmdRemoveRailroadTrack().

◆ CmdRemoveRailroadTrack()

CommandCost CmdRemoveRailroadTrack ( DoCommandFlags flags,
TileIndex end_tile,
TileIndex start_tile,
Track track )

Build rail on a stretch of track.

Stub for the unified rail builder/remover

Parameters
flagsoperation to perform
end_tileend tile of drag
start_tilestart tile of drag
tracktrack-orientation
Returns
the cost of this operation or an error
See also
CmdRailTrackHelper

Definition at line 947 of file rail_cmd.cpp.

References CmdRailTrackHelper(), and INVALID_RAILTYPE.

◆ CmdRemoveSignalTrack()

CommandCost CmdRemoveSignalTrack ( DoCommandFlags flags,
TileIndex tile,
TileIndex end_tile,
Track track,
bool autofill )

Remove signals on a stretch of track.

Stub for the unified signal builder/remover

Parameters
flagsoperation to perform
tilestart tile of drag
end_tileend tile of drag
tracktrack-orientation
autofillfill beyond selected stretch?
Returns
the cost of this operation or an error
See also
CmdSignalTrackHelper

Definition at line 1521 of file rail_cmd.cpp.

References CmdSignalTrackHelper(), SIG_ELECTRIC, and SIGTYPE_BLOCK.

◆ CmdRemoveSingleRail()

CommandCost CmdRemoveSingleRail ( DoCommandFlags flags,
TileIndex tile,
Track track )

◆ CmdRemoveSingleSignal()

◆ CmdSignalTrackHelper()

CommandCost CmdSignalTrackHelper ( DoCommandFlags flags,
TileIndex tile,
TileIndex end_tile,
Track track,
SignalType sigtype,
SignalVariant sigvar,
bool mode,
bool remove,
bool autofill,
bool minimise_gaps,
int signal_density )
static

Build many signals by dragging; AutoSignals.

Parameters
flagsoperation to perform
tilestart tile of drag
end_tileend tile of drag
tracktrack-orientation
sigtypedefault signal type
sigvarsignal variant to build
modetrue = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
removeremove signals?
autofillfill beyond selected stretch?
minimise_gapsfalse = keep fixed distance, true = minimise gaps between signals
signal_densityuser defined signals_density
Returns
the cost of this operation or an error

Definition at line 1252 of file rail_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), GetOtherTunnelBridgeEnd(), GetPresentSignals(), GetSignalType(), GetSignalVariant(), GetTileType(), GetTunnelBridgeLength(), HasBit(), HasSignalOnTrack(), HasTrack(), INVALID_STRING_ID, INVALID_TILE, INVALID_TRACKDIR, IsDiagonalTrackdir(), IsPbsSignal(), IsPlainRailTile(), Railway, Road, SetBit(), SIG_SEMAPHORE, SignalAgainstTrackdir(), SignalAlongTrackdir(), SignalOnTrack(), SIGTYPE_BLOCK, SIGTYPE_ENTRY, SIGTYPE_EXIT, Map::Size(), CommandCost::Succeeded(), TILE_AXIAL_DISTANCE, TILE_CORNER_DISTANCE, ToggleBit(), ToTileIndexDiff(), TrackdirToTrack(), TrackToTrackdir(), and TunnelBridge.

Referenced by CmdBuildSignalTrack(), and CmdRemoveSignalTrack().

◆ CompareRailTypes()

bool CompareRailTypes ( const RailType & first,
const RailType & second )
static

Compare railtypes based on their sorting order.

Parameters
firstThe railtype to compare to.
secondThe railtype to compare.
Returns
True iff the first should be sorted before the second.

Definition at line 122 of file rail_cmd.cpp.

References GetRailTypeInfo(), and RailTypeInfo::sorting_order.

Referenced by InitRailTypes().

◆ DrawSignals()

void DrawSignals ( TileIndex tile,
TrackBits rails,
const RailTypeInfo * rti )
static

Definition at line 2405 of file rail_cmd.cpp.

◆ DrawSingleSignal()

void DrawSingleSignal ( TileIndex tile,
const RailTypeInfo * rti,
Track track,
SignalState condition,
SignalOffsets image,
uint pos )
static

Definition at line 1867 of file rail_cmd.cpp.

◆ DrawTile_Rail()

◆ DrawTrackBits()

◆ DrawTrackBitsOverlay()

void DrawTrackBitsOverlay ( TileInfo * ti,
TrackBits track,
const RailTypeInfo * rti )
static

Definition at line 2074 of file rail_cmd.cpp.

◆ DrawTrackDetails()

◆ DrawTrackFence()

void DrawTrackFence ( const TileInfo * ti,
const PalSpriteID & psid,
uint num_sprites,
RailFenceOffset rfo )
static

Draw a track fence.

Parameters
tiTile drawing information.
psidFirst fence sprite and palette.
num_spritesNumber of fence sprites.
rfoFence to draw.

Definition at line 1942 of file rail_cmd.cpp.

References _fence_offsets, AddSortableSpriteToDraw(), GetSlopePixelZInCorner(), PalSpriteID::pal, RemoveHalftileSlope(), PalSpriteID::sprite, TileInfo::tileh, Coord3D< T >::x, Coord3D< T >::y, and Coord3D< T >::z.

Referenced by DrawTrackDetails(), DrawTrackFence_NE(), DrawTrackFence_NW(), DrawTrackFence_SE(), and DrawTrackFence_SW().

◆ DrawTrackFence_NE()

void DrawTrackFence_NE ( const TileInfo * ti,
const PalSpriteID & psid,
uint num_sprites )
static

Draw fence at NE border matching the tile slope.

Parameters
tiTile drawing information.
psidFirst fence sprite and palette.
num_spritesNumber of fence sprites.

Definition at line 1983 of file rail_cmd.cpp.

References DrawTrackFence(), RFO_FLAT_Y_NE, RFO_SLOPE_NW_NE, RFO_SLOPE_SE_NE, SLOPE_E, SLOPE_NE, and TileInfo::tileh.

Referenced by DrawTrackDetails().

◆ DrawTrackFence_NW()

void DrawTrackFence_NW ( const TileInfo * ti,
const PalSpriteID & psid,
uint num_sprites )
static

Draw fence at NW border matching the tile slope.

Parameters
tiTile drawing information.
psidFirst fence sprite and palette.
num_spritesNumber of fence sprites.

Definition at line 1957 of file rail_cmd.cpp.

References DrawTrackFence(), RFO_FLAT_X_NW, RFO_SLOPE_NE_NW, RFO_SLOPE_SW_NW, SLOPE_NW, SLOPE_W, and TileInfo::tileh.

Referenced by DrawTrackDetails().

◆ DrawTrackFence_SE()

void DrawTrackFence_SE ( const TileInfo * ti,
const PalSpriteID & psid,
uint num_sprites )
static

Draw fence at SE border matching the tile slope.

Parameters
tiTile drawing information.
psidFirst fence sprite and palette.
num_spritesNumber of fence sprites.

Definition at line 1970 of file rail_cmd.cpp.

References DrawTrackFence(), RFO_FLAT_X_SE, RFO_SLOPE_NE_SE, RFO_SLOPE_SW_SE, SLOPE_S, SLOPE_SE, and TileInfo::tileh.

Referenced by DrawTrackDetails().

◆ DrawTrackFence_SW()

void DrawTrackFence_SW ( const TileInfo * ti,
const PalSpriteID & psid,
uint num_sprites )
static

Draw fence at SW border matching the tile slope.

Parameters
tiTile drawing information.
psidFirst fence sprite and palette.
num_spritesNumber of fence sprites.

Definition at line 1996 of file rail_cmd.cpp.

References DrawTrackFence(), RFO_FLAT_Y_SW, RFO_SLOPE_NW_SW, RFO_SLOPE_SE_SW, SLOPE_S, SLOPE_SW, and TileInfo::tileh.

Referenced by DrawTrackDetails().

◆ DrawTrackSprite()

void DrawTrackSprite ( SpriteID sprite,
PaletteID pal,
const TileInfo * ti,
Slope s )
inlinestatic

Definition at line 2069 of file rail_cmd.cpp.

◆ DrawTrainDepotSprite()

void DrawTrainDepotSprite ( int x,
int y,
int dir,
RailType railtype )

Definition at line 2568 of file rail_cmd.cpp.

◆ EnsureNoTrainOnTrack()

CommandCost EnsureNoTrainOnTrack ( TileIndex tile,
Track track )
static

Tests if a vehicle interacts with the specified track.

All track bits interact except parallel TRACK_BIT_HORZ or TRACK_BIT_VERT.

Parameters
tileThe tile.
trackThe track.
Returns
Succeeded command (no train found), or a failed command (a train was found).

Definition at line 228 of file rail_cmd.cpp.

References EnsureNoTrainOnTrackBits(), and TrackToTrackBits().

Referenced by CmdBuildSingleRail(), and CmdRemoveSingleRail().

◆ FloodHalftile()

bool FloodHalftile ( TileIndex t)

Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.

The function floods the lower halftile, if the tile has a halftile foundation.

Parameters
tThe tile to flood.
Returns
true if something was flooded.

Definition at line 761 of file rail_cmd.cpp.

References _current_company, ApplyFoundationToSlope(), CornerToTrackBits(), Execute, FindFirstTrack(), GetHighestSlopeCorner(), GetRailFoundation(), GetRailGroundType(), GetTileSlope(), GetTrackBits(), HalfTileWater, IsNonContinuousFoundation(), IsPlainRailTile(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), MakeShore(), MarkTileDirtyByTile(), OppositeCorner(), OWNER_WATER, Backup< T >::Restore(), SetRailGroundType(), and TRACK_BIT_NONE.

Referenced by DoFloodTile().

◆ GetFoundation_Rail()

Foundation GetFoundation_Rail ( TileIndex tile,
Slope tileh )
static

Tile callback function signature for getting the foundation of a tile.

Parameters
tileThe tile to check.
tilehThe current slope.
Returns
The foundation that will be used.

Definition at line 2610 of file rail_cmd.cpp.

References FlatteningFoundation(), GetRailFoundation(), GetTrackBits(), and IsPlainRail().

◆ GetJunctionGroundSpriteOffset()

int GetJunctionGroundSpriteOffset ( TrackBits track)
static

Returns which of the 5 junction-'Rail underlays' to use for the given track bits.

See https://newgrf-specs.tt-wiki.net/wiki/Action3/Railtypes for the cases.

Precondition
The track bits describe a junction, so at least two bits are set.
Parameters
trackThe track bits to consider.
Returns
The offset in the five junction ground sprites.

Definition at line 2241 of file rail_cmd.cpp.

References TRACK_BIT_3WAY_NE, TRACK_BIT_3WAY_NW, TRACK_BIT_3WAY_SE, and TRACK_BIT_3WAY_SW.

Referenced by DrawTrackBits().

◆ GetRailFoundation()

◆ GetSafeSlopeZ()

uint GetSafeSlopeZ ( uint x,
uint y,
Track track )
static

Get surface height in point (x,y) On tiles with halftile foundations move (x,y) to a safe point wrt.

track

Parameters
xThe world X-coordinate.
yThe world Y-coordinate.
trackThe track to get the height for.
Returns
The world Z-coordinate.

Definition at line 1855 of file rail_cmd.cpp.

References GetSlopePixelZ(), TRACK_LEFT, TRACK_LOWER, TRACK_RIGHT, and TRACK_UPPER.

◆ GetSlopePixelZ_Rail()

int GetSlopePixelZ_Rail ( TileIndex tile,
uint x,
uint y,
bool ground_vehicle )
static

Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.

Parameters
tileThe queries tile for the Z coordinate.
xWorld X coordinate in tile "units".
yWorld Y coordinate in tile "units".
ground_vehicleWhether to get the Z coordinate of the ground vehicle, or the ground.
Returns
World Z coordinate at tile ground (vehicle) level, including slopes and foundations.
See also
GetSlopePixelZ

Definition at line 2596 of file rail_cmd.cpp.

References ApplyPixelFoundationToSlope(), GetPartialPixelZ(), GetRailFoundation(), GetTileMaxPixelZ(), GetTilePixelSlope(), GetTrackBits(), IsPlainRail(), and SLOPE_FLAT.

◆ GetTileDesc_Rail()

void GetTileDesc_Rail ( TileIndex tile,
TileDesc & td )
static

Tile callback function signature for obtaining a tile description.

Parameters
tileTile being queried
tdStorage pointer for returned tile description
See also
GetTileDesc

Definition at line 2815 of file rail_cmd.cpp.

References _settings_game, TileDesc::build_date, Depot, GetRailTileType(), GetRailType(), GetRailTypeInfo(), GetSignalType(), GetTileOwner(), HasSignalOnTrack(), RailTypeInfo::max_speed, RailTypeInfo::name, Normal, TileDesc::owner, TileDesc::rail_speed, TileDesc::railtype, Signals, TileDesc::str, RailTypeInfo::strings, TRACK_LOWER, and TRACK_UPPER.

◆ GetTileTrackStatus_Rail()

TrackStatus GetTileTrackStatus_Rail ( TileIndex tile,
TransportType mode,
uint sub_mode,
DiagDirection side )
static

Tile callback function signature for getting the possible tracks that can be taken on a given tile by a given transport.

The return value contains the existing trackdirs and signal states.

see track_func.h for usage of TrackStatus.

Parameters
tilethe tile to get the track status from
modethe mode of transportation
sub_modeused to differentiate between different kinds within the mode
sideThe side where the tile is entered.
Returns
the track status information
See also
GetTileTrackStatus

Definition at line 2743 of file rail_cmd.cpp.

References CombineTrackStatus(), Depot, DiagDirToDiagTrackBits(), GetPresentSignals(), GetRailDepotDirection(), GetRailGroundType(), GetRailTileType(), GetSignalStates(), GetTileSlope(), GetTrackBits(), HalfTileWater, INVALID_DIAGDIR, IsOnewaySignal(), IsPlainRail(), IsSlopeWithOneCornerRaised(), Normal, SignalOnTrack(), Signals, TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_NONE, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, TRACK_LOWER, TRACK_UPPER, TrackBitsToTrackdirBits(), TRACKDIR_BIT_LEFT_N, TRACKDIR_BIT_LEFT_S, TRACKDIR_BIT_LOWER_E, TRACKDIR_BIT_LOWER_W, TRACKDIR_BIT_NONE, TRACKDIR_BIT_RIGHT_N, TRACKDIR_BIT_RIGHT_S, TRACKDIR_BIT_UPPER_E, TRACKDIR_BIT_UPPER_W, TRACKDIR_BIT_X_NE, TRACKDIR_BIT_X_SW, TRACKDIR_BIT_Y_NW, TRACKDIR_BIT_Y_SE, TRANSPORT_RAIL, and TRANSPORT_WATER.

◆ InitRailTypes()

void InitRailTypes ( )

◆ RemoveTrainDepot()

CommandCost RemoveTrainDepot ( TileIndex tile,
DoCommandFlags flags )
static

Definition at line 1757 of file rail_cmd.cpp.

◆ ResetRailTypes()

void ResetRailTypes ( )

Reset all rail type information to its default values.

Definition at line 65 of file rail_cmd.cpp.

References _original_railtypes.

Referenced by ResetNewGRFData().

◆ ResolveRailTypeGUISprites()

void ResolveRailTypeGUISprites ( RailTypeInfo * rti)

Definition at line 75 of file rail_cmd.cpp.

◆ TerraformTile_Rail()

CommandCost TerraformTile_Rail ( TileIndex tile,
DoCommandFlags flags,
int z_new,
Slope tileh_new )
static

Tile callback function signature of the terraforming callback.

The function is called when a tile is affected by a terraforming operation. It has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype. With DoCommandFlag::Execute in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).

Note
The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.
Parameters
tileThe involved tile.
flagsCommand flags passed to the terraform command (DoCommandFlag::Execute, DoCommandFlag::QueryCost, etc.).
z_newTileZ after terraforming.
tileh_newSlope after terraforming.
Returns
Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
See also
TerraformTile

Definition at line 3065 of file rail_cmd.cpp.

References _price, _settings_game, AutoslopeCheckForEntranceEdge(), AutoslopeEnabled(), Barren, BuildFoundation, ClearWater, Execute, EXPENSES_CONSTRUCTION, GetRailDepotDirection(), GetRailFoundation(), GetRailGroundType(), GetSlopeZInCorner(), GetTileSlopeZ(), GetTrackBits(), HalfTileWater, HasVehicleOnTile(), IsPlainRail(), IsSlopeWithOneCornerRaised(), IsSpecialRailFoundation(), SetRailGroundType(), SLOPE_EW, SLOPE_NS, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TestAutoslopeOnRailTile(), TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, BaseVehicle::type, and VEH_SHIP.

◆ TestAutoslopeOnRailTile()

CommandCost TestAutoslopeOnRailTile ( TileIndex tile,
DoCommandFlags flags,
int z_old,
Slope tileh_old,
int z_new,
Slope tileh_new,
TrackBits rail_bits )
static

Tests if autoslope is allowed.

Parameters
tileThe tile.
flagsTerraform command flags.
z_oldOld TileZ.
tileh_oldOld TileSlope.
z_newNew TileZ.
tileh_newNew TileSlope.
rail_bitsTrackbits.
Returns
The cost of this operation or an error.

Definition at line 3025 of file rail_cmd.cpp.

References _price, _settings_game, CommandCost::AddCost(), ApplyFoundationToSlope(), AutoslopeEnabled(), Barren, BuildFoundation, CheckRailSlope(), ClearWater, Execute, EXPENSES_CONSTRUCTION, GetRailFoundation(), GetRailGroundType(), GetSlopeZInCorner(), HalfTileWater, IsSlopeWithOneCornerRaised(), RemoveHalftileSlope(), SetRailGroundType(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_NONE, TRACK_BIT_RIGHT, and TRACK_BIT_UPPER.

Referenced by TerraformTile_Rail().

◆ TicksToLeaveDepot()

int TicksToLeaveDepot ( const Train * v)

Compute number of ticks when next wagon will leave a depot.

Negative means next wagon should have left depot n ticks before.

Parameters
vvehicle outside (leaving) the depot
Returns
number of ticks when the next wagon will leave

Definition at line 2951 of file rail_cmd.cpp.

References Train::CalcNextVehicleOffset(), DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, GetRailDepotDirection(), Vehicle::tile, Vehicle::x_pos, and Vehicle::y_pos.

Referenced by AdvanceWagonsAfterSwap(), CheckTrainsLengths(), and FixupTrainLengths().

◆ TileLoop_Rail()

◆ ValidateAutoDrag()

CommandCost ValidateAutoDrag ( Trackdir * trackdir,
TileIndex start,
TileIndex end )
static

Definition at line 816 of file rail_cmd.cpp.

◆ ValParamTrackOrientation()

bool ValParamTrackOrientation ( Track track)
inlinestatic

Definition at line 411 of file rail_cmd.cpp.

◆ VehicleEnterTile_Rail()

VehicleEnterTileStates VehicleEnterTile_Rail ( Vehicle * v,
TileIndex tile,
int x,
int y )
static

Variable Documentation

◆ _deltacoord_leaveoffset

const int8_t _deltacoord_leaveoffset[8]
static
Initial value:
= {
-1, 0, 1, 0,
0, 1, 0, -1
}

Definition at line 2939 of file rail_cmd.cpp.

◆ _fence_offsets

const FenceOffset _fence_offsets[]
static
Initial value:
= {
{ CORNER_INVALID, 0, 1, 16, 1 },
{ CORNER_INVALID, 1, 0, 1, 16 },
{ CORNER_W, 8, 8, 1, 1 },
{ CORNER_N, 8, 8, 1, 1 },
{ CORNER_INVALID, 0, 1, 16, 1 },
{ CORNER_INVALID, 1, 0, 1, 16 },
{ CORNER_INVALID, 0, 1, 16, 1 },
{ CORNER_INVALID, 1, 0, 1, 16 },
{ CORNER_INVALID, 0, 15, 16, 1 },
{ CORNER_INVALID, 15, 0, 1, 16 },
{ CORNER_E, 8, 8, 1, 1 },
{ CORNER_S, 8, 8, 1, 1 },
{ CORNER_INVALID, 0, 15, 16, 1 },
{ CORNER_INVALID, 15, 0, 1, 16 },
{ CORNER_INVALID, 0, 15, 16, 1 },
{ CORNER_INVALID, 15, 0, 1, 16 },
}

Offsets for drawing fences.

Definition at line 1916 of file rail_cmd.cpp.

Referenced by DrawTrackFence().

◆ _fractcoords_behind

const uint8_t _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 }
static

Definition at line 2937 of file rail_cmd.cpp.

◆ _fractcoords_enter

const uint8_t _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 }
static

Definition at line 2938 of file rail_cmd.cpp.

◆ _halftile_sub_sprite

const SubSprite _halftile_sub_sprite[4]
static
Initial value:
= {
{ -INF , -INF , 32 - 33, INF },
{ -INF , 0 + 7, INF , INF },
{ -31 + 33, -INF , INF , INF },
{ -INF , -INF , INF , 30 - 23 }
}
static const int INF
Big number compared to tilesprite size.

Definition at line 2062 of file rail_cmd.cpp.

◆ _railtypes

Definition at line 46 of file rail_cmd.cpp.

◆ _railtypes_hidden_mask

RailTypes _railtypes_hidden_mask

Definition at line 48 of file rail_cmd.cpp.

◆ _sorted_railtypes

◆ _tile_type_rail_procs

const TileTypeProcs _tile_type_rail_procs
extern
Initial value:
= {
.draw_tile_proc = DrawTile_Rail,
.get_slope_pixel_z_proc = GetSlopePixelZ_Rail,
.clear_tile_proc = ClearTile_Rail,
.get_tile_desc_proc = GetTileDesc_Rail,
.get_tile_track_status_proc = GetTileTrackStatus_Rail,
.click_tile_proc = ClickTile_Rail,
.tile_loop_proc = TileLoop_Rail,
.change_tile_owner_proc = ChangeTileOwner_Rail,
.vehicle_enter_tile_proc = VehicleEnterTile_Rail,
.get_foundation_proc = GetFoundation_Rail,
.terraform_tile_proc = TerraformTile_Rail,
.check_build_above_proc = CheckBuildAbove_Rail,
}
static void DrawTile_Rail(TileInfo *ti)
Tile callback function signature for drawing a tile and its contents to the screen.
static CommandCost ClearTile_Rail(TileIndex tile, DoCommandFlags flags)
Tile callback function signature for clearing a tile.
static int GetSlopePixelZ_Rail(TileIndex tile, uint x, uint y, bool ground_vehicle)
Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.
static VehicleEnterTileStates VehicleEnterTile_Rail(Vehicle *v, TileIndex tile, int x, int y)
Tile callback function for a vehicle entering a tile.
static void ChangeTileOwner_Rail(TileIndex tile, Owner old_owner, Owner new_owner)
Tile callback function signature for changing the owner of a tile.
static bool ClickTile_Rail(TileIndex tile)
Tile callback function signature for clicking a tile.
static void GetTileDesc_Rail(TileIndex tile, TileDesc &td)
Tile callback function signature for obtaining a tile description.
static TrackStatus GetTileTrackStatus_Rail(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Tile callback function signature for getting the possible tracks that can be taken on a given tile by...
static Foundation GetFoundation_Rail(TileIndex tile, Slope tileh)
Tile callback function signature for getting the foundation of a tile.
static CommandCost CheckBuildAbove_Rail(TileIndex tile, DoCommandFlags flags, Axis axis, int height)
Tile callback function signature to test if a bridge can be built above a tile.
static void TileLoop_Rail(TileIndex tile)
Tile callback function signature for running periodic tile updates.
static CommandCost TerraformTile_Rail(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
Tile callback function signature of the terraforming callback.

TileTypeProcs definitions for TileType::Rail tiles.

Definition at line 53 of file landscape.cpp.

◆ _track_sloped_sprites

const uint8_t _track_sloped_sprites[14]
static
Initial value:
= {
14, 15, 22, 13,
0, 21, 17, 12,
23, 0, 18, 20,
19, 16
}

Definition at line 181 of file rail_cmd.cpp.

◆ _trackdelta

const TileIndexDiffC _trackdelta[]
static
Initial value:
= {
{ -1, 0 }, { 0, 1 }, { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, 1 },
{ 0, 0 },
{ 0, 0 },
{ 1, 0 }, { 0, -1 }, { 0, -1 }, { 1, 0 }, { 0, -1 }, { -1, 0 },
{ 0, 0 },
{ 0, 0 }
}

Definition at line 806 of file rail_cmd.cpp.

◆ _valid_tracks_on_leveled_foundation

const TrackBits _valid_tracks_on_leveled_foundation[15]
static
Initial value:
= {
}
@ TRACK_BIT_UPPER
Upper track.
Definition track_type.h:39
@ TRACK_BIT_LEFT
Left track.
Definition track_type.h:41
@ TRACK_BIT_Y
Y-axis track.
Definition track_type.h:38
@ TRACK_BIT_NONE
No track.
Definition track_type.h:36
@ TRACK_BIT_X
X-axis track.
Definition track_type.h:37
@ TRACK_BIT_LOWER
Lower track.
Definition track_type.h:40
@ TRACK_BIT_ALL
All possible tracks.
Definition track_type.h:50
@ TRACK_BIT_RIGHT
Right track.
Definition track_type.h:42

Valid TrackBits on a specific (non-steep)-slope with leveled foundation.

Definition at line 283 of file rail_cmd.cpp.

Referenced by CheckRailSlope(), and GetRailFoundation().

◆ _valid_tracks_without_foundation

const TrackBits _valid_tracks_without_foundation[15]
static

◆ INF

const int INF = 1000
static

Big number compared to tilesprite size.

Definition at line 2061 of file rail_cmd.cpp.

Referenced by DrawBridgePillars(), and DrawRoadTypeCatenary().