OpenTTD
|
Handling of rail tiles. More...
#include "stdafx.h"
#include "cmd_helper.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 "date_func.h"
#include "strings_func.h"
#include "company_gui.h"
#include "object_map.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... |
Macros | |
#define | MAYBE_DRAW_SIGNAL(x, y, z, t) if (IsSignalPresent(tile, x)) DrawSingleSignal(tile, rti, t, GetSingleSignalState(tile, x), y, z) |
Typedefs | |
typedef SmallVector< Train *, 16 > | 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 | |
assert_compile (sizeof(_original_railtypes)<=sizeof(_railtypes)) | |
void | ResetRailTypes () |
Reset all rail type information to its default values. | |
void | ResolveRailTypeGUISprites (RailtypeInfo *rti) |
static int CDECL | 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, uint flags) |
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 (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build a single piece of rail. | |
CommandCost | CmdRemoveSingleRail (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
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 (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build or remove a stretch of railroad tracks. | |
CommandCost | CmdBuildRailroadTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build rail on a stretch of track. | |
CommandCost | CmdRemoveRailroadTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build rail on a stretch of track. | |
CommandCost | CmdBuildTrainDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build a train depot. | |
CommandCost | CmdBuildSingleSignal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals, and what-else not. | |
static bool | CheckSignalAutoFill (TileIndex &tile, Trackdir &trackdir, int &signal_ctr, bool remove) |
static CommandCost | CmdSignalTrackHelper (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build many signals by dragging; AutoSignals. | |
CommandCost | CmdBuildSignalTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build signals on a stretch of track. | |
CommandCost | CmdRemoveSingleSignal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Remove signals. | |
CommandCost | CmdRemoveSignalTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
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 (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
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) |
static Foundation | GetFoundation_Track (TileIndex tile, Slope tileh) |
static void | TileLoop_Track (TileIndex tile) |
static TrackStatus | GetTileTrackStatus_Track (TileIndex tile, TransportType mode, uint sub_mode, 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 *data) |
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] |
RailType | _sorted_railtypes [RAILTYPE_END] |
uint8 | _sorted_railtypes_size |
static const byte | _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 | _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 byte | _fractcoords_behind [4] = { 0x8F, 0x8, 0x80, 0xF8 } |
static const byte | _fractcoords_enter [4] = { 0x8A, 0x48, 0x84, 0xA8 } |
static const int8 | _deltacoord_leaveoffset [8] |
const TileTypeProcs | _tile_type_rail_procs |
Handling of rail tiles.
Definition in 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 53 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 400 of file rail_cmd.cpp.
References _settings_game, ConstructionSettings::build_on_slopes, GameSettings::construction, EXPENSES_CONSTRUCTION, FLOOD_NONE, FOUNDATION_INVALID, FOUNDATION_NONE, GetFloodingBehaviour(), GetRailFoundation(), IsSteepSlope(), and return_cmd_error.
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. |
flags | Flags of the operation. |
Definition at line 241 of file rail_cmd.cpp.
References DC_NO_RAIL_OVERLAP, GetTrackBits(), HasSignals(), IsPlainRail(), return_cmd_error, TRACK_BIT_HORZ, and TRACK_BIT_VERT.
Referenced by CmdBuildSingleRail().
CommandCost CmdBuildRailroadTrack | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build rail on a stretch of track.
Stub for the unified rail builder/remover
tile | start tile of drag |
flags | operation to perform |
p1 | end tile of drag |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 916 of file rail_cmd.cpp.
References ClrBit(), and CmdRailTrackHelper().
CommandCost CmdBuildSignalTrack | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build signals on a stretch of track.
Stub for the unified signal builder/remover
tile | start tile of drag |
flags | operation to perform |
p1 | end tile of drag |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 1420 of file rail_cmd.cpp.
References CmdSignalTrackHelper().
CommandCost CmdBuildSingleRail | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build a single piece of rail.
tile | tile to build on |
flags | operation to perform |
p1 | railtype of being built piece (normal, mono, maglev) |
p2 | rail track to build |
text | unused |
Definition at line 434 of file rail_cmd.cpp.
References _current_company, CommandCost::AddCost(), AddTrackToSignalBuffer(), AXIS_X, AXIS_Y, CheckOwnership(), CheckRailSlope(), CheckTileOwnership(), CheckTrackCombination(), CMD_CONVERT_RAIL, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CountBits(), DC_EXEC, DirtyCompanyInfrastructureWindows(), DoCommand(), DRD_NONE, EnsureNoTrainOnTrack(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCrossingRailBits(), GetDisallowedRoadDirections(), GetRailType(), GetRoadBits(), GetRoadOwner(), GetRoadTypes(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), HasBit(), HasExactlyOneBit(), HasPowerOnRail(), HasRoadWorks(), 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(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_WATER, RAIL_GROUND_BARREN, RAIL_GROUND_WATER, RailBuildCost(), RailNoLevelCrossings(), return_cmd_error, ROAD_NONE, ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ROAD, SetTrackBits(), CommandCost::Succeeded(), TRACK_BIT_NONE, TRACK_X, TRACK_Y, TracksOverlap(), TrackToTrackBits(), UpdateLevelCrossing(), VALID_LEVEL_CROSSING_SLOPES, ValParamRailtype(), and YapfNotifyTrackLayoutChange().
CommandCost CmdBuildSingleSignal | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
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, bit 4 (cycle signal-type) is ignored
tile | tile where to build the signals |
flags | operation to perform |
p1 | various bitstuffed elements
|
p2 | used for CmdBuildManySignals() to copy direction of first signal |
text | unused |
Definition at line 1024 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(), GB(), 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, return_cmd_error, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SIG_SEMAPHORE, SignalOnTrack(), Vehicle::tile, TracksOverlap(), TrackToTrackBits(), TryPathReserve(), Vehicle::vehstatus, VS_STOPPED, and YapfNotifyTrackLayoutChange().
CommandCost CmdBuildTrainDepot | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build a train depot.
tile | position of the train depot |
flags | operation to perform |
p1 | rail type |
p2 | bit 0..1 entrance direction (DiagDirection) |
text | unused |
Definition at line 952 of file rail_cmd.cpp.
References _current_company, _date, _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(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, GameSettings::construction, DC_EXEC, DiagDirToDiagTrack(), DirtyCompanyInfrastructureWindows(), DoCommand(), CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetTileSlope(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIAGDIR, IsBridgeAbove(), MakeDefaultName(), MarkTileDirtyByTile(), RailBuildCost(), return_cmd_error, SLOPE_FLAT, ValParamRailtype(), and YapfNotifyTrackLayoutChange().
CommandCost CmdConvertRail | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Convert one rail type to the other.
You can convert normal rail to monorail/maglev easily or vice-versa.
tile | end tile of rail conversion drag |
flags | operation to perform |
p1 | start tile of drag |
p2 | various bitstuffed elements:
|
text | unused |
Definition at line 1540 of file rail_cmd.cpp.
References _settings_game, CommandCost::AddCost(), SmallVector< T, S >::Append(), SmallVector< T, S >::Begin(), CCF_TRACK, CheckTileOwnership(), CMD_ERROR, CountBits(), DC_EXEC, DiagDirToDiagTrack(), DirtyCompanyInfrastructureWindows(), VehicleSettings::disable_elrails, SmallVector< T, S >::End(), EnsureNoVehicleOnGround(), error(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), FindVehicleOnPos(), FreeTrainTrackReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), GetCrossingRailTrack(), GetOtherTunnelBridgeEnd(), GetRailDepotTrack(), GetRailStationTrack(), GetRailTileType(), GetRailType(), GetReservedTrackbits(), GetTileOwner(), GetTileType(), GetTrackBits(), GetTrainForReservation(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasBit(), 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(), SmallVector< T, S >::Length(), LEVELCROSSING_TRACKBIT_FACTOR, CommandCost::MakeError(), MapSize(), MarkBridgeDirty(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, CompanyInfrastructure::rail, RAIL_TILE_DEPOT, RailConvertCost(), RailNoLevelCrossings(), RAILTYPE_ELECTRIC, RAILTYPE_RAIL, RemoveFirstTrack(), SetRailType(), 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.
tile | start tile of drag |
flags | operation to perform |
p1 | end tile of drag |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 856 of file rail_cmd.cpp.
References CommandCost::AddCost(), CMD_BUILD_SINGLE_RAIL, CMD_ERROR, CMD_REMOVE_SINGLE_RAIL, DoCommand(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetErrorMessage(), HasBit(), IsDiagonalTrackdir(), MapSize(), ToggleBit(), ToTileIndexDiff(), TrackdirToTrack(), TrackToTrackdir(), and ValParamRailtype().
Referenced by CmdBuildRailroadTrack(), and CmdRemoveRailroadTrack().
CommandCost CmdRemoveRailroadTrack | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build rail on a stretch of track.
Stub for the unified rail builder/remover
tile | start tile of drag |
flags | operation to perform |
p1 | end tile of drag |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 935 of file rail_cmd.cpp.
References CmdRailTrackHelper(), and SetBit().
CommandCost CmdRemoveSignalTrack | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Remove signals on a stretch of track.
Stub for the unified signal builder/remover
tile | start tile of drag |
flags | operation to perform |
p1 | end tile of drag |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 1512 of file rail_cmd.cpp.
References CmdSignalTrackHelper(), and SetBit().
CommandCost CmdRemoveSingleRail | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Remove a single piece of track.
tile | tile to remove track from |
flags | operation to perform |
p1 | unused |
p2 | rail orientation |
text | unused |
Definition at line 598 of file rail_cmd.cpp.
References _current_company, CommandCost::AddCost(), AddTrackToSignalBuffer(), CheckTileOwnership(), CMD_ERROR, CMD_REMOVE_SIGNALS, CountBits(), DC_BANKRUPT, DC_EXEC, DeleteNewGRFInspectWindow(), DirtyCompanyInfrastructureWindows(), DoCommand(), EnsureNoTrainOnTrack(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), FreeTrainTrackReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCrossingRailBits(), GetCrossingRoadBits(), GetRailReservationTrackBits(), GetRailType(), GetRoadOwner(), GetRoadTypes(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), GetTrainForReservation(), HasReservedTracks(), HasSignalOnTrack(), INVALID_OWNER, 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(), return_cmd_error, ROADTYPE_ROAD, ROADTYPE_TRAM, SetTrackBits(), SetTrackReservation(), TRACK_BIT_X, TRACK_BIT_Y, TRACK_X, TRACK_Y, TracksOverlap(), TrackToTrackBits(), TryPathReserve(), and YapfNotifyTrackLayoutChange().
CommandCost CmdRemoveSingleSignal | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Remove signals.
tile | coordinates where signal is being deleted from |
flags | operation to perform |
p1 | various bitstuffed elements, only track information is used
|
p2 | unused |
text | unused |
Definition at line 1437 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, return_cmd_error, ReverseTrackdir(), SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SignalOnTrack(), TileAddByDiagDir(), TrackBitsToTrack(), TrackdirBitsToTrackBits(), TrackdirReachesTrackdirs(), TrackdirToExitdir(), TrackToTrackBits(), TrackToTrackdir(), TryPathReserve(), and YapfNotifyTrackLayoutChange().
|
static |
Build many signals by dragging; AutoSignals.
tile | start tile of drag |
flags | operation to perform |
p1 | end tile of drag |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 1250 of file rail_cmd.cpp.
References CommandCost::AddCost(), ClrBit(), CMD_BUILD_SIGNALS, CMD_ERROR, CMD_REMOVE_SIGNALS, DC_EXEC, DoCommand(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GB(), CommandCost::GetErrorMessage(), GetPresentSignals(), HasBit(), HasSignalOnTrack(), HasTrack(), INVALID_STRING_ID, INVALID_TILE, INVALID_TRACKDIR, IsDiagonalTrackdir(), IsPlainRailTile(), MapSize(), return_cmd_error, SB(), SetBit(), SIG_ELECTRIC, SignalAgainstTrackdir(), SignalAlongTrackdir(), SignalOnTrack(), SIGTYPE_ENTRY, SIGTYPE_EXIT, SIGTYPE_NORMAL, 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 120 of file rail_cmd.cpp.
References GetRailTypeInfo(), and RailtypeInfo::sorting_order.
Referenced by InitRailTypes().
Draw ground sprite and track bits.
ti | TileInfo |
track | TrackBits to draw |
Definition at line 2208 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_RIGHT, TRACK_BIT_UPPER, TRACK_BIT_VERT, TRACK_BIT_Y, RailtypeInfo::track_ns, and RailtypeInfo::track_y.
|
static |
Draw track fences.
ti | Tile drawing information. |
rti | Rail type information. |
Definition at line 1994 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 1935 of file rail_cmd.cpp.
References 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().
|
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(), 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 741 of file rail_cmd.cpp.
References _current_company, ApplyFoundationToSlope(), CMD_REMOVE_SINGLE_RAIL, CornerToTrackBits(), DC_EXEC, DoCommand(), FIND_FIRST_BIT, GetHighestSlopeCorner(), GetRailFoundation(), GetTileSlope(), GetTrackBits(), IsNonContinuousFoundation(), IsPlainRailTile(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), MakeShore(), MarkTileDirtyByTile(), OppositeCorner(), OWNER_WATER, RAIL_GROUND_WATER, Backup< T >::Restore(), and CommandCost::Succeeded().
Referenced by DoFloodTile().
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 320 of file rail_cmd.cpp.
References 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(), DrawCatenaryRailway(), 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 1843 of file rail_cmd.cpp.
References TRACK_LEFT, TRACK_LOWER, TRACK_RIGHT, and TRACK_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 2934 of file rail_cmd.cpp.
References _settings_game, CommandCost::AddCost(), ApplyFoundationToSlope(), AutoslopeEnabled(), ConstructionSettings::build_on_slopes, CheckRailSlope(), GameSettings::construction, EXPENSES_CONSTRUCTION, GetRailFoundation(), GetSlopeZInCorner(), IsSlopeWithOneCornerRaised(), RAIL_GROUND_BARREN, RAIL_GROUND_WATER, RemoveHalftileSlope(), return_cmd_error, and TRACK_BIT_NONE.
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 2854 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 |
Tile callback routine when vehicle enters tile.
Definition at line 2874 of file rail_cmd.cpp.
References AXIS_X, Train::CalcNextVehicleOffset(), DiagDirToAxis(), DiagDirToDir(), Vehicle::direction, SpecializedVehicle< T, Type >::First(), SpecializedVehicle< Train, Type >::From(), GetRailDepotDirection(), InvalidateWindowData(), IsRailDepotTile(), SpecializedVehicle< T, Type >::Next(), ReverseDiagDir(), ReverseDir(), Vehicle::tile, TRACK_BIT_DEPOT, 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 2842 of file rail_cmd.cpp.
|
static |
Offsets for drawing fences.
Definition at line 1909 of file rail_cmd.cpp.
|
static |
Definition at line 2044 of file rail_cmd.cpp.
const TileTypeProcs _tile_type_rail_procs |
|
static |
Definition at line 181 of file rail_cmd.cpp.
|
static |
Definition at line 786 of file rail_cmd.cpp.
|
static |
Valid TrackBits on a specific (non-steep)-slope with leveled foundation.
Definition at line 292 of file rail_cmd.cpp.
|
static |
Valid TrackBits on a specific (non-steep)-slope without foundation.
Definition at line 270 of file rail_cmd.cpp.