|
OpenTTD Source 20260621-master-g720d10536d
|
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 Trackdir | GetOtherTrackdir (Trackdir trackdir) |
| Get the other Trackdir for a non-diagonal Trackdir. | |
| 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 bool | IsTrainSignalSideRight () |
| Helper to determine whether the train signals are to be placed on the right side. | |
| 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, DiagDirection dir, RailType railtype) |
| Draw train depot sprite in the UI. | |
| 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, RoadTramType 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 TrackdirIndexArray< TileIndexDiffC > | _trackdelta |
| Tile deltas for each trackdir. | |
| static const FenceOffset | _fence_offsets [] |
| Offsets for drawing fences. | |
| static const int | INF = 1000 |
| Big number compared to tilesprite size. | |
| static constexpr CornerIndexArray< SubSprite > | _halftile_sub_sprite |
| SubSprite for drawing the track halftile of 'three-corners-raised'-sloped rail sprites. | |
| static constexpr DiagDirectionIndexArray< Coord2D< uint8_t > > | _fractcoords_behind |
| Coordinates to detect when a train is approaching a depot from behind for each depot direction. | |
| static constexpr DiagDirectionIndexArray< Coord2D< uint8_t > > | _fractcoords_enter |
| Coordinates where a train should enter a depot for each depot direction. | |
| static constexpr DiagDirectionIndexArray< Coord2D< int8_t > > | _deltacoord_leaveoffset |
| Offsets (to be multiplied by length) from the depot enter coordinates where a train should appear when exiting a depot for each depot direction. | |
| const TileTypeProcs | _tile_type_rail_procs |
| TileTypeProcs definitions for TileType::Rail tiles. | |
Handling of rail tiles.
Definition in file rail_cmd.cpp.
Helper type for lists/vectors of trains.
Definition at line 44 of file rail_cmd.cpp.
| enum 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.
Definition at line 1203 of file rail_cmd.cpp.
| RailType AllocateRailType | ( | RailTypeLabel | label | ) |
Allocate a new rail type label.
| label | The label of the rail type. |
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.
|
static |
Tile callback function signature for changing the owner of a tile.
| tile | The tile to process. |
| old_owner | The owner to replace. |
| new_owner | The owner to replace with. |
Definition at line 2938 of file rail_cmd.cpp.
References Bankrupt, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Count(), CountBits(), Execute, GetPresentSignals(), GetRailType(), GetTrackBits(), HasSignals(), INVALID_OWNER, IsPlainRail(), IsTileOwner(), SetTileOwner(), and TracksOverlap().
|
static |
Tile callback function signature to test if a bridge can be built above a tile.
| tile | The involved tile. |
| flags | Command flags passed to the build command. |
| axis | Axis of bridge being built. |
| height | Absolute height of bridge platform. |
Definition at line 3175 of file rail_cmd.cpp.
References IsPlainRail().
|
static |
Tests if a track can be build on a tile.
| tileh | Tile slope. |
| rail_bits | Tracks to build. |
| existing | Tracks already built. |
| tile | Tile (used for water test) |
Definition at line 390 of file rail_cmd.cpp.
References _price, _settings_game, _valid_tracks_on_leveled_foundation, Any, BuildFoundation, Construction, GetFloodingBehaviour(), GetRailFoundation(), Invalid, IsSteepSlope(), and None.
Referenced by CmdBuildSingleRail(), and TestAutoslopeOnRailTile().
|
static |
Check that the new track bits may be built.
| tile | Tile to build on. |
| to_build | New track bits. |
Definition at line 239 of file rail_cmd.cpp.
References GetTrackBits(), and IsPlainRail().
Referenced by CmdBuildSingleRail().
|
static |
Tile callback function signature for clearing a tile.
| tile | The tile to clear. |
| flags | The command flags. |
Definition at line 1799 of file rail_cmd.cpp.
References _current_company, _price, CommandCost::AddCost(), Auto, Bankrupt, ClearWater, CMD_ERROR, Construction, Depot, EnsureNoVehicleOnGround(), Execute, CommandCost::Failed(), CommandCost::GetCost(), GetRailGroundType(), GetRailTileType(), GetTileSlope(), GetTrackBits(), HalfTileWater, IsPlainRail(), IsSlopeWithOneCornerRaised(), IsTileOwner(), Normal, Signals, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
|
static |
Tile callback function signature for clicking a tile.
| tile | The tile that was clicked. |
Definition at line 2835 of file rail_cmd.cpp.
References IsRailDepot(), ShowDepotWindow(), and Train.
| 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
| flags | operation to perform |
| end_tile | end tile of drag |
| start_tile | start tile of drag |
| railtype | railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building |
| track | track-orientation |
| auto_remove_signals | false = build up to an obstacle, true = fail if an obstacle is found (used for AIs). |
| fail_on_obstacle | false = error on signal in the way, true = auto remove signals when in the way |
Definition at line 941 of file rail_cmd.cpp.
References CmdRailTrackHelper().
| 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
| flags | operation to perform |
| tile | start tile of drag |
| end_tile | end tile of drag |
| track | track-orientation |
| sigtype | default signal type |
| sigvar | signal variant to build |
| mode | true = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
| autofill | fill beyond selected stretch? |
| minimise_gaps | false = keep fixed distance, true = minimise gaps between signals |
| signal_density | user defined signals_density |
Definition at line 1453 of file rail_cmd.cpp.
References CmdSignalTrackHelper().
| CommandCost CmdBuildSingleRail | ( | DoCommandFlags | flags, |
| TileIndex | tile, | ||
| RailType | railtype, | ||
| Track | track, | ||
| bool | auto_remove_signals ) |
Build a single piece of rail.
| flags | operation to perform |
| tile | tile to build on |
| railtype | railtype of being built piece (normal, mono, maglev) |
| track | track-orientation |
| auto_remove_signals | false = error on signal in the way, true = auto remove signals when in the way |
Definition at line 424 of file rail_cmd.cpp.
References _current_company, _price, _settings_game, CommandCost::AddCost(), AddTrackToSignalBuffer(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Any, Barren, CheckForDockingTile(), CheckOwnership(), CheckRailSlope(), CheckTileOwnership(), CheckTrackCombination(), ClearRough, ClearWater, CMD_ERROR, Construction, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Count(), Count, DirtyCompanyInfrastructureWindows(), EnsureNoTrainOnTrack(), EnsureNoVehicleOnGround(), Execute, CommandCost::Failed(), CommandCost::GetCost(), GetCrossingRailTrack(), GetCrossingRoadAxis(), GetDisallowedRoadDirections(), GetRailType(), GetRoadBits(), GetRoadOwner(), GetRoadTypeRoad(), GetRoadTypeTram(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), HalfTileWater, HasBit(), HasPowerOnRail(), HasRoadWorks(), HasSignalOnTrack(), HasSignals(), INVALID_ROADTYPE, IsCompatibleRail(), IsLevelCrossing(), IsNormalRoad(), IsPlainRail(), IsPossibleDockingTile(), IsSlopeWithOneCornerRaised(), IsTileType(), LEVELCROSSING_TRACKBIT_FACTOR, MakeRailNormal(), MakeRoadCrossing(), MarkDirtyAdjacentLevelCrossingTiles(), MarkTileDirtyByTile(), OWNER_DEITY, RailBuildCost(), RailNoLevelCrossings(), Railway, Road, ROAD_X, ROAD_Y, RoadBuildCost(), RoadNoLevelCrossing(), SetRailGroundType(), SetTrackBits(), CommandCost::Succeeded(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TracksOverlap(), Tram, UpdateLevelCrossing(), VALID_LEVEL_CROSSING_SLOPES, ValParamRailType(), Water, X, Y, and YapfNotifyTrackLayoutChange().
| 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
| flags | operation to perform |
| tile | tile where to build the signals |
| track | track-orientation |
| sigtype | type of the signal |
| sigvar | variant of signal type (normal/semaphore) |
| ctrl_pressed | true = override signal/semaphore, or pre/exit/combo signal or toggle variant (CTRL-toggle) |
| convert_signal | convert the present signal type and variant |
| cycle_start | start cycle from this signal type |
| cycle_stop | wrap around after this signal type |
| num_dir_cycle | cycle the signal direction this many times |
| skip_existing_signals | true = don't modify an existing signal but don't fail either, false = always set new signal type |
| signals_copy | used for CmdBuildManySignals() to copy direction of first signal |
Definition at line 1055 of file rail_cmd.cpp.
References _current_company, _price, _settings_game, AddTrackToSignalBuffer(), BuildSignals, CheckTileOwnership(), ClearSignals, CMD_ERROR, Construction, CountBits(), Vehicle::cur_speed, Vehicle::current_order, CycleSignalSide(), Depot, DirtyCompanyInfrastructureWindows(), Electric, End, EnsureNoVehicleOnGround(), Execute, CommandCost::Failed(), FreeTrainTrackReservation(), SpecializedVehicle< T, Type >::GetMovingFront(), GetPresentSignals(), GetRailReservationTrackBits(), GetSignalStates(), GetSignalType(), GetSignalVariant(), GetTileOwner(), GetTrackBits(), GetTrainForReservation(), Train::GetVehicleTrackdir(), HasReservedTracks(), HasSignalOnTrack(), HasSignals(), HasTrack(), IsPbsSignal(), IsPlainRailTile(), IsSafeWaitingPosition(), Order::IsType(), KillFirstBit(), MarkTileDirtyByTile(), Semaphore, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SetSignalType(), SetSignalVariant(), SignalOnTrack(), Stopped, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, to_underlying(), Train::track, TracksOverlap(), TryPathReserve(), Vehicle::vehstatus, and YapfNotifyTrackLayoutChange().
| CommandCost CmdBuildTrainDepot | ( | DoCommandFlags | flags, |
| TileIndex | tile, | ||
| RailType | railtype, | ||
| DiagDirection | dir ) |
Build a train depot.
| flags | operation to perform |
| tile | position of the train depot |
| railtype | rail type |
| dir | entrance direction |
Definition at line 969 of file rail_cmd.cpp.
References _current_company, _price, _settings_game, CommandCost::AddCost(), AddSideToSignalBuffer(), BuildDepotTrain, BuildFoundation, CanBuildDepotByTileh(), CheckTileOwnership(), CMD_ERROR, Construction, DiagDirToDiagTrack(), DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), Execute, CommandCost::Failed(), GetRailDepotDirection(), GetRailType(), GetTileSlope(), Invalid, IsBridgeAbove(), IsRailDepotTile(), IsValidDiagDirection(), MakeDefaultName(), MakeRailDepot(), MarkTileDirtyByTile(), RailBuildCost(), SetRailDepotExitDirection(), SLOPE_FLAT, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), ValParamRailType(), and YapfNotifyTrackLayoutChange().
| 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.
| flags | operation to perform |
| tile | end tile of rail conversion drag |
| area_start | start tile of drag |
| totype | new railtype to convert to. |
| diagonal | build diagonally or not. |
Definition at line 1546 of file rail_cmd.cpp.
References _settings_game, CommandCost::AddCost(), CCF_TRACK, CheckTileOwnership(), CMD_ERROR, Construction, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Count(), Count, TileIterator::Create(), Depot, DiagDirToDiagTrack(), DirtyCompanyInfrastructureWindows(), EnsureNoTrainOnTrackBits(), EnsureNoVehicleOnGround(), Execute, 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, 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, Road, SetRailType(), Map::Size(), Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TracksOverlap(), Train, TRANSPORT_RAIL, TryPathReserve(), TunnelBridge, TUNNELBRIDGE_TRACKBIT_FACTOR, TunnelBridgeIsFree(), ValParamRailType(), and YapfNotifyTrackLayoutChange().
|
static |
Build or remove a stretch of railroad tracks.
| flags | operation to perform |
| tile | start tile of drag |
| end_tile | end tile of drag |
| railtype | railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building |
| track | track-orientation |
| remove | remove tracks? |
| auto_remove_signals | false = error on signal in the way, true = auto remove signals when in the way, only used for building |
| fail_on_obstacle | false = build starting from and up to an obstacle, true = fail if an obstacle is found (used for AIs) |
Definition at line 884 of file rail_cmd.cpp.
References _trackdelta, CommandCost::AddCost(), CMD_ERROR, Construction, CommandCost::Failed(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), GetOtherTrackdir(), IsDiagonalTrackdir(), Map::Size(), ToTileIndexDiff(), TrackdirToTrack(), TrackToTrackdir(), and ValParamRailType().
Referenced by CmdBuildRailroadTrack(), and 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
| flags | operation to perform |
| end_tile | end tile of drag |
| start_tile | start tile of drag |
| track | track-orientation |
Definition at line 956 of file rail_cmd.cpp.
References CmdRailTrackHelper(), and INVALID_RAILTYPE.
| 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
| flags | operation to perform |
| tile | start tile of drag |
| end_tile | end tile of drag |
| track | track-orientation |
| autofill | fill beyond selected stretch? |
Definition at line 1531 of file rail_cmd.cpp.
References Block, CmdSignalTrackHelper(), and Electric.
| CommandCost CmdRemoveSingleRail | ( | DoCommandFlags | flags, |
| TileIndex | tile, | ||
| Track | track ) |
Remove a single piece of track.
| flags | operation to perform |
| tile | tile to remove track from |
| track | rail orientation |
Definition at line 613 of file rail_cmd.cpp.
References _current_company, CommandCost::AddCost(), AddTrackToSignalBuffer(), Bankrupt, CheckTileOwnership(), CMD_ERROR, Construction, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Count(), DeleteNewGRFInspectWindow(), DirtyCompanyInfrastructureWindows(), EnsureNoTrainOnTrack(), EnsureNoVehicleOnGround(), Execute, CommandCost::Failed(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Flip(), FreeTrainTrackReservation(), GetCrossingRailTrack(), GetCrossingRoadAxis(), GetCrossingRoadBits(), GetRailGroundType(), GetRailReservationTrackBits(), GetRailType(), GetRoadOwner(), GetRoadTypeRoad(), GetRoadTypeTram(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), GetTrainForReservation(), HalfTileWater, HasReservedTracks(), HasSignalOnTrack(), INVALID_OWNER, IsDockingTile(), IsLevelCrossing(), IsPlainRail(), IsSlopeWithOneCornerRaised(), LEVELCROSSING_TRACKBIT_FACTOR, MakeRoadNormal(), MakeShore(), MarkTileDirtyByTile(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), OWNER_WATER, RailClearCost(), RailTypes, Railway, Road, SetDockingTile(), SetTrackBits(), SetTrackReservation(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TRACK_BIT_CROSS, TracksOverlap(), Tram, TryPathReserve(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), X, Y, and YapfNotifyTrackLayoutChange().
| CommandCost CmdRemoveSingleSignal | ( | DoCommandFlags | flags, |
| TileIndex | tile, | ||
| Track | track ) |
Remove signals.
| flags | operation to perform |
| tile | coordinates where signal is being deleted from |
| track | track-orientation |
Definition at line 1465 of file rail_cmd.cpp.
References _current_company, _price, AddTrackToSignalBuffer(), CheckTileOwnership(), ClearSignals, Construction, CountBits(), DirtyCompanyInfrastructureWindows(), Electric, Execute, CommandCost::Failed(), GetPresentSignals(), GetReservedTrackbits(), GetSignalType(), GetTileOwner(), GetTrainForReservation(), HasReservedTracks(), HasSignalOnTrack(), HasSignalOnTrackdir(), HasTrack(), Invalid, IsPbsSignal(), IsPlainRailTile(), MarkTileDirtyByTile(), OWNER_WATER, ReverseTrackdir(), SetHasSignals(), SetPresentSignals(), SetSignalStates(), SetSignalVariant(), SignalOnTrack(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileAddByDiagDir(), TrackBitsToTrack(), TrackdirBitsToTrackBits(), TrackdirReachesTrackdirs(), TrackdirToExitdir(), TrackToTrackdir(), TryPathReserve(), and YapfNotifyTrackLayoutChange().
|
static |
Build many signals by dragging; AutoSignals.
| flags | operation to perform |
| tile | start tile of drag |
| end_tile | end tile of drag |
| track | track-orientation |
| sigtype | default signal type |
| sigvar | signal variant to build |
| mode | true = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
| remove | remove signals? |
| autofill | fill beyond selected stretch? |
| minimise_gaps | false = keep fixed distance, true = minimise gaps between signals |
| signal_density | user defined signals_density |
Definition at line 1262 of file rail_cmd.cpp.
References _trackdelta, CommandCost::AddCost(), Block, CMD_ERROR, Construction, End, Entry, Execute, Exit, CommandCost::Failed(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), GetOtherTrackdir(), GetOtherTunnelBridgeEnd(), GetPresentSignals(), GetSignalType(), GetSignalVariant(), GetTileType(), GetTunnelBridgeLength(), HasBit(), HasSignalOnTrack(), HasTrack(), Invalid, INVALID_STRING_ID, INVALID_TILE, IsDiagonalTrackdir(), IsPbsSignal(), IsPlainRailTile(), Railway, Road, SetBit(), SignalAgainstTrackdir(), SignalAlongTrackdir(), SignalOnTrack(), Map::Size(), CommandCost::Succeeded(), TILE_AXIAL_DISTANCE, TILE_CORNER_DISTANCE, ToTileIndexDiff(), TrackdirToTrack(), TrackToTrackdir(), and TunnelBridge.
Referenced by CmdBuildSignalTrack(), and CmdRemoveSignalTrack().
Compare railtypes based on their sorting order.
| first | The railtype to compare to. |
| second | The railtype to compare. |
Definition at line 122 of file rail_cmd.cpp.
References GetRailTypeInfo(), and RailTypeInfo::sorting_order.
Referenced by InitRailTypes().
|
static |
Definition at line 2427 of file rail_cmd.cpp.
|
static |
Definition at line 1890 of file rail_cmd.cpp.
|
static |
Tile callback function signature for drawing a tile and its contents to the screen.
| ti | Information about the tile to draw |
Definition at line 2462 of file rail_cmd.cpp.
References _depot_gfx_table, _depot_invisible_gfx_table, _display_opt, _settings_client, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), RailTypeInfo::base_sprites, Buildings, Depot, DrawBridgeMiddle(), DrawFoundation(), DrawGroundSprite(), DrawRailCatenary(), DrawRailTileSeq(), DrawTrackBits(), DrawTrackDetails(), EdgeNE, EdgeNW, EdgeSE, EdgeSW, FullDetail, GetCompanyPalette(), GetCustomRailSprite(), GetRailDepotDirection(), GetRailType(), GetRailTypeInfo(), RailTypeInfo::GetRailtypeSpriteOffset(), GetTileOwner(), GetTrackBits(), Ground, DrawTileSprites::ground, GroundSpritePaletteTransform(), HasDepotReservation(), HasRailCatenaryDrawn(), HasSignals(), IsBridgeAbove(), IsInvisibilitySet(), IsPlainRail(), IsSnowOrDesertRailGround(), Leveled, Menu, NE, NW, Overlay, PALETTE_CRASH, RTO_X, RTO_Y, SE, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), RailTypeInfo::single_x, RailTypeInfo::single_y, SLOPE_FLAT, RailTypeInfo::snow_offset, PalSpriteID::sprite, SW, TileInfo::tile, TileInfo::tileh, TRACK_BIT_3WAY_NE, TRACK_BIT_3WAY_NW, TRACK_BIT_3WAY_SE, and TRACK_BIT_3WAY_SW.
Draw ground sprite and track bits.
Definition at line 2280 of file rail_cmd.cpp.
References _halftile_sub_sprite, _settings_client, Barren, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), RailTypeInfo::base_sprites, ComplementSlope(), CornerToTrackBits(), DrawFoundation(), DrawGroundSprite(), GetHalftileFoundationCorner(), GetHighestSlopeCorner(), GetJunctionGroundSpriteOffset(), GetRailFoundation(), GetRailGroundType(), GetRailReservationTrackBits(), GetRailType(), GetRailTypeInfo(), RailTypeInfo::ground, HalftileFoundation(), HalfTileSnow, HalfTileWater, HasReservedTracks(), IsNonContinuousFoundation(), IsSteepSlope(), IsValidCorner(), Left, Lower, Menu, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), None, OppositeCorner(), PALETTE_CRASH, PALETTE_TO_BARE_LAND, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), Right, RailTypeInfo::single_e, RailTypeInfo::single_n, RailTypeInfo::single_s, RailTypeInfo::single_sloped, RailTypeInfo::single_w, RailTypeInfo::single_x, RailTypeInfo::single_y, SLOPE_E, SLOPE_ELEVATED, SLOPE_FLAT, SLOPE_N, SLOPE_S, SLOPE_W, SlopeToSpriteOffset(), SlopeWithThreeCornersRaised(), RailTypeInfo::snow_offset, SnowOrDesert, SteepBoth, SteepLower, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileInfo::tile, TILE_HEIGHT, TileInfo::tileh, TRACK_BIT_CROSS, TRACK_BIT_HORZ, TRACK_BIT_VERT, RailTypeInfo::track_ns, RailTypeInfo::track_y, Upper, X, and Y.
Referenced by DrawTile_Rail().
|
static |
Definition at line 2092 of file rail_cmd.cpp.
|
static |
Draw track fences.
| ti | Tile drawing information. |
| rti | Rail type information. |
| pal | The palette to apply while drawing. |
Definition at line 2027 of file rail_cmd.cpp.
References ComplementSlope(), DrawTrackFence(), DrawTrackFence_NE(), DrawTrackFence_NW(), DrawTrackFence_SE(), DrawTrackFence_SW(), FenceHoriz1, FenceHoriz2, FenceNE, FenceNESW, FenceNW, Fences, FenceSE, FenceSENW, FenceSW, FenceVert1, FenceVert2, GetCustomRailSprite(), GetHalftileSlopeCorner(), GetHighestSlopeCorner(), GetRailGroundType(), HalfTileWater, IsHalftileSlope(), OppositeCorner(), RFO_FLAT_LEFT, RFO_FLAT_LOWER, RFO_FLAT_RIGHT, RFO_FLAT_UPPER, PalSpriteID::sprite, TCX_NORMAL, TCX_UPPER_HALFTILE, TileInfo::tile, and TileInfo::tileh.
Referenced by DrawTile_Rail().
|
static |
Draw a track fence.
| ti | Tile drawing information. |
| psid | First fence sprite and palette. |
| num_sprites | Number of fence sprites. |
| rfo | Fence to draw. |
Definition at line 1960 of file rail_cmd.cpp.
References _fence_offsets, AddSortableSpriteToDraw(), GetSlopePixelZInCorner(), IsValidCorner(), 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().
|
static |
Draw fence at NE border matching the tile slope.
| ti | Tile drawing information. |
| psid | First fence sprite and palette. |
| num_sprites | Number of fence sprites. |
Definition at line 2001 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().
|
static |
Draw fence at NW border matching the tile slope.
| ti | Tile drawing information. |
| psid | First fence sprite and palette. |
| num_sprites | Number of fence sprites. |
Definition at line 1975 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().
|
static |
Draw fence at SE border matching the tile slope.
| ti | Tile drawing information. |
| psid | First fence sprite and palette. |
| num_sprites | Number of fence sprites. |
Definition at line 1988 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().
|
static |
Draw fence at SW border matching the tile slope.
| ti | Tile drawing information. |
| psid | First fence sprite and palette. |
| num_sprites | Number of fence sprites. |
Definition at line 2014 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().
Definition at line 2087 of file rail_cmd.cpp.
| void DrawTrainDepotSprite | ( | int | x, |
| int | y, | ||
| DiagDirection | dir, | ||
| RailType | railtype ) |
Draw train depot sprite in the UI.
| x | X position. |
| y | Y position. |
| dir | Direction of depot. |
| railtype | Railtype of depot. |
Definition at line 2597 of file rail_cmd.cpp.
References _depot_gfx_table, _local_company, Depot, DrawRailTileSeqInGUI(), DrawSprite(), GetCompanyPalette(), GetCustomRailSprite(), GetRailTypeInfo(), RailTypeInfo::GetRailtypeSpriteOffset(), Ground, DrawTileSprites::ground, INVALID_TILE, RTO_X, RTO_Y, SE, PalSpriteID::sprite, and SW.
Referenced by BuildRailDepotWindow::DrawWidget().
|
static |
Tests if a vehicle interacts with the specified track.
All track bits interact except parallel TRACK_BIT_HORZ or TRACK_BIT_VERT.
| tile | The tile. |
| track | The track. |
Definition at line 228 of file rail_cmd.cpp.
References EnsureNoTrainOnTrackBits().
Referenced by CmdBuildSingleRail(), and CmdRemoveSingleRail().
| 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.
| t | The tile to flood. |
Definition at line 759 of file rail_cmd.cpp.
References _current_company, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), ApplyFoundationToSlope(), CornerToTrackBits(), Execute, FindFirstTrack(), GetHighestSlopeCorner(), GetRailFoundation(), GetRailGroundType(), GetTileSlope(), GetTrackBits(), HalfTileWater, IsNonContinuousFoundation(), IsPlainRailTile(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), MakeShore(), MarkTileDirtyByTile(), OppositeCorner(), OWNER_WATER, and SetRailGroundType().
Referenced by DoFloodTile().
|
static |
Tile callback function signature for getting the foundation of a tile.
| tile | The tile to check. |
| tileh | The current slope. |
Definition at line 2639 of file rail_cmd.cpp.
References FlatteningFoundation(), GetRailFoundation(), GetTrackBits(), and IsPlainRail().
|
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.
| track | The track bits to consider. |
Definition at line 2263 of file rail_cmd.cpp.
References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), TRACK_BIT_3WAY_NE, TRACK_BIT_3WAY_NW, TRACK_BIT_3WAY_SE, and TRACK_BIT_3WAY_SW.
Referenced by DrawTrackBits().
Get the other Trackdir for a non-diagonal Trackdir.
i.e. upper -> lower, left -> right, etc.
| trackdir | the trackdir. |
Definition at line 820 of file rail_cmd.cpp.
References to_underlying().
Referenced by CmdRailTrackHelper(), and CmdSignalTrackHelper().
| Foundation GetRailFoundation | ( | Slope | tileh, |
| TrackBits | bits ) |
Checks if a track combination is valid on a specific slope and returns the needed foundation.
| tileh | Tile slope. |
| bits | Trackbits. |
Definition at line 310 of file rail_cmd.cpp.
References _valid_tracks_on_leveled_foundation, _valid_tracks_without_foundation, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), CornerToTrackBits(), GetHighestSlopeCorner(), HalftileFoundation(), InclinedX, InclinedY, Invalid, IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), Left, Leveled, Lower, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), None, OppositeCorner(), Right, SLOPE_E, SLOPE_N, SLOPE_S, SLOPE_W, SlopeWithOneCornerRaised(), SlopeWithThreeCornersRaised(), SpecialRailFoundation(), SteepBoth, SteepLower, TRACK_BIT_HORZ, TRACK_BIT_VERT, TracksOverlap(), Upper, X, and Y.
Referenced by CheckRailSlope(), DrawRailCatenaryRailway(), DrawTrackBits(), FloodHalftile(), GetFoundation_Rail(), GetSlopePixelZ_Rail(), TerraformTile_Rail(), TestAutoslopeOnRailTile(), and TileLoop_Rail().
|
static |
Get surface height in point (x,y) On tiles with halftile foundations move (x,y) to a safe point wrt.
track
| x | The world X-coordinate. |
| y | The world Y-coordinate. |
| track | The track to get the height for. |
Definition at line 1860 of file rail_cmd.cpp.
References GetSlopePixelZ(), Left, Lower, Right, and Upper.
|
static |
Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.
| tile | The queries tile for the Z coordinate. |
| x | World X coordinate in tile "units". |
| y | World Y coordinate in tile "units". |
| ground_vehicle | Whether to get the Z coordinate of the ground vehicle, or the ground. |
Definition at line 2625 of file rail_cmd.cpp.
References ApplyPixelFoundationToSlope(), GetPartialPixelZ(), GetRailFoundation(), GetTileMaxPixelZ(), GetTilePixelSlope(), GetTrackBits(), IsPlainRail(), and SLOPE_FLAT.
Tile callback function signature for obtaining a tile description.
| tile | Tile being queried |
| td | Storage pointer for returned tile description |
Definition at line 2844 of file rail_cmd.cpp.
References _settings_game, TileDesc::build_date, Depot, End, GetRailTileType(), GetRailType(), GetRailTypeInfo(), GetSignalType(), GetTileOwner(), HasSignalOnTrack(), Lower, RailTypeInfo::max_speed, RailTypeInfo::name, Normal, TileDesc::owner, TileDesc::rail_speed, TileDesc::railtype, Signals, TileDesc::str, RailTypeInfo::strings, and Upper.
|
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.
| tile | the tile to get the track status from |
| mode | the mode of transportation |
| sub_mode | used to differentiate between different kinds within the mode |
| side | The side where the tile is entered. |
Definition at line 2772 of file rail_cmd.cpp.
References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), Depot, DiagDirToDiagTrack(), GetPresentSignals(), GetRailDepotDirection(), GetRailGroundType(), GetRailTileType(), GetSignalStates(), GetTileSlope(), GetTrackBits(), HalfTileWater, Invalid, IsOnewaySignal(), IsPlainRail(), IsSlopeWithOneCornerRaised(), Left, Left_N, Left_S, Lower, Lower_E, Lower_W, Normal, Right, Right_N, Right_S, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SignalOnTrack(), Signals, TrackBitsToTrackdirBits(), TRANSPORT_RAIL, TRANSPORT_WATER, Upper, Upper_E, Upper_W, X_NE, X_SW, Y_NW, and Y_SE.
| void InitRailTypes | ( | ) |
Resolve sprites of custom rail types.
Definition at line 130 of file rail_cmd.cpp.
References _sorted_railtypes, CompareRailTypes(), RailTypeInfo::flags, Hidden, RailTypeInfo::Index(), RailTypeInfo::label, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by AfterLoadGRFs().
|
static |
Helper to determine whether the train signals are to be placed on the right side.
true iff signals are to be drawn on the right side. Definition at line 1876 of file rail_cmd.cpp.
References _settings_game, Left, Right, and RoadVehicleDrivingSide.
|
static |
Definition at line 1764 of file rail_cmd.cpp.
| 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().
| void ResolveRailTypeGUISprites | ( | RailTypeInfo * | rti | ) |
Definition at line 75 of file rail_cmd.cpp.
|
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).
| tile | The involved tile. |
| flags | Command flags passed to the terraform command (DoCommandFlag::Execute, DoCommandFlag::QueryCost, etc.). |
| z_new | TileZ after terraforming. |
| tileh_new | Slope after terraforming. |
Definition at line 3125 of file rail_cmd.cpp.
References _price, _settings_game, AutoslopeCheckForEntranceEdge(), AutoslopeEnabled(), Barren, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), BuildFoundation, ClearWater, Construction, Execute, GetRailDepotDirection(), GetRailFoundation(), GetRailGroundType(), GetSlopeZInCorner(), GetTileSlopeZ(), GetTrackBits(), HalfTileWater, HasVehicleOnTile(), IsPlainRail(), IsSlopeWithOneCornerRaised(), IsSpecialRailFoundation(), Left, Lower, Right, SetRailGroundType(), Ship, SLOPE_EW, SLOPE_NS, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TestAutoslopeOnRailTile(), BaseVehicle::type, and Upper.
|
static |
Tests if autoslope is allowed.
| tile | The tile. |
| flags | Terraform command flags. |
| z_old | Old TileZ. |
| tileh_old | Old TileSlope. |
| z_new | New TileZ. |
| tileh_new | New TileSlope. |
| rail_bits | Trackbits. |
Definition at line 3085 of file rail_cmd.cpp.
References _price, _settings_game, CommandCost::AddCost(), ApplyFoundationToSlope(), AutoslopeEnabled(), Barren, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), BuildFoundation, CheckRailSlope(), ClearWater, Construction, Execute, CommandCost::Failed(), GetRailFoundation(), GetRailGroundType(), GetSlopeZInCorner(), HalfTileWater, IsSlopeWithOneCornerRaised(), Left, Lower, RemoveHalftileSlope(), Right, SetRailGroundType(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Upper.
Referenced by TerraformTile_Rail().
| 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.
| v | vehicle outside (leaving) the depot |
Definition at line 2999 of file rail_cmd.cpp.
References _fractcoords_enter, Train::CalcNextVehicleOffset(), GetRailDepotDirection(), NE, NW, SE, SW, Vehicle::tile, TILE_UNIT_MASK, Vehicle::x_pos, and Vehicle::y_pos.
Referenced by AdvanceWagonsAfterSwap(), CheckTrainsLengths(), and FixupTrainLengths().
|
static |
Tile callback function signature for running periodic tile updates.
| tile | The tile to update. |
Definition at line 2645 of file rail_cmd.cpp.
References _settings_game, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Arctic, Barren, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), Desert, End, FenceHoriz1, FenceHoriz2, FenceNE, FenceNESW, FenceNW, FenceSE, FenceSENW, FenceSW, FenceVert1, FenceVert2, GetRailFoundation(), GetRailGroundType(), GetSnowLine(), GetTileOwner(), GetTileSlopeZ(), GetTrackBits(), GetTropicZone(), Grass, HalfTileSnow, HalfTileWater, House, InclinedX, InclinedY, Industry, IsNonContinuousFoundation(), IsObjectType(), IsPlainRail(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), IsTileOwner(), IsTileType(), IsValidTile(), MarkTileDirtyByTile(), NE, None, NW, Object, OBJECT_OWNED_LAND, Road, SE, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetRailGroundType(), SLOPE_FLAT, SnowOrDesert, SteepLower, SW, TileLoop_Water(), TileOffsByDiagDir(), TRACK_BIT_3WAY_NE, TRACK_BIT_3WAY_NW, TRACK_BIT_3WAY_SE, TRACK_BIT_3WAY_SW, Tropic, and TunnelBridge.
|
static |
Definition at line 825 of file rail_cmd.cpp.
|
inlinestatic |
Definition at line 410 of file rail_cmd.cpp.
|
static |
Tile callback function for a vehicle entering a tile.
| v | Vehicle entering the tile. |
| tile | Tile entered. |
| x | X position in world coordinates. |
| y | Y position in world coordinates. |
Definition at line 3014 of file rail_cmd.cpp.
References _deltacoord_leaveoffset, _fractcoords_behind, _fractcoords_enter, AxisToTrack(), Train::CalcNextVehicleOffset(), CannotEnter, Depot, DiagDirToAxis(), DiagDirToDir(), DrivingBackwards, EnteredWormhole, SpecializedVehicle< T, Type >::First(), SpecializedVehicle< Train, Type >::From(), Vehicle::GetMovingDirection(), Vehicle::GetMovingNext(), GetRailDepotDirection(), Hidden, InvalidateWindowData(), IsRailDepotTile(), SpecializedVehicle< T, Type >::Next(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), ReverseDiagDir(), ReverseDir(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, TILE_UNIT_MASK, Train::track, Train, BaseVehicle::type, BaseConsist::vehicle_flags, VehicleEnterDepot(), and Vehicle::vehstatus.
|
staticconstexpr |
Offsets (to be multiplied by length) from the depot enter coordinates where a train should appear when exiting a depot for each depot direction.
Definition at line 2986 of file rail_cmd.cpp.
Referenced by VehicleEnterTile_Rail().
|
static |
Offsets for drawing fences.
Definition at line 1934 of file rail_cmd.cpp.
Referenced by DrawTrackFence().
|
staticconstexpr |
Coordinates to detect when a train is approaching a depot from behind for each depot direction.
Definition at line 2967 of file rail_cmd.cpp.
Referenced by VehicleEnterTile_Rail().
|
staticconstexpr |
Coordinates where a train should enter a depot for each depot direction.
Definition at line 2975 of file rail_cmd.cpp.
Referenced by TicksToLeaveDepot(), and VehicleEnterTile_Rail().
|
staticconstexpr |
SubSprite for drawing the track halftile of 'three-corners-raised'-sloped rail sprites.
Definition at line 2080 of file rail_cmd.cpp.
Referenced by DrawTrackBits().
| RailTypeInfo _railtypes[RAILTYPE_END] |
Definition at line 46 of file rail_cmd.cpp.
| RailTypes _railtypes_hidden_mask |
Definition at line 48 of file rail_cmd.cpp.
| std::vector<RailType> _sorted_railtypes |
Sorted list of rail types.
Definition at line 47 of file rail_cmd.cpp.
Referenced by BuildRailToolbarWindow::ChangeRailTypeOnHotkey(), GetRailTypeDropDownList(), InitRailTypes(), SetDefaultRailGui(), CompanyInfrastructureWindow::UpdateWidgetSize(), and ReplaceVehicleWindow::UpdateWidgetSize().
|
extern |
TileTypeProcs definitions for TileType::Rail tiles.
Definition at line 53 of file landscape.cpp.
|
static |
Definition at line 181 of file rail_cmd.cpp.
|
static |
Tile deltas for each trackdir.
Definition at line 805 of file rail_cmd.cpp.
Referenced by CmdRailTrackHelper(), and CmdSignalTrackHelper().
|
static |
Valid TrackBits on a specific (non-steep)-slope with leveled foundation.
Definition at line 282 of file rail_cmd.cpp.
Referenced by CheckRailSlope(), and GetRailFoundation().
|
static |
Valid TrackBits on a specific (non-steep)-slope without foundation.
Definition at line 260 of file rail_cmd.cpp.
Referenced by GetRailFoundation().
|
static |
Big number compared to tilesprite size.
Definition at line 2078 of file rail_cmd.cpp.
Referenced by DrawBridgePillars(), and DrawRoadTypeCatenary().