OpenTTD Source 20241224-master-gee860a5c8e
|
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 (DoCommandFlag flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals) |
Build a single piece of rail. | |
CommandCost | CmdRemoveSingleRail (DoCommandFlag 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 (DoCommandFlag 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 (DoCommandFlag 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 (DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, Track track) |
Build rail on a stretch of track. | |
CommandCost | CmdBuildTrainDepot (DoCommandFlag flags, TileIndex tile, RailType railtype, DiagDirection dir) |
Build a train depot. | |
CommandCost | CmdBuildSingleSignal (DoCommandFlag 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 (DoCommandFlag 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 (DoCommandFlag 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 (DoCommandFlag flags, TileIndex tile, Track track) |
Remove signals. | |
CommandCost | CmdRemoveSignalTrack (DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill) |
Remove signals on a stretch of track. | |
static Vehicle * | UpdateTrainPowerProc (Vehicle *v, void *data) |
Update power of train under which is the railtype being converted. | |
CommandCost | CmdConvertRail (DoCommandFlag flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal) |
Convert one rail type to the other. | |
static CommandCost | RemoveTrainDepot (TileIndex tile, DoCommandFlag flags) |
static CommandCost | ClearTile_Track (TileIndex tile, DoCommandFlag flags) |
static uint | GetSaveSlopeZ (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, SpriteID base_image, uint num_sprites, RailFenceOffset rfo) |
Draw a track fence. | |
static void | DrawTrackFence_NW (const TileInfo *ti, SpriteID base_image, uint num_sprites) |
Draw fence at NW border matching the tile slope. | |
static void | DrawTrackFence_SE (const TileInfo *ti, SpriteID base_image, uint num_sprites) |
Draw fence at SE border matching the tile slope. | |
static void | DrawTrackFence_NE (const TileInfo *ti, SpriteID base_image, uint num_sprites) |
Draw fence at NE border matching the tile slope. | |
static void | DrawTrackFence_SW (const TileInfo *ti, SpriteID base_image, uint num_sprites) |
Draw fence at SW border matching the tile slope. | |
static void | DrawTrackDetails (const TileInfo *ti, const RailTypeInfo *rti) |
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 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_Track (TileInfo *ti) |
void | DrawTrainDepotSprite (int x, int y, int dir, RailType railtype) |
static int | GetSlopePixelZ_Track (TileIndex tile, uint x, uint y, bool) |
static Foundation | GetFoundation_Track (TileIndex tile, Slope tileh) |
static void | TileLoop_Track (TileIndex tile) |
static TrackStatus | GetTileTrackStatus_Track (TileIndex tile, TransportType mode, uint, DiagDirection side) |
static bool | ClickTile_Track (TileIndex tile) |
static void | GetTileDesc_Track (TileIndex tile, TileDesc *td) |
static void | ChangeTileOwner_Track (TileIndex tile, Owner old_owner, Owner new_owner) |
int | TicksToLeaveDepot (const Train *v) |
Compute number of ticks when next wagon will leave a depot. | |
static VehicleEnterTileStatus | VehicleEnter_Track (Vehicle *u, TileIndex tile, int x, int y) |
Tile callback routine when vehicle enters tile. | |
static CommandCost | TestAutoslopeOnRailTile (TileIndex tile, uint flags, int z_old, Slope tileh_old, int z_new, Slope tileh_new, TrackBits rail_bits) |
Tests if autoslope is allowed. | |
static Vehicle * | EnsureNoShipProc (Vehicle *v, void *) |
Test-procedure for HasVehicleOnPos to check for a ship. | |
static CommandCost | TerraformTile_Track (TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new) |
Variables | |
RailTypeInfo | _railtypes [RAILTYPE_END] |
std::vector< RailType > | _sorted_railtypes |
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 uint32_t | _drawtile_track_palette |
static FenceOffset | _fence_offsets [] |
Offsets for drawing fences. | |
static const int | INF = 1000 |
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 |
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 1199 of file rail_cmd.cpp.
RailType AllocateRailType | ( | RailTypeLabel | label | ) |
Allocate a new rail type label.
Definition at line 150 of file rail_cmd.cpp.
References _original_railtypes, RailTypeInfo::alternate_labels, RailTypeInfo::compatible_railtypes, RailTypeInfo::introduces_railtypes, INVALID_RAILTYPE, RailTypeInfo::label, RailTypeInfo::powered_railtypes, RAILTYPE_BEGIN, RAILTYPE_END, RAILTYPE_RAIL, and RailTypeInfo::sorting_order.
Definition at line 2874 of file rail_cmd.cpp.
|
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 392 of file rail_cmd.cpp.
References _settings_game, _valid_tracks_on_leveled_foundation, ConstructionSettings::build_on_slopes, GameSettings::construction, EXPENSES_CONSTRUCTION, FLOOD_NONE, FOUNDATION_INVALID, FOUNDATION_NONE, GetFloodingBehaviour(), GetRailFoundation(), and IsSteepSlope().
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 241 of file rail_cmd.cpp.
References GetTrackBits(), and IsPlainRail().
Referenced by CmdBuildSingleRail().
|
static |
Definition at line 1800 of file rail_cmd.cpp.
|
static |
Definition at line 2773 of file rail_cmd.cpp.
CommandCost CmdBuildRailroadTrack | ( | DoCommandFlag | 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 932 of file rail_cmd.cpp.
References CmdRailTrackHelper().
CommandCost CmdBuildSignalTrack | ( | DoCommandFlag | 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 1449 of file rail_cmd.cpp.
References CmdSignalTrackHelper().
CommandCost CmdBuildSingleRail | ( | DoCommandFlag | 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 426 of file rail_cmd.cpp.
References _current_company, _settings_game, CommandCost::AddCost(), AddTrackToSignalBuffer(), AXIS_X, AXIS_Y, CheckForDockingTile(), CheckOwnership(), CheckRailSlope(), CheckTileOwnership(), CheckTrackCombination(), CMD_ERROR, GameSettings::construction, CountBits(), ConstructionSettings::crossing_with_competitor, DC_EXEC, DirtyCompanyInfrastructureWindows(), DRD_NONE, EnsureNoTrainOnTrack(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCrossingRailBits(), GetCrossingRoadAxis(), GetDisallowedRoadDirections(), GetRailType(), GetRoadBits(), GetRoadOwner(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), HasBit(), HasExactlyOneBit(), HasPowerOnRail(), HasRoadWorks(), HasSignalOnTrack(), HasSignals(), HasTrack(), INVALID_ROADTYPE, IsCompatibleRail(), IsLevelCrossing(), IsNormalRoad(), IsPlainRail(), IsSlopeWithOneCornerRaised(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), LEVELCROSSING_TRACKBIT_FACTOR, MakeRoadCrossing(), MarkDirtyAdjacentLevelCrossingTiles(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_WATER, OWNER_DEITY, RAIL_GROUND_BARREN, RAIL_GROUND_WATER, RailBuildCost(), RailNoLevelCrossings(), ROAD_NONE, ROAD_X, ROAD_Y, RoadBuildCost(), RoadNoLevelCrossing(), SetTrackBits(), CommandCost::Succeeded(), TRACK_BEGIN, TRACK_BIT_NONE, TRACK_END, TRACK_X, TRACK_Y, TracksOverlap(), TrackToTrackBits(), UpdateLevelCrossing(), VALID_LEVEL_CROSSING_SLOPES, ValParamRailType(), and YapfNotifyTrackLayoutChange().
CommandCost CmdBuildSingleSignal | ( | DoCommandFlag | 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 1052 of file rail_cmd.cpp.
References _current_company, _settings_game, AddTrackToSignalBuffer(), CheckTileOwnership(), CMD_ERROR, CountBits(), Vehicle::cur_speed, Vehicle::current_order, DC_EXEC, DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), PathfinderSettings::forbid_90_deg, FreeTrainTrackReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetPresentSignals(), GetRailReservationTrackBits(), GetSignalStates(), GetTileOwner(), GetTrackBits(), GetTrainForReservation(), Train::GetVehicleTrackdir(), HasBit(), HasReservedTracks(), HasSignalOnTrack(), HasSignals(), HasTrack(), IsPlainRailTile(), IsSafeWaitingPosition(), Order::IsType(), KillFirstBit(), MarkTileDirtyByTile(), GameSettings::pf, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SIG_SEMAPHORE, SignalOnTrack(), Vehicle::tile, TRACK_BIT_DEPOT, TracksOverlap(), TrackToTrackBits(), TryPathReserve(), Vehicle::vehstatus, VS_STOPPED, and YapfNotifyTrackLayoutChange().
CommandCost CmdBuildTrainDepot | ( | DoCommandFlag | 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 963 of file rail_cmd.cpp.
References _current_company, _settings_game, CommandCost::AddCost(), AddSideToSignalBuffer(), Depot::build_date, ConstructionSettings::build_on_slopes, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_depot_pool >::CanAllocateItem(), CanBuildDepotByTileh(), CheckTileOwnership(), CMD_ERROR, GameSettings::construction, TimerGameCalendar::date, DC_EXEC, DiagDirToDiagTrack(), DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetRailDepotDirection(), GetRailType(), GetTileSlope(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIAGDIR, IsBridgeAbove(), IsRailDepotTile(), IsValidDiagDirection(), MakeDefaultName(), MakeRailDepot(), MarkTileDirtyByTile(), RailBuildCost(), SetRailDepotExitDirection(), SLOPE_FLAT, ValParamRailType(), and YapfNotifyTrackLayoutChange().
CommandCost CmdConvertRail | ( | DoCommandFlag | 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 1553 of file rail_cmd.cpp.
References _settings_game, CommandCost::AddCost(), CCF_TRACK, CheckTileOwnership(), CMD_ERROR, CountBits(), TileIterator::Create(), DC_EXEC, DiagDirToDiagTrack(), DirtyCompanyInfrastructureWindows(), VehicleSettings::disable_elrails, EnsureNoTrainOnTrackBits(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), FindVehicleOnPos(), FreeTrainTrackReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCrossingRailTrack(), GetOtherTunnelBridgeEnd(), GetRailDepotTrack(), GetRailStationTrack(), GetRailTileType(), GetRailType(), GetReservedTrackbits(), GetTileOwner(), GetTileType(), GetTrackBits(), GetTrainForReservation(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasPowerOnRail(), HasStationRail(), HasTunnelBridgeReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_TILE, INVALID_TRACK, InvalidateWindowData(), IsBridge(), IsCompatibleRail(), IsLevelCrossing(), IsLevelCrossingTile(), IsPlainRailTile(), IsRailStationTile(), IsStationTileBlocked(), LEVELCROSSING_TRACKBIT_FACTOR, CommandCost::MakeError(), MarkBridgeDirty(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, CompanyInfrastructure::rail, RAIL_TILE_DEPOT, RailConvertCost(), RailNoLevelCrossings(), RAILTYPE_ELECTRIC, RAILTYPE_RAIL, RemoveFirstTrack(), SetRailType(), Map::Size(), TRACK_BIT_NONE, TracksOverlap(), TRANSPORT_RAIL, TryPathReserve(), TUNNELBRIDGE_TRACKBIT_FACTOR, TunnelBridgeIsFree(), UpdateTrainPowerProc(), ValParamRailType(), GameSettings::vehicle, WC_BUILD_VEHICLE, WC_VEHICLE_DEPOT, 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 876 of file rail_cmd.cpp.
References CommandCost::AddCost(), CMD_ERROR, EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetErrorMessage(), IsDiagonalTrackdir(), Map::Size(), ToggleBit(), ToTileIndexDiff(), TrackdirToTrack(), TrackToTrackdir(), and ValParamRailType().
Referenced by CmdBuildRailroadTrack(), and CmdRemoveRailroadTrack().
CommandCost CmdRemoveRailroadTrack | ( | DoCommandFlag | 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 947 of file rail_cmd.cpp.
References CmdRailTrackHelper(), and INVALID_RAILTYPE.
CommandCost CmdRemoveSignalTrack | ( | DoCommandFlag | 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 1527 of file rail_cmd.cpp.
References CmdSignalTrackHelper(), SIG_ELECTRIC, and SIGTYPE_BLOCK.
CommandCost CmdRemoveSingleRail | ( | DoCommandFlag | 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 615 of file rail_cmd.cpp.
References _current_company, CommandCost::AddCost(), AddTrackToSignalBuffer(), CheckTileOwnership(), CMD_ERROR, CountBits(), DC_BANKRUPT, DC_EXEC, DeleteNewGRFInspectWindow(), DirtyCompanyInfrastructureWindows(), EnsureNoTrainOnTrack(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), FreeTrainTrackReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCrossingRailBits(), GetCrossingRoadAxis(), GetCrossingRoadBits(), GetRailReservationTrackBits(), GetRailType(), GetRoadOwner(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), GetTrainForReservation(), HasReservedTracks(), HasSignalOnTrack(), INVALID_OWNER, IsDockingTile(), IsLevelCrossing(), IsPlainRail(), IsSlopeWithOneCornerRaised(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), LEVELCROSSING_TRACKBIT_FACTOR, MakeRoadNormal(), MakeShore(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, OWNER_WATER, RAIL_GROUND_WATER, RailClearCost(), SetDockingTile(), SetTrackBits(), SetTrackReservation(), TRACK_BIT_X, TRACK_BIT_Y, TRACK_X, TRACK_Y, TracksOverlap(), TrackToTrackBits(), TryPathReserve(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), and YapfNotifyTrackLayoutChange().
CommandCost CmdRemoveSingleSignal | ( | DoCommandFlag | 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 1461 of file rail_cmd.cpp.
References _current_company, AddTrackToSignalBuffer(), CheckTileOwnership(), CountBits(), DC_EXEC, DirtyCompanyInfrastructureWindows(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetPresentSignals(), GetReservedTrackbits(), GetTileOwner(), GetTrainForReservation(), HasReservedTracks(), HasSignalOnTrack(), HasSignalOnTrackdir(), HasTrack(), INVALID_TRACK, IsPlainRailTile(), MarkTileDirtyByTile(), OWNER_WATER, ReverseTrackdir(), SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SignalOnTrack(), TileAddByDiagDir(), TrackBitsToTrack(), TrackdirBitsToTrackBits(), TrackdirReachesTrackdirs(), TrackdirToExitdir(), TrackToTrackBits(), 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 1258 of file rail_cmd.cpp.
References CommandCost::AddCost(), CMD_ERROR, EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetErrorMessage(), GetOtherTunnelBridgeEnd(), GetPresentSignals(), GetTileType(), GetTunnelBridgeLength(), HasBit(), HasSignalOnTrack(), HasTrack(), INVALID_STRING_ID, INVALID_TILE, INVALID_TRACKDIR, IsDiagonalTrackdir(), IsPlainRailTile(), MP_RAILWAY, MP_ROAD, MP_TUNNELBRIDGE, SetBit(), SIG_SEMAPHORE, SignalAgainstTrackdir(), SignalAlongTrackdir(), SignalOnTrack(), SIGTYPE_BLOCK, SIGTYPE_ENTRY, SIGTYPE_EXIT, Map::Size(), CommandCost::Succeeded(), ToggleBit(), ToTileIndexDiff(), TrackdirToTrack(), and TrackToTrackdir().
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 2388 of file rail_cmd.cpp.
|
static |
Definition at line 1871 of file rail_cmd.cpp.
|
static |
Definition at line 2422 of file rail_cmd.cpp.
Draw ground sprite and track bits.
ti | TileInfo |
track | TrackBits to draw |
Definition at line 2237 of file rail_cmd.cpp.
References _settings_client, RailTypeInfo::base_sprites, ComplementSlope(), CornerToTrackBits(), DrawFoundation(), DrawGroundSprite(), FOUNDATION_NONE, FOUNDATION_STEEP_BOTH, FOUNDATION_STEEP_LOWER, GetHalftileFoundationCorner(), GetHighestSlopeCorner(), GetRailFoundation(), GetRailReservationTrackBits(), GetRailType(), GetRailTypeInfo(), RailTypeInfo::ground, ClientSettings::gui, HalftileFoundation(), HasReservedTracks(), IsNonContinuousFoundation(), IsSteepSlope(), IsValidCorner(), OppositeCorner(), PALETTE_CRASH, PALETTE_TO_BARE_LAND, RAIL_GROUND_BARREN, RAIL_GROUND_HALF_SNOW, RAIL_GROUND_ICE_DESERT, RAIL_GROUND_WATER, GUISettings::show_track_reservation, 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, TileInfo::tile, TILE_HEIGHT, TileInfo::tileh, TRACK_BIT_3WAY_NE, TRACK_BIT_3WAY_NW, TRACK_BIT_3WAY_SE, TRACK_BIT_3WAY_SW, TRACK_BIT_CROSS, TRACK_BIT_HORZ, TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, TRACK_BIT_VERT, TRACK_BIT_X, TRACK_BIT_Y, RailTypeInfo::track_ns, and RailTypeInfo::track_y.
|
static |
Definition at line 2072 of file rail_cmd.cpp.
|
static |
Draw track fences.
ti | Tile drawing information. |
rti | Rail type information. |
Definition at line 2010 of file rail_cmd.cpp.
References ComplementSlope(), DrawTrackFence(), DrawTrackFence_NE(), DrawTrackFence_NW(), DrawTrackFence_SE(), DrawTrackFence_SW(), GetCustomRailSprite(), GetHalftileSlopeCorner(), GetHighestSlopeCorner(), IsHalftileSlope(), OppositeCorner(), RAIL_GROUND_FENCE_HORIZ1, RAIL_GROUND_FENCE_HORIZ2, RAIL_GROUND_FENCE_NE, RAIL_GROUND_FENCE_NESW, RAIL_GROUND_FENCE_NW, RAIL_GROUND_FENCE_SE, RAIL_GROUND_FENCE_SENW, RAIL_GROUND_FENCE_SW, RAIL_GROUND_FENCE_VERT1, RAIL_GROUND_FENCE_VERT2, RAIL_GROUND_WATER, RFO_FLAT_LEFT, RFO_FLAT_LOWER, RFO_FLAT_RIGHT, RFO_FLAT_UPPER, RTSG_FENCES, TCX_NORMAL, TCX_UPPER_HALFTILE, TileInfo::tile, and TileInfo::tileh.
|
static |
Draw a track fence.
ti | Tile drawing information. |
base_image | First fence sprite. |
num_sprites | Number of fence sprites. |
rfo | Fence to draw. |
Definition at line 1951 of file rail_cmd.cpp.
References _fence_offsets, AddSortableSpriteToDraw(), GetSlopePixelZInCorner(), FenceOffset::height_ref, RemoveHalftileSlope(), TileInfo::tileh, TileInfo::x, FenceOffset::x_offs, FenceOffset::x_size, TileInfo::y, FenceOffset::y_offs, FenceOffset::y_size, and TileInfo::z.
Referenced by DrawTrackDetails(), DrawTrackFence_NE(), DrawTrackFence_NW(), DrawTrackFence_SE(), and DrawTrackFence_SW().
Draw fence at NE border matching the tile slope.
Definition at line 1988 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().
Draw fence at NW border matching the tile slope.
Definition at line 1968 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().
Draw fence at SE border matching the tile slope.
Definition at line 1978 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().
Draw fence at SW border matching the tile slope.
Definition at line 1998 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().
|
inlinestatic |
Definition at line 2067 of file rail_cmd.cpp.
void DrawTrainDepotSprite | ( | int | x, |
int | y, | ||
int | dir, | ||
RailType | railtype | ||
) |
Definition at line 2543 of file rail_cmd.cpp.
Test-procedure for HasVehicleOnPos to check for a ship.
Definition at line 3036 of file rail_cmd.cpp.
References BaseVehicle::type, and VEH_SHIP.
|
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 229 of file rail_cmd.cpp.
References EnsureNoTrainOnTrackBits(), and TrackToTrackBits().
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 762 of file rail_cmd.cpp.
References _current_company, ApplyFoundationToSlope(), CornerToTrackBits(), DC_EXEC, FindFirstTrack(), GetHighestSlopeCorner(), GetRailFoundation(), GetTileSlope(), GetTrackBits(), IsNonContinuousFoundation(), IsPlainRailTile(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), MakeShore(), MarkTileDirtyByTile(), OppositeCorner(), OWNER_WATER, RAIL_GROUND_WATER, and Backup< T >::Restore().
Referenced by DoFloodTile().
|
static |
Definition at line 2583 of file rail_cmd.cpp.
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 312 of file rail_cmd.cpp.
References _valid_tracks_without_foundation, CornerToTrackBits(), FOUNDATION_INCLINED_X, FOUNDATION_INCLINED_Y, FOUNDATION_INVALID, FOUNDATION_LEVELED, FOUNDATION_NONE, FOUNDATION_STEEP_BOTH, FOUNDATION_STEEP_LOWER, GetHighestSlopeCorner(), HalftileFoundation(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), OppositeCorner(), SLOPE_E, SLOPE_N, SLOPE_S, SLOPE_W, SlopeWithOneCornerRaised(), SlopeWithThreeCornersRaised(), SpecialRailFoundation(), TRACK_BIT_HORZ, TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_NONE, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, TRACK_BIT_VERT, TRACK_BIT_X, TRACK_BIT_Y, and TracksOverlap().
Referenced by CheckRailSlope(), DrawRailCatenaryRailway(), DrawTrackBits(), FloodHalftile(), and TestAutoslopeOnRailTile().
|
static |
Get surface height in point (x,y) On tiles with halftile foundations move (x,y) to a safe point wrt.
track
Definition at line 1859 of file rail_cmd.cpp.
References GetSlopePixelZ(), TRACK_LEFT, TRACK_LOWER, TRACK_RIGHT, and TRACK_UPPER.
|
static |
Definition at line 2570 of file rail_cmd.cpp.
Definition at line 2781 of file rail_cmd.cpp.
|
static |
Definition at line 2711 of file rail_cmd.cpp.
void InitRailTypes | ( | ) |
Resolve sprites of custom rail types.
Definition at line 130 of file rail_cmd.cpp.
References CompareRailTypes(), RailTypeInfo::flags, HasBit(), RAILTYPE_BEGIN, RAILTYPE_END, RTF_HIDDEN, and SetBit().
Referenced by AfterLoadGRFs().
|
static |
Definition at line 1766 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, lengthof, and RAILTYPES_NONE.
Referenced by ResetNewGRFData().
void ResolveRailTypeGUISprites | ( | RailTypeInfo * | rti | ) |
Definition at line 75 of file rail_cmd.cpp.
|
static |
Definition at line 3041 of file rail_cmd.cpp.
|
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 2994 of file rail_cmd.cpp.
References _settings_game, CommandCost::AddCost(), ApplyFoundationToSlope(), AutoslopeEnabled(), ConstructionSettings::build_on_slopes, CheckRailSlope(), GameSettings::construction, DC_EXEC, EXPENSES_CONSTRUCTION, GetRailFoundation(), GetSlopeZInCorner(), IsSlopeWithOneCornerRaised(), RAIL_GROUND_BARREN, RAIL_GROUND_WATER, RemoveHalftileSlope(), TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_NONE, TRACK_BIT_RIGHT, and TRACK_BIT_UPPER.
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 2916 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().
|
static |
Definition at line 2588 of file rail_cmd.cpp.
Update power of train under which is the railtype being converted.
Definition at line 1533 of file rail_cmd.cpp.
References SpecializedVehicle< T, Type >::From(), include(), BaseVehicle::type, and VEH_TRAIN.
Referenced by CmdConvertRail().
|
static |
Definition at line 817 of file rail_cmd.cpp.
|
inlinestatic |
Definition at line 412 of file rail_cmd.cpp.
|
static |
Tile callback routine when vehicle enters tile.
Definition at line 2934 of file rail_cmd.cpp.
References AXIS_X, Train::CalcNextVehicleOffset(), DiagDirToAxis(), DiagDirToDir(), Vehicle::direction, SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::From(), GetRailDepotDirection(), InvalidateWindowData(), IsRailDepotTile(), SpecializedVehicle< T, Type >::Next(), ReverseDiagDir(), ReverseDir(), Vehicle::tile, TRACK_BIT_DEPOT, TRACK_BIT_X, TRACK_BIT_Y, BaseVehicle::type, VEH_TRAIN, VehicleEnterDepot(), Vehicle::vehstatus, VETSB_CANNOT_ENTER, VETSB_CONTINUE, VETSB_ENTERED_WORMHOLE, VS_HIDDEN, and WC_VEHICLE_DEPOT.
|
static |
Definition at line 2904 of file rail_cmd.cpp.
|
static |
Definition at line 1911 of file rail_cmd.cpp.
|
static |
Offsets for drawing fences.
Definition at line 1925 of file rail_cmd.cpp.
Referenced by DrawTrackFence().
|
static |
Definition at line 2902 of file rail_cmd.cpp.
|
static |
Definition at line 2903 of file rail_cmd.cpp.
|
static |
Definition at line 2060 of file rail_cmd.cpp.
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 |
Definition at line 47 of file rail_cmd.cpp.
|
extern |
Definition at line 49 of file landscape.cpp.
|
static |
Definition at line 182 of file rail_cmd.cpp.
|
static |
Definition at line 807 of file rail_cmd.cpp.
|
static |
Valid TrackBits on a specific (non-steep)-slope with leveled foundation.
Definition at line 284 of file rail_cmd.cpp.
Referenced by CheckRailSlope().
|
static |
Valid TrackBits on a specific (non-steep)-slope without foundation.
Definition at line 262 of file rail_cmd.cpp.
Referenced by GetRailFoundation().
|
static |
Definition at line 2059 of file rail_cmd.cpp.