#include "stdafx.h"
#include "gui.h"
#include "articulated_vehicles.h"
#include "command_func.h"
#include "pathfinder/npf/npf_func.h"
#include "pathfinder/yapf/yapf.hpp"
#include "pathfinder/follow_track.hpp"
#include "openttd.h"
#include "news_func.h"
#include "company_func.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
#include "newgrf_text.h"
#include "group.h"
#include "table/sprites.h"
#include "strings_func.h"
#include "functions.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "autoreplace_gui.h"
#include "gfx_func.h"
#include "ai/ai.hpp"
#include "newgrf_station.h"
#include "effectvehicle_func.h"
#include "gamelog.h"
#include "network/network.h"
#include "spritecache.h"
#include "table/strings.h"
#include "table/train_cmd.h"
Go to the source code of this file.
Data Structures | |
| class | VehicleOrderSaver |
| This class will save the current order of a vehicle and restore it on destruction. More... | |
| struct | RailtypeSlowdownParams |
| struct | TrainCollideChecker |
Defines | |
| #define | MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0) |
Typedefs | |
| typedef SmallVector< Train *, 16 > | TrainList |
| Helper type for lists/vectors of trains. | |
Enumerations | |
| enum | AccelType { AM_ACCEL, AM_BRAKE } |
Functions | |
| static Track | ChooseTrainTrack (Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool force_res, bool *got_reservation, bool mark_stuck) |
| static bool | TrainCheckIfLineEnds (Train *v) |
| Checks for line end. | |
| static void | TrainController (Train *v, Vehicle *nomove) |
| static TileIndex | TrainApproachingCrossingTile (const Train *v) |
| Determines whether train is approaching a rail-road crossing (thus making it barred). | |
| static void | CheckIfTrainNeedsService (Train *v) |
| static void | CheckNextTrainTile (Train *v) |
| Check if the train is on the last reserved tile and try to extend the path then. | |
| static DiagDirection | TrainExitDir (Direction direction, TrackBits track) |
| Determine the side in which the train will leave the tile. | |
| byte | FreightWagonMult (CargoID cargo) |
| Return the cargo weight multiplier to use for a rail vehicle. | |
| void | TrainPowerChanged (Train *v) |
| Recalculates the cached total power of a train. | |
| static void | TrainCargoChanged (Train *v) |
| Recalculates the cached weight of a train and its vehicles. | |
| static void | RailVehicleLengthChanged (const Train *u) |
| Logs a bug in GRF and shows a warning message if this is for the first time this happened. | |
| void | CheckTrainsLengths () |
| Checks if lengths of all rail vehicles are valid. | |
| void | TrainConsistChanged (Train *v, bool same_length) |
| Recalculates the cached stuff of a train. | |
| int | GetTrainStopLocation (StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length) |
| Get the stop location of (the center) of the front vehicle of a train at a platform of a station. | |
| int | GetTrainCurveSpeedLimit (Train *v) |
| Computes train speed limit caused by curves. | |
| static int | GetTrainAcceleration (Train *v, bool mode) |
| new acceleration | |
| void | UpdateTrainAcceleration (Train *v) |
| static SpriteID | GetDefaultTrainSprite (uint8 spritenum, Direction direction) |
| static SpriteID | GetRailIcon (EngineID engine, bool rear_head, int &y) |
| void | DrawTrainEngine (int left, int right, int preferred_x, int y, EngineID engine, SpriteID pal) |
| static CommandCost | CmdBuildRailWagon (EngineID engine, TileIndex tile, DoCommandFlag flags) |
| static void | NormalizeTrainVehInDepot (const Train *u) |
| Move all free vehicles in the depot to the train. | |
| static void | AddRearEngineToMultiheadedTrain (Train *v) |
| CommandCost | CmdBuildRailVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Build a railroad vehicle. | |
| static Train * | FindGoodVehiclePos (const Train *src) |
| static void | MakeTrainBackup (TrainList &list, Train *t) |
| Make a backup of a train into a train list. | |
| static void | RestoreTrainBackup (TrainList &list) |
| Restore the train from the backup list. | |
| static void | RemoveFromConsist (Train *part, bool chain=false) |
| Remove the given wagon from it's consist. | |
| static void | InsertInConsist (Train *dst, Train *chain) |
| Inserts a chain into the train at dst. | |
| static void | NormaliseDualHeads (Train *t) |
| Normalise the dual heads in the train, i.e. | |
| static void | NormaliseSubtypes (Train *chain) |
| Normalise the sub types of the parts in this chain. | |
| static CommandCost | CheckNewTrain (Train *original_dst, Train *dst, Train *original_src, Train *src) |
| Check/validate whether we may actually build a new train. | |
| static CommandCost | CheckTrainAttachment (Train *t) |
| Check whether the train parts can be attached. | |
| static CommandCost | ValidateTrains (Train *original_dst, Train *dst, Train *original_src, Train *src) |
| Validate whether we are going to create valid trains. | |
| static void | ArrangeTrains (Train **dst_head, Train *dst, Train **src_head, Train *src, bool move_chain) |
| Arrange the trains in the wanted way. | |
| static void | NormaliseTrainHead (Train *head) |
| Normalise the head of the train again, i.e. | |
| CommandCost | CmdMoveRailVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Move a rail vehicle around inside the depot. | |
| CommandCost | CmdSellRailWagon (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Sell a (single) train wagon/engine. | |
| static void | SetLastSpeed (Train *v, int spd) |
| static void | MarkTrainAsStuck (Train *v) |
| Mark a train as stuck and stop it if it isn't stopped right now. | |
| static void | SwapTrainFlags (uint16 *swap_flag1, uint16 *swap_flag2) |
| static void | ReverseTrainSwapVeh (Train *v, int l, int r) |
| static Vehicle * | TrainOnTileEnum (Vehicle *v, void *) |
| Check if the vehicle is a train. | |
| static Vehicle * | TrainApproachingCrossingEnum (Vehicle *v, void *data) |
| Checks if a train is approaching a rail-road crossing. | |
| static bool | TrainApproachingCrossing (TileIndex tile) |
| Finds a vehicle approaching rail-road crossing. | |
| void | UpdateLevelCrossing (TileIndex tile, bool sound) |
| Sets correct crossing state. | |
| static void | MaybeBarCrossingWithSound (TileIndex tile) |
| Bars crossing and plays ding-ding sound if not barred already. | |
| static void | AdvanceWagonsBeforeSwap (Train *v) |
| Advances wagons for train reversing, needed for variable length wagons. | |
| static void | AdvanceWagonsAfterSwap (Train *v) |
| Advances wagons for train reversing, needed for variable length wagons. | |
| static void | ReverseTrainDirection (Train *v) |
| CommandCost | CmdReverseTrainDirection (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Reverse train. | |
| CommandCost | CmdForceTrainProceed (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Force a train through a red signal. | |
| CommandCost | CmdRefitRailVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Refits a train to the specified cargo type. | |
| static FindDepotData | FindClosestTrainDepot (Train *v, int max_distance) |
| returns the tile of a depot to goto to. | |
| CommandCost | CmdSendTrainToDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Send a train to a depot. | |
| static void | HandleLocomotiveSmokeCloud (const Train *v) |
| static bool | CheckTrainStayInDepot (Train *v) |
| static void | ClearPathReservation (const Train *v, TileIndex tile, Trackdir track_dir) |
| Clear the reservation of a tile that was just left by a wagon on track_dir. | |
| void | FreeTrainTrackReservation (const Train *v, TileIndex origin, Trackdir orig_td) |
| Free the reserved path in front of a vehicle. | |
| static Track | DoTrainPathfind (const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool do_track_reservation, PBSTileInfo *dest) |
| Perform pathfinding for a train. | |
| static PBSTileInfo | ExtendTrainReservation (const Train *v, TrackBits *new_tracks, DiagDirection *enterdir) |
| Extend a train path as far as possible. | |
| static bool | TryReserveSafeTrack (const Train *v, TileIndex tile, Trackdir td, bool override_tailtype) |
| Try to reserve any path to a safe tile, ignoring the vehicle's destination. | |
| bool | TryPathReserve (Train *v, bool mark_as_stuck, bool first_tile_okay) |
| Try to reserve a path to a safe position. | |
| static bool | CheckReverseTrain (const Train *v) |
| static int | UpdateTrainSpeed (Train *v) |
| This function looks at the vehicle and updates it's speed (cur_speed and subspeed) variables. | |
| static void | TrainEnterStation (Train *v, StationID station) |
| static byte | AfterSetTrainPos (Train *v, bool new_tile) |
| static bool | CheckCompatibleRail (const Train *v, TileIndex tile) |
| static void | AffectSpeedByZChange (Train *v, byte old_z) |
| Modify the speed of the vehicle due to a change in altitude. | |
| static bool | TrainMovedChangeSignals (TileIndex tile, DiagDirection dir) |
| static uint | TrainCrashed (Train *v) |
| Marks train as crashed and creates an AI event. | |
| static Vehicle * | FindTrainCollideEnum (Vehicle *v, void *data) |
| static bool | CheckTrainCollision (Train *v) |
| Checks whether the specified train has a collision with another vehicle. | |
| static Vehicle * | CheckTrainAtSignal (Vehicle *v, void *data) |
| static Vehicle * | CollectTrackbitsFromCrashedVehiclesEnum (Vehicle *v, void *data) |
| Collect trackbits of all crashed train vehicles on a tile. | |
| static void | DeleteLastWagon (Train *v) |
| Deletes/Clears the last wagon of a crashed train. | |
| static void | ChangeTrainDirRandomly (Train *v) |
| static bool | HandleCrashedTrain (Train *v) |
| static void | HandleBrokenTrain (Train *v) |
| static bool | TrainApproachingLineEnd (Train *v, bool signal) |
| Train is approaching line end, slow down and possibly reverse. | |
| static bool | TrainCanLeaveTile (const Train *v) |
| Determines whether train would like to leave the tile. | |
| static bool | TrainLocoHandler (Train *v, bool mode) |
Variables | |
| static const byte | _vehicle_initial_x_fract [4] = {10, 8, 4, 8} |
| static const byte | _vehicle_initial_y_fract [4] = { 8, 4, 8, 10} |
| static const int8 | _vehicle_smoke_pos [8] |
| static const byte | _initial_tile_subcoord [6][4][3] |
| static const RailtypeSlowdownParams | _railtype_slowdown [] |
| static const uint16 | _breakdown_speeds [16] |
| Maximum speeds for train that is broken down or approaching line end. | |
Definition in file train_cmd.cpp.
| static void AdvanceWagonsAfterSwap | ( | Train * | v | ) | [static] |
Advances wagons for train reversing, needed for variable length wagons.
This one is called after the train is reversed.
| v | First vehicle in chain |
Definition at line 1828 of file train_cmd.cpp.
References TrainCache::cached_veh_length, GetRailDepotTrack(), SpecializedVehicle< T, Type >::Last(), SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< T, Type >::Previous(), Train::tcache, TicksToLeaveDepot(), Train::track, TRACK_BIT_DEPOT, and TrackToTrackBits().
| static void AdvanceWagonsBeforeSwap | ( | Train * | v | ) | [static] |
Advances wagons for train reversing, needed for variable length wagons.
This one is called before the train is reversed.
| v | First vehicle in chain |
Definition at line 1800 of file train_cmd.cpp.
References TrainCache::cached_veh_length, SpecializedVehicle< T, Type >::Last(), SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< T, Type >::Previous(), and Train::tcache.
| static void ArrangeTrains | ( | Train ** | dst_head, | |
| Train * | dst, | |||
| Train ** | src_head, | |||
| Train * | src, | |||
| bool | move_chain | |||
| ) | [static] |
Arrange the trains in the wanted way.
| dst_head | The destination chain of the to be moved vehicle. | |
| dst | The destination for the to be moved vehicle. | |
| src_head | The source chain of the to be moved vehicle. | |
| src | The to be moved vehicle. | |
| move_chain | Whether to move all vehicles after src or not. |
Definition at line 1245 of file train_cmd.cpp.
References Train::GetNextUnit(), Train::GetNextVehicle(), InsertInConsist(), Train::IsMultiheaded(), NormaliseDualHeads(), and RemoveFromConsist().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
| static CommandCost CheckNewTrain | ( | Train * | original_dst, | |
| Train * | dst, | |||
| Train * | original_src, | |||
| Train * | src | |||
| ) | [static] |
Check/validate whether we may actually build a new train.
| original_dst | The original destination chain. | |
| dst | The destination chain after constructing the train. | |
| original_dst | The original source chain. | |
| dst | The source chain after constructing the train. |
Definition at line 1123 of file train_cmd.cpp.
References _settings_game, Train::IsEngine(), VehicleSettings::max_trains, return_cmd_error, VEH_TRAIN, and GameSettings::vehicle.
Referenced by ValidateTrains().
| static void CheckNextTrainTile | ( | Train * | v | ) | [static] |
Check if the train is on the last reserved tile and try to extend the path then.
Definition at line 2251 of file train_cmd.cpp.
References _settings_game, FindFirstTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), PathfinderSettings::forbid_90_deg, GetSignalStateByTrackdir(), GetStationIndex(), Train::GetVehicleTrackdir(), HasPbsSignalOnTrackdir(), HasReservedTracks(), HasSignalOnTrackdir(), IsRailStationTile(), IsTileType(), KillFirstBit(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_exitdir, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_old_td, MP_RAILWAY, PathfinderSettings::path_backoff_interval, GameSettings::pf, SIGNAL_STATE_RED, Train::track, TRACK_BIT_DEPOT, TrackCrossesTracks(), TRACKDIR_BIT_NONE, TrackdirBitsToTrackBits(), and TrackdirToTrack().
| static CommandCost CheckTrainAttachment | ( | Train * | t | ) | [static] |
Check whether the train parts can be attached.
| t | the train to check |
Definition at line 1147 of file train_cmd.cpp.
References _settings_game, CALLBACK_FAILED, CBID_TRAIN_ALLOW_WAGON_ATTACH, error(), TrainCache::first_engine, GetEngineGRFID(), GetGRFStringID(), GetVehicleCallbackParent(), Train::IsArticulatedPart(), Train::IsEngine(), Train::IsRearDualheaded(), VehicleSettings::mammoth_trains, SpecializedVehicle< T, Type >::Next(), return_cmd_error, Train::tcache, and GameSettings::vehicle.
Referenced by ValidateTrains().
| static bool CheckTrainCollision | ( | Train * | v | ) | [static] |
Checks whether the specified train has a collision with another vehicle.
If so, destroys this vehicle, and the other vehicle if its subtype has TS_Front. Reports the incident in a flashy news item, modifies station ratings and plays a sound.
Definition at line 3248 of file train_cmd.cpp.
References AddVehicleNewsItem(), FindVehicleOnPos(), FindVehicleOnPosXY(), GetOtherTunnelBridgeEnd(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, NS_ACCIDENT, SetDParam(), Train::track, TRACK_BIT_DEPOT, and TRACK_BIT_WORMHOLE.
| void CheckTrainsLengths | ( | ) |
Checks if lengths of all rail vehicles are valid.
If not, shows an error message.
Definition at line 191 of file train_cmd.cpp.
References abs(), CMD_PAUSE, DoCommandP(), SpecializedVehicle< T, Type >::First(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_STRING_ID, max(), SpecializedVehicle< T, Type >::Next(), PM_PAUSED_ERROR, SetDParam(), ShowErrorMessage(), TicksToLeaveDepot(), and TRACK_BIT_DEPOT.
Referenced by InitializeWindowsAndCaches(), and ReloadNewGRFData().
Clear the reservation of a tile that was just left by a wagon on track_dir.
Definition at line 2364 of file train_cmd.cpp.
References _settings_client, GetOtherTunnelBridgeEnd(), GetTunnelBridgeDirection(), ClientSettings::gui, HasVehicleOnTunnelBridge(), IsRailStationTile(), IsTileType(), MarkTileDirtyByTile(), MP_TUNNELBRIDGE, ReverseDiagDir(), SetRailStationPlatformReservation(), SetTunnelBridgeReservation(), GUISettings::show_track_reservation, TileAddByDiagDir(), TrackdirToExitdir(), TrackdirToTrack(), and UnreserveRailTrack().
| CommandCost CmdBuildRailVehicle | ( | TileIndex | tile, | |
| DoCommandFlag | flags, | |||
| uint32 | p1, | |||
| uint32 | p2, | |||
| const char * | text | |||
| ) |
Build a railroad vehicle.
| tile | tile of the depot where rail-vehicle is built | |
| flags | type of operation | |
| p1 | engine type id | |
| p2 | bit 1 prevents any free cars from being added to the train | |
| text | unused |
Definition at line 836 of file train_cmd.cpp.
References _cur_year, _date, _settings_game, CheckConsistencyOfArticulatedVehicle(), CMD_ERROR, CT_INVALID, DC_AUTOREPLACE, DEFAULT_GROUP, DiagDirToDir(), ENGINE_EXCLUSIVE_PREVIEW, TrainCache::first_engine, GetRailDepotDirection(), GetRailType(), HasBit(), HasPowerOnRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateAutoreplaceWindow(), InvalidateWindowClassesData(), InvalidateWindowData(), IsEngineBuildable(), IsRailDepotTile(), IsTileOwner(), VehicleSettings::max_trains, NormalizeTrainVehInDepot(), Train::railtype, RAILVEH_MULTIHEAD, RAILVEH_WAGON, return_cmd_error, SetBit(), Train::SetEngine(), Train::SetFrontEngine(), SetWindowDirty(), Train::tcache, TILE_SIZE, TileX(), TileY(), Train::track, TRACK_BIT_DEPOT, Train::Train(), TrainConsistChanged(), UpdateTrainGroupID(), VEH_TRAIN, GameSettings::vehicle, VehicleMove(), and VehicleRandomBits().
| CommandCost CmdForceTrainProceed | ( | TileIndex | tile, | |
| DoCommandFlag | flags, | |||
| uint32 | p1, | |||
| uint32 | p2, | |||
| const char * | text | |||
| ) |
Force a train through a red signal.
| tile | unused | |
| flags | type of operation | |
| p1 | train to ignore the red signal | |
| p2 | unused | |
| text | unused |
Definition at line 2038 of file train_cmd.cpp.
References CMD_ERROR, Train::flags, Train::force_proceed, SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsInDepot(), and SetWindowDirty().
| CommandCost CmdMoveRailVehicle | ( | TileIndex | tile, | |
| DoCommandFlag | flags, | |||
| uint32 | p1, | |||
| uint32 | p2, | |||
| const char * | text | |||
| ) |
Move a rail vehicle around inside the depot.
| tile | unused | |
| flags | type of operation Note: DC_AUTOREPLACE is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot. | |
| p1 | various bitstuffed elements
| |
| p2 | (bit 0) move all vehicles following the source vehicle | |
| text | unused |
Definition at line 1318 of file train_cmd.cpp.
References ArrangeTrains(), CMD_ERROR, DC_AUTOREPLACE, DEFAULT_GROUP, DeleteVehicleOrders(), DeleteWindowById(), CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), GB(), Train::GetFirstEnginePart(), SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), Train::GetLastEnginePart(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, InvalidateWindowClassesData(), InvalidateWindowData(), Train::IsEngine(), Train::IsFrontEngine(), Train::IsRearDualheaded(), Train::IsStoppedInDepot(), MakeTrainBackup(), NormaliseSubtypes(), NormaliseTrainHead(), Train::other_multiheaded_part, RemoveVehicleFromGroup(), RestoreTrainBackup(), return_cmd_error, SetTrainGroupID(), and ValidateTrains().
| CommandCost CmdRefitRailVehicle | ( | TileIndex | tile, | |
| DoCommandFlag | flags, | |||
| uint32 | p1, | |||
| uint32 | p2, | |||
| const char * | text | |||
| ) |
Refits a train to the specified cargo type.
| tile | unused | |
| flags | type of operation | |
| p1 | vehicle ID of the train to refit | |
| p2 | various bitstuffed elements
| |
| text | unused |
Definition at line 2067 of file train_cmd.cpp.
References CMD_ERROR, SpecializedVehicle< T, Type >::First(), GB(), SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), Train::IsStoppedInDepot(), NUM_CARGO, RefitVehicle(), return_cmd_error, SetWindowDirty(), and TrainConsistChanged().
| CommandCost CmdReverseTrainDirection | ( | TileIndex | tile, | |
| DoCommandFlag | flags, | |||
| uint32 | p1, | |||
| uint32 | p2, | |||
| const char * | text | |||
| ) |
Reverse train.
| tile | unused | |
| flags | type of operation | |
| p1 | train to reverse | |
| p2 | if true, reverse a unit in a train (needs to be in a depot) | |
| text | unused |
Definition at line 1971 of file train_cmd.cpp.
References _settings_game, CBM_VEHICLE_ARTIC_ENGINE, CMD_ERROR, SpecializedVehicle< T, Type >::First(), Train::flags, Train::force_proceed, SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), GetStationIndex(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsMultiheaded(), Train::IsStoppedInDepot(), IsTileType(), MP_STATION, SpecializedVehicle< T, Type >::Next(), return_cmd_error, SetWindowDirty(), ToggleBit(), VehicleSettings::train_acceleration_model, and GameSettings::vehicle.
| CommandCost CmdSellRailWagon | ( | TileIndex | tile, | |
| DoCommandFlag | flags, | |||
| uint32 | p1, | |||
| uint32 | p2, | |||
| const char * | text | |||
| ) |
Sell a (single) train wagon/engine.
| tile | unused | |
| flags | type of operation | |
| p1 | the wagon/engine index | |
| p2 | the selling mode
| |
| text | unused |
Definition at line 1492 of file train_cmd.cpp.
References CommandCost::AddCost(), ArrangeTrains(), CMD_ERROR, DeleteVehicleOrders(), CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), Train::GetFirstEnginePart(), SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), HasBit(), InvalidateWindowClassesData(), InvalidateWindowData(), Train::IsEngine(), Train::IsFrontEngine(), Train::IsRearDualheaded(), Train::IsStoppedInDepot(), MakeTrainBackup(), SpecializedVehicle< T, Type >::Next(), NormaliseSubtypes(), NormaliseTrainHead(), RestoreTrainBackup(), return_cmd_error, ShowVehicleViewWindow(), and ValidateTrains().
| CommandCost CmdSendTrainToDepot | ( | TileIndex | tile, | |
| DoCommandFlag | flags, | |||
| uint32 | p1, | |||
| uint32 | p2, | |||
| const char * | text | |||
| ) |
Send a train to a depot.
| tile | unused | |
| flags | type of operation | |
| p1 | train to send to the depot | |
| p2 | various bitmasked elements
| |
| text | unused |
Definition at line 2139 of file train_cmd.cpp.
References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), SendAllVehiclesToDepot(), and VEH_TRAIN.
| static Vehicle* CollectTrackbitsFromCrashedVehiclesEnum | ( | Vehicle * | v, | |
| void * | data | |||
| ) | [static] |
Collect trackbits of all crashed train vehicles on a tile.
| v | Vehicle passed from Find/HasVehicleOnPos() | |
| data | trackdirbits for the result |
Definition at line 3609 of file train_cmd.cpp.
References DiagDirToDiagTrackBits(), SpecializedVehicle< Train, VEH_TRAIN >::From(), GetTunnelBridgeDirection(), Train::track, TRACK_BIT_WORMHOLE, and VEH_TRAIN.
Referenced by DeleteLastWagon().
| static void DeleteLastWagon | ( | Train * | v | ) | [static] |
Deletes/Clears the last wagon of a crashed train.
It takes the engine of the train, then goes to the last wagon and deletes that. Each call to this function will remove the last wagon of a crashed train. If this wagon was on a crossing, or inside a tunnel/bridge, recalculate the signals as they might need updating
| v | the Vehicle of which last wagon is to be removed |
Definition at line 3632 of file train_cmd.cpp.
References CollectTrackbitsFromCrashedVehiclesEnum(), DiagDirToDiagTrackBits(), FindVehicleOnPos(), SpecializedVehicle< T, Type >::First(), GetTunnelBridgeDirection(), HasBit(), HasReservedTracks(), INVALID_DIAGDIR, IsRailDepotTile(), IsTileType(), MP_TUNNELBRIDGE, SpecializedVehicle< T, Type >::Next(), SetSignalsOnBothDir(), SetWindowDirty(), Train::track, TRACK_BEGIN, TRACK_BIT_DEPOT, TRACK_BIT_NONE, TRACK_BIT_WORMHOLE, TRACK_END, TRACK_X, TRACK_Y, TrackBitsToTrack(), TrainConsistChanged(), TryReserveRailTrack(), UnreserveRailTrack(), UpdateLevelCrossing(), and UpdateSignalsOnSegment().
| static Track DoTrainPathfind | ( | const Train * | v, | |
| TileIndex | tile, | |||
| DiagDirection | enterdir, | |||
| TrackBits | tracks, | |||
| bool * | path_not_found, | |||
| bool | do_track_reservation, | |||
| PBSTileInfo * | dest | |||
| ) | [static] |
Perform pathfinding for a train.
| v | The train | |
| tile | The tile the train is about to enter | |
| enterdir | Diagonal direction the train is coming from | |
| tracks | Usable tracks on the new tile | |
| path_not_found | [out] Set to false if the pathfinder couldn't find a way to the destination | |
| do_track_reservation | Path reservation is requested | |
| dest | [out] State and destination of the requested path |
Definition at line 2467 of file train_cmd.cpp.
References _settings_game, NPFTrainChooseTrack(), PathfinderSettings::pathfinder_for_trains, GameSettings::pf, VPF_NPF, VPF_YAPF, and YapfTrainChooseTrack().
| static PBSTileInfo ExtendTrainReservation | ( | const Train * | v, | |
| TrackBits * | new_tracks, | |||
| DiagDirection * | enterdir | |||
| ) | [static] |
Extend a train path as far as possible.
Stops on encountering a safe tile, another reservation or a track choice.
Definition at line 2482 of file train_cmd.cpp.
References _settings_game, FindFirstTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), FollowTrainReservation(), PathfinderSettings::forbid_90_deg, HasOnewaySignalBlockingTrackdir(), HasReservedTracks(), IsPlainRail(), IsSafeWaitingPosition(), IsTileType(), IsWaitingPositionFree(), KillFirstBit(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_err, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_exitdir, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_is_station, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_old_td, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_old_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_tiles_skipped, MP_RAILWAY, GameSettings::pf, PBSTileInfo::tile, TileOffsByDiagDir(), PBSTileInfo::trackdir, TRACKDIR_BIT_NONE, TrackdirBitsToTrackBits(), TrackdirCrossesTrackdirs(), TrackdirReachesTrackdirs(), TrackdirToTrack(), TryReserveRailTrack(), and UnreserveRailTrack().
| static FindDepotData FindClosestTrainDepot | ( | Train * | v, | |
| int | max_distance | |||
| ) | [static] |
returns the tile of a depot to goto to.
The given vehicle must not be crashed!
Definition at line 2100 of file train_cmd.cpp.
References _settings_game, FollowTrainReservation(), IsRailDepotTile(), NPFTrainFindNearestDepot(), PathfinderSettings::pathfinder_for_trains, GameSettings::pf, PBSTileInfo::tile, VPF_NPF, VPF_YAPF, and YapfTrainFindNearestDepot().
Free the reserved path in front of a vehicle.
Definition at line 2398 of file train_cmd.cpp.
References ClearPathReservation(), RailtypeInfo::compatible_railtypes, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetRailTypeInfo(), GetReservedTrackbits(), GetSignalStateByTrackdir(), GetStationIndex(), Train::GetVehicleTrackdir(), HasPbsSignalOnTrackdir(), HasSignalOnTrackdir(), INVALID_TILE, INVALID_TRACKDIR, Train::IsFrontEngine(), IsOnewaySignal(), IsRailStationTile(), IsTileType(), IsValidTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_is_bridge, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_is_station, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_is_tunnel, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_tile, MarkTileDirtyByTile(), MP_RAILWAY, MP_TUNNELBRIDGE, Train::railtype, RemoveFirstTrackdir(), ReverseTrackdir(), SetSignalStateByTrackdir(), SIGNAL_STATE_RED, TrackBitsToTrackdirBits(), TRACKDIR_BIT_NONE, TrackdirToTrack(), TracksOverlap(), TrackToTrackBits(), and UnreserveRailTrack().
Referenced by CmdBuildRailStation(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), RemoveFromRailBaseStation(), and RemoveRailStation().
| byte FreightWagonMult | ( | CargoID | cargo | ) |
Return the cargo weight multiplier to use for a rail vehicle.
| cargo | Cargo type to get multiplier for |
Definition at line 82 of file train_cmd.cpp.
References _settings_game, VehicleSettings::freight_trains, CargoSpec::Get(), and GameSettings::vehicle.
Referenced by DrawTrainDetails(), TrainCargoChanged(), TrainDetailsCapacityTab(), and TrainDetailsCargoTab().
| int GetTrainCurveSpeedLimit | ( | Train * | v | ) |
Computes train speed limit caused by curves.
| v | first vehicle of consist |
Definition at line 417 of file train_cmd.cpp.
References _settings_game, TrainCache::cached_tilt, Clamp(), RailtypeInfo::curve_speed, DIRDIFF_45LEFT, DIRDIFF_45RIGHT, DIRDIFF_90LEFT, DIRDIFF_90RIGHT, DIRDIFF_SAME, DirDifference(), GetRailTypeInfo(), SpecializedVehicle< T, Type >::Next(), Train::railtype, Train::tcache, VehicleSettings::train_acceleration_model, and GameSettings::vehicle.
Referenced by GetTrainAcceleration(), and TrainConsistChanged().
| int GetTrainStopLocation | ( | StationID | station_id, | |
| TileIndex | tile, | |||
| const Train * | v, | |||
| int * | station_ahead, | |||
| int * | station_length | |||
| ) |
Get the stop location of (the center) of the front vehicle of a train at a platform of a station.
| station_id | the ID of the station where we're stopping | |
| tile | the tile where the vehicle currently is | |
| v | the vehicle to get the stop location of | |
| station_ahead | 'return' the amount of 1/16th tiles in front of the train | |
| station_length | 'return' the station length in 1/16th tiles |
Definition at line 372 of file train_cmd.cpp.
References TrainCache::cached_total_length, TrainCache::cached_veh_length, DirToDiagDir(), SpecializedStation< Station, false >::Get(), Station::GetPlatformLength(), OSL_PLATFORM_FAR_END, OSL_PLATFORM_MIDDLE, OSL_PLATFORM_NEAR_END, Train::tcache, and TILE_SIZE.
Referenced by GetTrainAcceleration().
Inserts a chain into the train at dst.
| dst | the place where to append after. | |
| chain | the chain to actually add. |
Definition at line 1055 of file train_cmd.cpp.
References Train::IsArticulatedPart(), SpecializedVehicle< T, Type >::Last(), and SpecializedVehicle< T, Type >::Next().
Referenced by ArrangeTrains(), and NormaliseDualHeads().
Make a backup of a train into a train list.
| list | to make the backup in | |
| t | the train to make the backup of |
Definition at line 1005 of file train_cmd.cpp.
References SmallVector< T, S >::Append(), and SpecializedVehicle< T, Type >::Next().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
| static void MarkTrainAsStuck | ( | Train * | v | ) | [static] |
Mark a train as stuck and stop it if it isn't stopped right now.
Definition at line 1610 of file train_cmd.cpp.
References Train::flags, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, SetBit(), and SetWindowWidgetDirty().
Referenced by TryPathReserve().
| static void MaybeBarCrossingWithSound | ( | TileIndex | tile | ) | [inline, static] |
Bars crossing and plays ding-ding sound if not barred already.
| tile | tile with crossing |
Definition at line 1785 of file train_cmd.cpp.
References MarkTileDirtyByTile().
Referenced by TrainCheckIfLineEnds().
| static void NormaliseDualHeads | ( | Train * | t | ) | [static] |
Normalise the dual heads in the train, i.e.
if one is missing move that one to this train.
| t | the train to normalise. |
Definition at line 1069 of file train_cmd.cpp.
References Train::GetNextVehicle(), InsertInConsist(), Train::IsEngine(), Train::IsMultiheaded(), SpecializedVehicle< T, Type >::Next(), Train::other_multiheaded_part, and RemoveFromConsist().
Referenced by ArrangeTrains().
| static void NormaliseSubtypes | ( | Train * | chain | ) | [static] |
Normalise the sub types of the parts in this chain.
| chain | the chain to normalise. |
Definition at line 1091 of file train_cmd.cpp.
References Train::ClearFreeWagon(), Train::ClearFrontEngine(), Train::IsEngine(), Train::IsWagon(), SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< T, Type >::Previous(), Train::SetFreeWagon(), and Train::SetFrontEngine().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
| static void NormaliseTrainHead | ( | Train * | head | ) | [static] |
Normalise the head of the train again, i.e.
that is tell the world that we have changed and update all kinds of variables.
| head | the train to update. |
Definition at line 1286 of file train_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsFrontEngine(), SetWindowDirty(), SetWindowWidgetDirty(), TrainConsistChanged(), UpdateTrainGroupID(), and VEH_TRAIN.
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
| static void RailVehicleLengthChanged | ( | const Train * | u | ) | [static] |
Logs a bug in GRF and shows a warning message if this is for the first time this happened.
| u | first vehicle of chain |
Definition at line 179 of file train_cmd.cpp.
References GamelogGRFBugReverse(), GBUG_VEH_LENGTH, GRFConfig::grf_bugs, HasBit(), and ShowNewGrfVehicleError().
Referenced by TrainConsistChanged().
| static void RemoveFromConsist | ( | Train * | part, | |
| bool | chain = false | |||
| ) | [static] |
Remove the given wagon from it's consist.
| part | the part of the train to remove. | |
| chain | whether to remove the whole chain. |
Definition at line 1038 of file train_cmd.cpp.
References Train::GetLastEnginePart(), SpecializedVehicle< T, Type >::Last(), SpecializedVehicle< T, Type >::Next(), and SpecializedVehicle< T, Type >::Previous().
Referenced by ArrangeTrains(), and NormaliseDualHeads().
| static void RestoreTrainBackup | ( | TrainList & | list | ) | [static] |
Restore the train from the backup list.
| list | the train to restore. |
Definition at line 1014 of file train_cmd.cpp.
References SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), SmallVector< T, S >::Length(), and SpecializedVehicle< T, Type >::Previous().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
| static bool TrainApproachingCrossing | ( | TileIndex | tile | ) | [static] |
Finds a vehicle approaching rail-road crossing.
| tile | tile to test |
Definition at line 1741 of file train_cmd.cpp.
References AxisToDiagDir(), HasVehicleOnPos(), ReverseDiagDir(), TileOffsByDiagDir(), and TrainApproachingCrossingEnum().
Referenced by UpdateLevelCrossing().
| static Vehicle* TrainApproachingCrossingEnum | ( | Vehicle * | v, | |
| void * | data | |||
| ) | [static] |
Checks if a train is approaching a rail-road crossing.
| v | vehicle on tile | |
| data | tile with crossing we are testing |
Definition at line 1720 of file train_cmd.cpp.
References SpecializedVehicle< Train, VEH_TRAIN >::From(), Train::IsFrontEngine(), TrainApproachingCrossingTile(), and VEH_TRAIN.
Referenced by TrainApproachingCrossing().
Determines whether train is approaching a rail-road crossing (thus making it barred).
| v | front engine of train |
Definition at line 3869 of file train_cmd.cpp.
References DiagDirToAxis(), INVALID_TILE, Train::IsFrontEngine(), TileOffsByDiagDir(), Train::track, TrainCanLeaveTile(), and TrainExitDir().
Referenced by TrainApproachingCrossingEnum().
| static bool TrainApproachingLineEnd | ( | Train * | v, | |
| bool | signal | |||
| ) | [static] |
Train is approaching line end, slow down and possibly reverse.
| v | front train engine | |
| signal | not line end, just a red signal |
Definition at line 3798 of file train_cmd.cpp.
References TrainCache::cached_veh_length, DIR_E, DIR_N, DIR_NE, DIR_NW, DIR_S, DIR_SE, DIR_W, Train::tcache, and TILE_SIZE.
Referenced by TrainCheckIfLineEnds().
| static bool TrainCanLeaveTile | ( | const Train * | v | ) | [static] |
Determines whether train would like to leave the tile.
| v | train to test |
Definition at line 3839 of file train_cmd.cpp.
References DiagDirToDir(), GetRailDepotDirection(), GetTunnelBridgeDirection(), IsRailDepotTile(), IsTileType(), MP_TUNNELBRIDGE, ReverseDiagDir(), Train::track, TRACK_BIT_DEPOT, and TRACK_BIT_WORMHOLE.
Referenced by TrainApproachingCrossingTile(), and TrainCheckIfLineEnds().
| static void TrainCargoChanged | ( | Train * | v | ) | [static] |
Recalculates the cached weight of a train and its vehicles.
Should be called each time the cargo on the consist changes.
| v | First vehicle of the consist. |
Definition at line 142 of file train_cmd.cpp.
References TrainCache::cached_weight, FreightWagonMult(), CargoSpec::Get(), HasBit(), SpecializedVehicle< T, Type >::Next(), PROP_TRAIN_WEIGHT, Train::tcache, TrainPowerChanged(), and CargoSpec::weight.
Referenced by TrainConsistChanged().
| static bool TrainCheckIfLineEnds | ( | Train * | v | ) | [static] |
Checks for line end.
Also, bars crossing at next tile if needed
| v | vehicle we are checking |
Definition at line 3895 of file train_cmd.cpp.
References _settings_game, DiagdirReachesTrackdirs(), FindFirstTrack(), PathfinderSettings::forbid_90_deg, GB(), GetTileTrackStatus(), MaybeBarCrossingWithSound(), GameSettings::pf, ReverseDiagDir(), TileOffsByDiagDir(), Train::track, TRACK_BIT_NONE, TrackCrossesTracks(), TrackdirBitsToTrackBits(), TrackStatusToRedSignals(), TrackStatusToTrackdirBits(), TrainApproachingLineEnd(), TrainCanLeaveTile(), TrainExitDir(), and TRANSPORT_RAIL.
| void TrainConsistChanged | ( | Train * | v, | |
| bool | same_length | |||
| ) |
Recalculates the cached stuff of a train.
Should be called each time a vehicle is added to/removed from the chain, and when the game is loaded. Note: this needs to be called too for 'wagon chains' (in the depot, without an engine)
| v | First vehicle of the chain. | |
| same_length | should length of vehicles stay the same? |
Definition at line 221 of file train_cmd.cpp.
References _settings_game, TrainCache::cached_max_curve_speed, TrainCache::cached_max_speed, TrainCache::cached_tilt, TrainCache::cached_total_length, CALLBACK_FAILED, CBID_TRAIN_WAGON_POWER, CBID_VEHICLE_LENGTH, CBM_TRAIN_WAGON_POWER, CBM_VEHICLE_LENGTH, Clamp(), ClrBit(), Train::compatible_railtypes, EF_RAIL_TILTS, GB(), GetRailTypeInfo(), GetTrainCurveSpeedLimit(), GetVehicleCallback(), GetVehicleCapacity(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsFreeWagon(), Train::IsFrontEngine(), min(), SpecializedVehicle< T, Type >::Next(), RailtypeInfo::powered_railtypes, PROP_TRAIN_SPEED, PROP_TRAIN_USER_DATA, Train::railtype, RAILTYPE_RAIL, RAILTYPES_NONE, RAILTYPES_RAIL, RAILVEH_WAGON, RailVehicleLengthChanged(), SetBit(), SetWindowDirty(), Train::tcache, TrainCargoChanged(), TrainCache::user_def_data, UsesWagonOverride(), GameSettings::vehicle, and VehicleSettings::wagon_speed_limits.
Referenced by AfterLoadVehicles(), CmdBuildRailVehicle(), CmdRefitRailVehicle(), DeleteLastWagon(), NormaliseTrainHead(), StateGameLoop(), and TransferCargo().
| static uint TrainCrashed | ( | Train * | v | ) | [static] |
Marks train as crashed and creates an AI event.
Doesn't do anything if the train is crashed already.
| v | first vehicle of chain |
Definition at line 3184 of file train_cmd.cpp.
References Train::Crash(), AIEventVehicleCrashed::CRASH_TRAIN, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, and Train::ReserveTrackUnderConsist().
| static DiagDirection TrainExitDir | ( | Direction | direction, | |
| TrackBits | track | |||
| ) | [inline, static] |
Determine the side in which the train will leave the tile.
| direction | vehicle direction | |
| track | vehicle track bits |
Definition at line 63 of file train_cmd.cpp.
References ChangeDiagDir(), DIAGDIR_END, DIAGDIRDIFF_90LEFT, DirToDiagDir(), HasBit(), TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, and TRACK_BIT_UPPER.
Referenced by TrainApproachingCrossingTile(), TrainCheckIfLineEnds(), and TryPathReserve().
| static Vehicle* TrainOnTileEnum | ( | Vehicle * | v, | |
| void * | ||||
| ) | [static] |
Check if the vehicle is a train.
| v | vehicle on tile |
Definition at line 1708 of file train_cmd.cpp.
References VEH_TRAIN.
| void TrainPowerChanged | ( | Train * | v | ) |
Recalculates the cached total power of a train.
Should be called when the consist is changed
| v | First vehicle of the consist. |
Definition at line 93 of file train_cmd.cpp.
References TrainCache::cached_max_te, TrainCache::cached_power, GetRailType(), HasBit(), HasPowerOnRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, SpecializedVehicle< T, Type >::Next(), PROP_TRAIN_POWER, PROP_TRAIN_TRACTIVE_EFFORT, Train::railtype, SetWindowDirty(), SetWindowWidgetDirty(), and Train::tcache.
Referenced by SettingsDisableElrail(), TrainCargoChanged(), and UpdateTrainPowerProc().
| bool TryPathReserve | ( | Train * | v, | |
| bool | mark_as_stuck, | |||
| bool | first_tile_okay | |||
| ) |
Try to reserve a path to a safe position.
| v | The vehicle | |
| mark_as_stuck | Should the train be marked as stuck on a failed reservation? | |
| first_tile_okay | True if no path should be reserved if the current tile is a safe position. |
Definition at line 2843 of file train_cmd.cpp.
References _settings_client, _settings_game, ClrBit(), DiagdirReachesTrackdirs(), DiagdirReachesTracks(), FindFirstTrackdir(), Train::flags, FollowTrainReservation(), PathfinderSettings::forbid_90_deg, GetRailDepotDirection(), GetReservedTrackbits(), GetTileTrackStatus(), ClientSettings::gui, HasBit(), HasDepotReservation(), HasReservedTracks(), HasSignalOnTrackdir(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsFrontEngine(), IsTileType(), MarkTileDirtyByTile(), MarkTrainAsStuck(), MP_RAILWAY, PBSTileInfo::okay, GameSettings::pf, ReverseTrackdir(), SetDepotReservation(), SetWindowWidgetDirty(), GUISettings::show_track_reservation, PBSTileInfo::tile, TileAddByDiagDir(), Train::track, TRACK_BIT_DEPOT, TrackBitsToTrackdirBits(), TrackCrossesTracks(), PBSTileInfo::trackdir, TrackdirBitsToTrackBits(), TrackdirToExitdir(), TrackdirToTrack(), TrackStatusToTrackdirBits(), TrainExitDir(), and TRANSPORT_RAIL.
Referenced by CmdBuildRailStation(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), RemoveFromRailBaseStation(), and RemoveRailStation().
| static bool TryReserveSafeTrack | ( | const Train * | v, | |
| TileIndex | tile, | |||
| Trackdir | td, | |||
| bool | override_tailtype | |||
| ) | [static] |
Try to reserve any path to a safe tile, ignoring the vehicle's destination.
Safe tiles are tiles in front of a signal, depots and station tiles at end of line.
| v | The vehicle. | |
| tile | The tile the search should start from. | |
| td | The trackdir the search should start from. | |
| override_railtype | Whether all physically compatible railtypes should be followed. |
Definition at line 2574 of file train_cmd.cpp.
References _settings_game, NPFTrainFindNearestSafeTile(), PathfinderSettings::pathfinder_for_trains, GameSettings::pf, VPF_NPF, VPF_YAPF, and YapfTrainFindNearestSafeTile().
| void UpdateLevelCrossing | ( | TileIndex | tile, | |
| bool | sound | |||
| ) |
Sets correct crossing state.
| tile | tile to update | |
| sound | should we play sound? |
Definition at line 1763 of file train_cmd.cpp.
References HasCrossingReservation(), HasVehicleOnPos(), MarkTileDirtyByTile(), TrainApproachingCrossing(), and TrainOnTileEnum().
Referenced by CmdBuildRoad(), CmdBuildSingleRail(), DeleteLastWagon(), and UnreserveRailTrack().
| static int UpdateTrainSpeed | ( | Train * | v | ) | [static] |
This function looks at the vehicle and updates it's speed (cur_speed and subspeed) variables.
Furthermore, it returns the distance that the train can drive this tick. This distance is expressed as 256 * n, where n is the number of straight (long) tracks the train can traverse. This means that moving along a straight track costs 256 "speed" and a diagonal track costs 192 "speed".
| v | The vehicle to update the speed of. |
Definition at line 2978 of file train_cmd.cpp.
References _settings_game, Clamp(), Train::flags, GetTrainAcceleration(), HasBit(), VehicleSettings::train_acceleration_model, and GameSettings::vehicle.
| static CommandCost ValidateTrains | ( | Train * | original_dst, | |
| Train * | dst, | |||
| Train * | original_src, | |||
| Train * | src | |||
| ) | [static] |
Validate whether we are going to create valid trains.
| original_dst | The original destination chain. | |
| dst | The destination chain after constructing the train. | |
| original_dst | The original source chain. | |
| dst | The source chain after constructing the train. |
Definition at line 1225 of file train_cmd.cpp.
References CheckNewTrain(), CheckTrainAttachment(), and CommandCost::Failed().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
const uint16 _breakdown_speeds[16] [static] |
Initial value:
{
225, 210, 195, 180, 165, 150, 135, 120, 105, 90, 75, 60, 45, 30, 15, 15
}
Definition at line 3786 of file train_cmd.cpp.
const byte _initial_tile_subcoord[6][4][3] [static] |
Initial value:
{
{{ 15, 8, 1 }, { 0, 0, 0 }, { 0, 8, 5 }, { 0, 0, 0 }},
{{ 0, 0, 0 }, { 8, 0, 3 }, { 0, 0, 0 }, { 8, 15, 7 }},
{{ 0, 0, 0 }, { 7, 0, 2 }, { 0, 7, 6 }, { 0, 0, 0 }},
{{ 15, 8, 2 }, { 0, 0, 0 }, { 0, 0, 0 }, { 8, 15, 6 }},
{{ 15, 7, 0 }, { 8, 0, 4 }, { 0, 0, 0 }, { 0, 0, 0 }},
{{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 8, 4 }, { 7, 15, 0 }},
}
Definition at line 2446 of file train_cmd.cpp.
const RailtypeSlowdownParams _railtype_slowdown[] [static] |
Initial value:
{
{256 / 4, 256 / 2, 256 / 4, 2},
{256 / 4, 256 / 2, 256 / 4, 2},
{256 / 4, 256 / 2, 256 / 4, 2},
{0, 256 / 2, 256 / 4, 2},
}
Definition at line 3092 of file train_cmd.cpp.
const int8 _vehicle_smoke_pos[8] [static] |
1.5.6