|
OpenTTD Source 20251213-master-g1091fa6071
|
Handling of trains. More...
#include "stdafx.h"#include "error.h"#include "articulated_vehicles.h"#include "command_func.h"#include "error_func.h"#include "pathfinder/yapf/yapf.hpp"#include "news_func.h"#include "company_func.h"#include "newgrf_sound.h"#include "newgrf_text.h"#include "strings_func.h"#include "viewport_func.h"#include "vehicle_func.h"#include "sound_func.h"#include "ai/ai.hpp"#include "game/game.hpp"#include "newgrf_station.h"#include "effectvehicle_func.h"#include "network/network.h"#include "core/random_func.hpp"#include "company_base.h"#include "newgrf.h"#include "order_backup.h"#include "zoom_func.h"#include "newgrf_debug.h"#include "framerate_type.h"#include "train_cmd.h"#include "misc_cmd.h"#include "timer/timer_game_calendar.h"#include "timer/timer_game_economy.h"#include "table/strings.h"#include "table/train_sprites.h"#include "safeguards.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 | AccelerationSlowdownParams |
| Data structure for storing engine speed changes of an acceleration type. More... | |
Typedefs | |
| typedef std::vector< Train * > | TrainList |
| Helper type for lists/vectors of trains. | |
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, bool reverse) |
| Checks for line end. | |
| bool | TrainController (Train *v, Vehicle *nomove, bool reverse) |
| Move a vehicle chain one movement stop forwards. | |
| static TileIndex | TrainApproachingCrossingTile (const Train *v) |
| Determines whether train is approaching a rail-road crossing (thus making it barred) | |
| static void | CheckIfTrainNeedsService (Train *v) |
| Check whether a train needs service, and if so, find a depot or service it. | |
| static void | CheckNextTrainTile (Train *v) |
| Check if the train is on the last reserved tile and try to extend the path then. | |
| template<> | |
| bool | IsValidImageIndex< VEH_TRAIN > (uint8_t image_index) |
| uint8_t | FreightWagonMult (CargoType cargo) |
| Return the cargo weight multiplier to use for a rail vehicle. | |
| void | CheckTrainsLengths () |
| Checks if lengths of all rail vehicles are valid. | |
| 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. | |
| static SpriteID | GetDefaultTrainSprite (uint8_t spritenum, Direction direction) |
| static void | GetRailIcon (EngineID engine, bool rear_head, int &y, EngineImageType image_type, VehicleSpriteSeq *result) |
| void | DrawTrainEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type) |
| void | GetTrainSpriteSize (EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type) |
| Get the size of the sprite of a train sprite heading west, or both heads (used for lists). | |
| static std::vector< VehicleID > | GetFreeWagonsInDepot (TileIndex tile) |
| Get a list of free wagons in a depot. | |
| static CommandCost | CmdBuildRailWagon (DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret) |
| Build a railroad wagon. | |
| void | NormalizeTrainVehInDepot (const Train *u) |
| Move all free vehicles in the depot to the train. | |
| static void | AddRearEngineToMultiheadedTrain (Train *v) |
| CommandCost | CmdBuildRailVehicle (DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret) |
| 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 its 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, bool check_limit) |
| 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 (DoCommandFlags flags, VehicleID src_veh, VehicleID dest_veh, bool move_chain) |
| Move a rail vehicle around inside the depot. | |
| CommandCost | CmdSellRailWagon (DoCommandFlags flags, Vehicle *t, bool sell_chain, bool backup_order, ClientID user) |
| Sell a (single) train wagon/engine. | |
| static void | MarkTrainAsStuck (Train *v) |
| Mark a train as stuck and stop it if it isn't stopped right now. | |
| static void | SwapTrainFlags (uint16_t *swap_flag1, uint16_t *swap_flag2) |
| Swap the two up/down flags in two ways: | |
| static void | UpdateStatusAfterSwap (Train *v) |
| Updates some variables after swapping the vehicle. | |
| void | ReverseTrainSwapVeh (Train *v, int l, int r) |
| Swap vehicles l and r in consist v, and reverse their direction. | |
| static bool | IsTrain (const Vehicle *v) |
| Check if the vehicle is a train. | |
| bool | TrainOnCrossing (TileIndex tile) |
| Check if a level crossing tile has a train on it. | |
| static bool | TrainApproachingCrossingEnum (const Vehicle *v, TileIndex tile) |
| Checks if a train is approaching a rail-road crossing. | |
| static bool | TrainApproachingCrossing (TileIndex tile) |
| Finds a vehicle approaching rail-road crossing. | |
| static bool | CheckLevelCrossing (TileIndex tile) |
| Check if a level crossing should be barred. | |
| static void | UpdateLevelCrossingTile (TileIndex tile, bool sound, bool force_barred) |
| Sets a level crossing tile to the correct state. | |
| void | UpdateLevelCrossing (TileIndex tile, bool sound, bool force_bar) |
| Update a level crossing to barred or open (crossing may include multiple adjacent tiles). | |
| void | MarkDirtyAdjacentLevelCrossingTiles (TileIndex tile, Axis road_axis) |
| Find adjacent level crossing tiles in this multi-track crossing and mark them dirty. | |
| void | UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval (TileIndex tile, Axis road_axis) |
| Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing tile. | |
| 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 bool | IsWholeTrainInsideDepot (const Train *v) |
| void | ReverseTrainDirection (Train *v) |
| Turn a train around. | |
| CommandCost | CmdReverseTrainDirection (DoCommandFlags flags, VehicleID veh_id, bool reverse_single_veh) |
| Reverse train. | |
| static TrainForceProceeding | DetermineNextTrainForceProceeding (const Train *t) |
| Determine to what force_proceed should be changed. | |
| CommandCost | CmdForceTrainProceed (DoCommandFlags flags, VehicleID veh_id) |
| Force a train through a red signal. | |
| static FindDepotData | FindClosestTrainDepot (Train *v, int max_distance) |
| Try to find a depot nearby. | |
| static bool | CheckTrainStayInDepot (Train *v) |
| Will the train stay in the depot the next tick? | |
| static void | ClearPathReservation (const Train *v, TileIndex tile, Trackdir track_dir) |
| Clear the reservation of tile that was just left by a wagon on track_dir. | |
| void | FreeTrainTrackReservation (const Train *v) |
| Free the reserved path in front of a vehicle. | |
| static Track | DoTrainPathfind (const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool do_track_reservation, PBSTileInfo *dest, TileIndex *final_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_railtype) |
| 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 void | TrainEnterStation (Train *v, StationID station) |
| Trains enters a station, send out a news item if it is the first train, and start loading. | |
| static bool | CheckCompatibleRail (const Train *v, TileIndex tile) |
| static void | AffectSpeedByZChange (Train *v, int 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 uint | CheckTrainCollision (Vehicle *v, Train *t) |
| Collision test function. | |
| static bool | CheckTrainCollision (Train *v) |
| Checks whether the specified train has a collision with another vehicle. | |
| static bool | IsRailStationPlatformOccupied (TileIndex tile) |
| static void | DeleteLastWagon (Train *v) |
| Deletes/Clears the last wagon of a crashed train. | |
| static void | ChangeTrainDirRandomly (Train *v) |
| Rotate all vehicles of a (crashed) train chain randomly to animate the crash. | |
| static bool | HandleCrashedTrain (Train *v) |
| Handle a crashed train. | |
| static bool | TrainApproachingLineEnd (Train *v, bool signal, bool reverse) |
| 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 uint8_t | _vehicle_initial_x_fract [4] = {10, 8, 4, 8} |
| static const uint8_t | _vehicle_initial_y_fract [4] = { 8, 4, 8, 10} |
| static const uint8_t | _initial_tile_subcoord [6][4][3] |
| static const AccelerationSlowdownParams | _accel_slowdown [] |
| Speed update fractions for each acceleration type. | |
| static const uint16_t | _breakdown_speeds [16] |
| Maximum speeds for train that is broken down or approaching line end. | |
Handling of trains.
Definition in file train_cmd.cpp.
Helper type for lists/vectors of trains.
Definition at line 865 of file train_cmd.cpp.
|
static |
Definition at line 724 of file train_cmd.cpp.
|
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 1917 of file train_cmd.cpp.
References Train::CalcNextVehicleOffset(), GetRailDepotTrack(), Hidden, SpecializedVehicle< T, Type >::Last(), SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< T, Type >::Previous(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), TicksToLeaveDepot(), Vehicle::tile, TRACK_BIT_DEPOT, TrackToTrackBits(), TrainController(), and Vehicle::vehstatus.
Referenced by ReverseTrainDirection().
|
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 1889 of file train_cmd.cpp.
References Train::CalcNextVehicleOffset(), SpecializedVehicle< T, Type >::Last(), SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< T, Type >::Previous(), and TrainController().
Referenced by ReverseTrainDirection().
|
inlinestatic |
Modify the speed of the vehicle due to a change in altitude.
| v | Train to update. |
| old_z | Previous height. |
Definition at line 3088 of file train_cmd.cpp.
References _accel_slowdown, _settings_game, Vehicle::cur_speed, Train::GetAccelerationType(), VehicleSettings::train_acceleration_model, GameSettings::vehicle, AccelerationSlowdownParams::z_down, Vehicle::z_pos, and AccelerationSlowdownParams::z_up.
Referenced by TrainController().
|
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 1147 of file train_cmd.cpp.
References Train::GetNextUnit(), SpecializedVehicle< T, Type >::GetNextVehicle(), InsertInConsist(), GroundVehicle< T, Type >::IsMultiheaded(), NormaliseDualHeads(), and RemoveFromConsist().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
|
static |
Rotate all vehicles of a (crashed) train chain randomly to animate the crash.
| v | First crashed vehicle. |
Definition at line 3709 of file train_cmd.cpp.
References ChangeDir(), DIRDIFF_45LEFT, DIRDIFF_45RIGHT, DIRDIFF_SAME, Vehicle::direction, GB(), Hidden, SpecializedVehicle< T, Type >::Next(), Random, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TRACK_BIT_WORMHOLE, GroundVehicle< T, Type >::UpdateInclination(), Vehicle::UpdatePosition(), SpecializedVehicle< T, Type >::UpdateViewport(), and Vehicle::vehstatus.
Referenced by HandleCrashedTrain().
Definition at line 3061 of file train_cmd.cpp.
|
static |
Check whether a train needs service, and if so, find a depot or service it.
Definition at line 4139 of file train_cmd.cpp.
References _settings_game, FindDepotData::best_length, Chance16(), Vehicle::current_order, Vehicle::dest_tile, FindClosestTrainDepot(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetDepotIndex(), Order::GetDestination(), GroundVehicle< T, Type >::gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, GroundVehicle< T, Type >::IsChainInDepot(), Order::IsType(), Order::MakeDummy(), Order::MakeGoToDepot(), YAPFSettings::maximum_go_to_depot_penalty, NearestDepot, Vehicle::NeedsAutomaticServicing(), NoIntermediate, Vehicle::owner, GameSettings::pf, Service, SetBit(), SetWindowWidgetDirty(), FindDepotData::tile, VehicleServiceInDepot(), WC_VEHICLE_VIEW, WID_VV_START_STOP, and PathfinderSettings::yapf.
Referenced by Train::OnNewEconomyDay().
|
inlinestatic |
Check if a level crossing should be barred.
| tile | The tile to check. |
Definition at line 1753 of file train_cmd.cpp.
References HasCrossingReservation(), TrainApproachingCrossing(), and TrainOnCrossing().
Referenced by UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), UpdateLevelCrossing(), and UpdateLevelCrossingTile().
|
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_src | The original source chain. |
| src | The source chain after constructing the train. |
Definition at line 989 of file train_cmd.cpp.
References _settings_game, GetFreeUnitNumber(), GroundVehicle< T, Type >::IsEngine(), VehicleSettings::max_trains, VEH_TRAIN, and GameSettings::vehicle.
Referenced by ValidateTrains().
|
static |
Check if the train is on the last reserved tile and try to extend the path then.
| v | Train that needs its path extended. |
Definition at line 2231 of file train_cmd.cpp.
References _settings_game, Vehicle::current_order, Vehicle::dest_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::exitdir, FindFirstTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), Order::GetDestination(), Vehicle::GetNumOrders(), GetSignalStateByTrackdir(), GetStationIndex(), GetTileRailType(), Order::GetType(), Train::GetVehicleTrackdir(), HasPbsSignalOnTrackdir(), HasReservedTracks(), HasSignalOnTrackdir(), IsRailStationTile(), IsRailWaypointTile(), IsTileType(), KillFirstBit(), MP_RAILWAY, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_td, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_tile, PathfinderSettings::path_backoff_interval, GameSettings::pf, ProcessOrders(), Rail90DegTurnDisallowed(), Order::ShouldStopAtStation(), SIGNAL_STATE_RED, Vehicle::tile, TRACK_BIT_DEPOT, TRACKDIR_BIT_NONE, TrackdirBitsToTrackBits(), and TrackdirToTrack().
Referenced by ReverseTrainDirection(), and TrainController().
|
static |
Definition at line 2963 of file train_cmd.cpp.
|
static |
Check whether the train parts can be attached.
| t | the train to check |
Definition at line 1013 of file train_cmd.cpp.
References _settings_game, GroundVehicleCache::cached_veh_length, CALLBACK_FAILED, CBID_TRAIN_ALLOW_WAGON_ATTACH, Vehicle::engine_type, ErrorUnknownCallbackResult(), GroundVehicleCache::first_engine, GroundVehicle< T, Type >::gcache, Vehicle::GetGRF(), Vehicle::GetGRFID(), GetGRFStringID(), GetVehicleCallbackParent(), GRFSTR_MISC_GRF_TEXT, Vehicle::InvalidateNewGRFCache(), Vehicle::IsArticulatedPart(), GroundVehicle< T, Type >::IsEngine(), GroundVehicle< T, Type >::IsRearDualheaded(), VehicleSettings::max_train_length, SpecializedVehicle< T, Type >::Next(), Vehicle::SetNext(), TILE_SIZE, and GameSettings::vehicle.
Referenced by ValidateTrains().
|
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.
| v | Train to test. |
Definition at line 3244 of file train_cmd.cpp.
References _settings_client, Accident, CheckTrainCollision(), SoundSettings::disaster, GetEncodedString(), GetOtherTunnelBridgeEnd(), ModifyStationRatingAround(), Vehicle::owner, SND_13_TRAIN_COLLISION, ClientSettings::sound, Vehicle::tile, TileVirtXY(), TRACK_BIT_DEPOT, TRACK_BIT_WORMHOLE, Vehicle::x_pos, and Vehicle::y_pos.
Collision test function.
| v | Train vehicle to test collision with. |
| t | Train being examined. |
Definition at line 3202 of file train_cmd.cpp.
References abs(), GroundVehicleCache::cached_veh_length, SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::From(), GroundVehicle< T, Type >::gcache, Vehicle::owner, TRACK_BIT_DEPOT, TrainCrashed(), BaseVehicle::type, VEH_TRAIN, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CheckTrainCollision().
| void CheckTrainsLengths | ( | ) |
Checks if lengths of all rail vehicles are valid.
If not, shows an error message.
Definition at line 75 of file train_cmd.cpp.
References _networking, abs(), Crashed, Error, GetEncodedString(), SpecializedVehicle< T, Type >::Iterate(), SpecializedVehicle< T, Type >::Next(), ShowErrorMessage(), TicksToLeaveDepot(), TRACK_BIT_DEPOT, and WL_CRITICAL.
Referenced by InitializeWindowsAndCaches(), and ReloadNewGRFData().
|
static |
Will the train stay in the depot the next tick?
| v | Train to check. |
Definition at line 2293 of file train_cmd.cpp.
References _settings_client, _settings_game, GroundVehicleCache::cached_power, Vehicle::cur_speed, Vehicle::current_order, Vehicle::dest_tile, Vehicle::direction, GroundVehicle< T, Type >::gcache, ClientSettings::gui, HasDepotReservation(), Hidden, INVALID_DIAGDIR, InvalidateWindowData(), Order::IsType(), Vehicle::IsWaitingForUnbunching(), Vehicle::LeaveUnbunchingDepot(), MarkTileDirtyByTile(), MarkTrainAsStuck(), SpecializedVehicle< T, Type >::Next(), Vehicle::owner, GameSettings::pf, Train::PlayLeaveStationSound(), PathfinderSettings::reserve_paths, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetDepotReservation(), SetWindowClassesDirty(), SetWindowDirty(), GUISettings::show_track_reservation, SIGSEG_FULL, SIGSEG_PBS, Stopped, TFP_NONE, Vehicle::tile, TRACK_BIT_DEPOT, TRACK_BIT_X, TRACK_BIT_Y, TryPathReserve(), Train::UpdateAcceleration(), Vehicle::UpdatePosition(), UpdateSignalsOnSegment(), SpecializedVehicle< T, Type >::UpdateViewport(), VehicleEnterDepot(), VehicleServiceInDepot(), Vehicle::vehstatus, Train::wait_counter, WC_TRAINS_LIST, and WC_VEHICLE_DEPOT.
|
static |
Definition at line 2724 of file train_cmd.cpp.
Clear the reservation of tile that was just left by a wagon on track_dir.
| v | Train owning the reservation. |
| tile | Tile with reservation to clear. |
| track_dir | Track direction to clear. |
Definition at line 2375 of file train_cmd.cpp.
References _settings_client, GetOtherTunnelBridgeEnd(), GetTunnelBridgeDirection(), ClientSettings::gui, IsBridge(), IsCompatibleTrainStationTile(), IsRailStationTile(), IsTileType(), MarkBridgeDirty(), MarkTileDirtyByTile(), MP_TUNNELBRIDGE, ReverseDiagDir(), SetRailStationPlatformReservation(), SetTunnelBridgeReservation(), GUISettings::show_track_reservation, TileAddByDiagDir(), TrackdirToExitdir(), TrackdirToTrack(), TunnelBridgeIsFree(), and UnreserveRailTrack().
Referenced by Train::Crash(), FreeTrainTrackReservation(), and TrainController().
| CommandCost CmdBuildRailVehicle | ( | DoCommandFlags | flags, |
| TileIndex | tile, | ||
| const Engine * | e, | ||
| Vehicle ** | ret | ||
| ) |
Build a railroad vehicle.
| flags | type of operation. | |
| tile | tile of the depot where rail-vehicle is built. | |
| e | the engine to build. | |
| [out] | ret | the vehicle that has been built. |
Definition at line 770 of file train_cmd.cpp.
References _current_company, AddArticulatedParts(), Vehicle::build_year, BuiltAsPrototype, RailVehicleInfo::capacity, Vehicle::cargo_cap, Vehicle::cargo_type, CCF_ARRANGE, CheckConsistencyOfArticulatedVehicle(), CMD_ERROR, CmdBuildRailWagon(), Train::ConsistChanged(), TimerGameCalendar::date, TimerGameEconomy::date, Vehicle::date_of_last_service, Vehicle::date_of_last_service_newgrf, DEFAULT_GROUP, DefaultPalette, DiagDirToDir(), Vehicle::direction, Vehicle::engine_type, ExclusivePreview, Execute, GroundVehicleCache::first_engine, Engine::flags, Flipped, GroundVehicle< T, Type >::gcache, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), Engine::GetDefaultCargoType(), Engine::GetLifeLengthInDays(), GetRailDepotDirection(), GetRailType(), GetSlopePixelZ(), Vehicle::group_id, HasPowerOnRail(), Hidden, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IsValidCargoType(), Vehicle::last_loading_station, Vehicle::last_station_visited, Vehicle::max_age, Vehicle::owner, RailVehicleInfo::railtypes, RAILVEH_MULTIHEAD, RAILVEH_WAGON, Random, Vehicle::random_bits, Vehicle::refit_cap, Engine::reliability, Vehicle::reliability, Engine::reliability_spd_dec, Vehicle::reliability_spd_dec, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), VehicleSpriteSeq::Set(), GroundVehicle< T, Type >::SetEngine(), GroundVehicle< T, Type >::SetFrontEngine(), settings, Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, Vehicle::spritenum, Stopped, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TestVehicleBuildProbability(), Vehicle::tile, TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, Vehicle::UpdatePosition(), UpdateTrainGroupID(), BaseConsist::vehicle_flags, Vehicle::vehstatus, Vehicle::x_pos, Vehicle::y_pos, TimerGameCalendar::year, and Vehicle::z_pos.
Referenced by CmdBuildVehicle().
|
static |
Build a railroad wagon.
| flags | type of operation. | |
| tile | tile of the depot where rail-vehicle is built. | |
| e | the engine to build. | |
| [out] | ret | the vehicle that has been built. |
< Must be same type
< Don't connect to ourself
Definition at line 636 of file train_cmd.cpp.
References _current_company, AddArticulatedParts(), Vehicle::build_year, RailVehicleInfo::capacity, Vehicle::cargo_cap, Vehicle::cargo_type, CCF_ARRANGE, CheckConsistencyOfArticulatedVehicle(), CMD_ERROR, TimerGameCalendar::date, TimerGameEconomy::date, Vehicle::date_of_last_service, Vehicle::date_of_last_service_newgrf, DEFAULT_GROUP, DefaultPalette, DiagDirToDir(), Vehicle::direction, Vehicle::engine_type, Execute, SpecializedVehicle< T, Type >::First(), GroundVehicleCache::first_engine, Flipped, GroundVehicle< T, Type >::gcache, SpecializedVehicle< T, Type >::Get(), Engine::GetDefaultCargoType(), GetFreeWagonsInDepot(), GetRailDepotDirection(), GetRailType(), GetSlopePixelZ(), Vehicle::group_id, Hidden, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, InvalidateWindowData(), IsCompatibleRail(), IsValidCargoType(), SpecializedVehicle< T, Type >::Last(), Vehicle::owner, RailVehicleInfo::railtypes, Random, Vehicle::random_bits, Vehicle::refit_cap, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), VehicleSpriteSeq::Set(), GroundVehicle< T, Type >::SetFreeWagon(), GroundVehicle< T, Type >::SetWagon(), Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, Vehicle::spritenum, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TestVehicleBuildProbability(), Vehicle::tile, TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, Vehicle::UpdatePosition(), UpdateTrainGroupID(), Vehicle::vehstatus, WC_VEHICLE_DEPOT, Vehicle::x_pos, Vehicle::y_pos, TimerGameCalendar::year, and Vehicle::z_pos.
Referenced by CmdBuildRailVehicle().
| CommandCost CmdForceTrainProceed | ( | DoCommandFlags | flags, |
| VehicleID | veh_id | ||
| ) |
Force a train through a red signal.
| flags | type of operation |
| veh_id | train to ignore the red signal |
Definition at line 2167 of file train_cmd.cpp.
References CheckOwnership(), CMD_ERROR, DetermineNextTrainForceProceeding(), Execute, CommandCost::Failed(), SpecializedVehicle< T, Type >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Train::IsPrimaryVehicle(), Vehicle::owner, BaseConsist::ResetDepotUnbunching(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WC_VEHICLE_VIEW.
| CommandCost CmdMoveRailVehicle | ( | DoCommandFlags | flags, |
| VehicleID | src_veh, | ||
| VehicleID | dest_veh, | ||
| bool | move_chain | ||
| ) |
Move a rail vehicle around inside the depot.
| flags | type of operation Note: DoCommandFlag::AutoReplace is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot. |
| src_veh | source vehicle index |
| dest_veh | what wagon to put the source wagon AFTER, XXX - VehicleID::Invalid() to make a new line |
| move_chain | move all vehicles following the source vehicle |
Definition at line 1218 of file train_cmd.cpp.
References _current_company, Vehicle::AddToShared(), ArrangeTrains(), AutoReplace, CheckCargoCapacity(), CheckOwnership(), CloseWindowById(), CMD_ERROR, Vehicle::CopyVehicleConfigAndStatistics(), GroupStatistics::CountVehicle(), Crashed, DEFAULT_GROUP, DeleteNewGRFInspectWindow(), DeleteVehicleOrders(), Execute, CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::GetFirstEnginePart(), SpecializedVehicle< T, Type >::GetIfValid(), SpecializedVehicle< T, Type >::GetLastEnginePart(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), InvalidateWindowData(), GroundVehicle< T, Type >::IsEngine(), Vehicle::IsFrontEngine(), GroundVehicle< T, Type >::IsRearDualheaded(), Vehicle::IsStoppedInDepot(), MakeTrainBackup(), BaseConsist::name, NoCargoCapacityCheck, NormaliseSubtypes(), NormaliseTrainHead(), Vehicle::orders, Vehicle::owner, Vehicle::ReleaseUnitNumber(), RestoreTrainBackup(), SetTrainGroupID(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, ValidateTrains(), Vehicle::vehstatus, WC_COMPANY, WC_TRAINS_LIST, WC_VEHICLE_DEPOT, WC_VEHICLE_DETAILS, WC_VEHICLE_ORDERS, WC_VEHICLE_REFIT, WC_VEHICLE_TIMETABLE, and WC_VEHICLE_VIEW.
| CommandCost CmdReverseTrainDirection | ( | DoCommandFlags | flags, |
| VehicleID | veh_id, | ||
| bool | reverse_single_veh | ||
| ) |
Reverse train.
| flags | type of operation |
| veh_id | train to reverse |
| reverse_single_veh | if true, reverse a unit in a train (needs to be in a depot) |
Definition at line 2073 of file train_cmd.cpp.
References _settings_game, ArticEngine, Vehicle::breakdown_ctr, EngineInfo::callback_mask, CCF_ARRANGE, CheckOwnership(), CMD_ERROR, Train::ConsistChanged(), Crashed, Vehicle::cur_speed, Vehicle::current_order, Vehicle::engine_type, Execute, CommandCost::Failed(), Vehicle::fill_percent_te_id, SpecializedVehicle< T, Type >::First(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Flip(), Flipped, SpecializedVehicle< T, Type >::GetIfValid(), GetStationIndex(), HideFillingPercent(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, GroundVehicle< T, Type >::IsMultiheaded(), Train::IsPrimaryVehicle(), Vehicle::IsStoppedInDepot(), IsTileType(), Order::IsType(), Vehicle::LeaveStation(), MP_STATION, Vehicle::Next(), Vehicle::owner, BaseConsist::ResetDepotUnbunching(), ReverseTrainDirection(), Reversing, GroundVehicle< T, Type >::SetLastSpeed(), SetWindowClassesDirty(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TFP_NONE, Vehicle::tile, VehicleSettings::train_acceleration_model, GameSettings::vehicle, Vehicle::vehstatus, WC_TRAINS_LIST, WC_VEHICLE_DEPOT, WC_VEHICLE_DETAILS, and WC_VEHICLE_VIEW.
| CommandCost CmdSellRailWagon | ( | DoCommandFlags | flags, |
| Vehicle * | t, | ||
| bool | sell_chain, | ||
| bool | backup_order, | ||
| ClientID | user | ||
| ) |
Sell a (single) train wagon/engine.
| flags | type of operation |
| t | the train wagon to sell |
| sell_chain | the selling mode
|
| backup_order | make order backup? |
| user | the user for the order backup. |
Definition at line 1416 of file train_cmd.cpp.
References CommandCost::AddCost(), Vehicle::AddToShared(), ArrangeTrains(), AutoReplace, OrderBackup::Backup(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_orderlist_pool >::CanAllocateItem(), Vehicle::CopyVehicleConfigAndStatistics(), GroupStatistics::CountVehicle(), DeleteVehicleOrders(), Execute, EXPENSES_NEW_VEHICLES, CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::From(), SpecializedVehicle< T, Type >::GetFirstEnginePart(), InvalidateWindowClassesData(), InvalidateWindowData(), GroundVehicle< T, Type >::IsEngine(), Vehicle::IsFrontEngine(), Train::IsPrimaryVehicle(), GroundVehicle< T, Type >::IsRearDualheaded(), MakeTrainBackup(), SpecializedVehicle< T, Type >::Next(), NormaliseSubtypes(), NormaliseTrainHead(), Vehicle::orders, RestoreTrainBackup(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, ValidateTrains(), WC_TRAINS_LIST, and WC_VEHICLE_DEPOT.
Referenced by CmdSellVehicle().
|
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 3630 of file train_cmd.cpp.
References AxisToDiagDir(), CCF_ARRANGE, Train::ConsistChanged(), Crashed, DiagDirToDiagTrackBits(), SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::From(), GetRailStationAxis(), GetTunnelBridgeDirection(), HasReservedTracks(), INVALID_DIAGDIR, IsLevelCrossingTile(), IsRailDepotTile(), IsRailStationTile(), IsTileType(), Vehicle::last_station_visited, MP_TUNNELBRIDGE, SpecializedVehicle< T, Type >::Next(), Vehicle::owner, ReverseDiagDir(), Vehicle::SetNext(), SetRailStationPlatformReservation(), SetSignalsOnBothDir(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, TRACK_BEGIN, TRACK_BIT_DEPOT, TRACK_BIT_NONE, TRACK_BIT_WORMHOLE, TRACK_X, TRACK_Y, TrackBitsToTrack(), TryReserveRailTrack(), BaseVehicle::type, UnreserveRailTrack(), UpdateLevelCrossing(), UpdateSignalsOnSegment(), VEH_TRAIN, Vehicle::vehstatus, and WC_VEHICLE_DEPOT.
Referenced by HandleCrashedTrain().
|
static |
Determine to what force_proceed should be changed.
If we are forced to proceed, cancel that order. If we are marked stuck we would want to force the train to proceed to the next signal unless we are stuck just before the next signal. In the other cases we would like to pass the signal at danger and run till the next signal we encounter.
| t | The train to determine the new value of force_proceed for. |
Definition at line 2150 of file train_cmd.cpp.
References Crashed, DiagdirReachesTracks(), FindFirstTrack(), GetTrackBits(), Train::GetVehicleTrackdir(), HasSignalOnTrack(), HasSignals(), INVALID_TILE, GroundVehicle< T, Type >::IsChainInDepot(), IsTileType(), MP_RAILWAY, Stuck, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TFP_NONE, TFP_SIGNAL, TFP_STUCK, Vehicle::tile, TileAddByDiagDir(), TRACK_BIT_NONE, TrackdirToExitdir(), and Vehicle::vehstatus.
Referenced by CmdForceTrainProceed().
|
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 | |
| [out] | path_found | Whether a path has been found or not. |
| do_track_reservation | Path reservation is requested | |
| [out] | dest | State and destination of the requested path |
| [out] | final_dest | Final tile of the best path found |
Definition at line 2499 of file train_cmd.cpp.
References INVALID_TILE, and YapfTrainChooseTrack().
| void DrawTrainEngine | ( | int | left, |
| int | right, | ||
| int | preferred_x, | ||
| int | y, | ||
| EngineID | engine, | ||
| PaletteID | pal, | ||
| EngineImageType | image_type | ||
| ) |
Definition at line 536 of file train_cmd.cpp.
|
static |
Extend a train path as far as possible.
Stops on encountering a safe tile, another reservation or a track choice.
Definition at line 2510 of file train_cmd.cpp.
References _settings_game, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::exitdir, FindFirstTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), FollowTrainReservation(), PathfinderSettings::forbid_90_deg, GetSignalStateByTrackdir(), GetTileRailType(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), HasReservedTracks(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_station, IsPlainRail(), IsSafeWaitingPosition(), IsTileType(), IsWaitingPositionFree(), KillFirstBit(), MarkTileDirtyByTile(), MP_RAILWAY, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_td, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_tile, GameSettings::pf, Rail90DegTurnDisallowed(), ReverseTrackdir(), SetSignalStateByTrackdir(), SIGNAL_STATE_GREEN, SIGNAL_STATE_RED, PBSTileInfo::tile, TileOffsByDiagDir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::tiles_skipped, PBSTileInfo::trackdir, TRACKDIR_BIT_NONE, TrackdirBitsToTrackBits(), TrackdirReachesTrackdirs(), TrackdirToTrack(), TryReserveRailTrack(), and UnreserveRailTrack().
|
static |
Try to find a depot nearby.
| v | Train that wants a depot. |
| max_distance | Maximal search distance. |
Definition at line 2196 of file train_cmd.cpp.
References Crashed, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::vehstatus, and YapfTrainFindNearestDepot().
Referenced by CheckIfTrainNeedsService(), and Train::FindClosestDepot().
Definition at line 846 of file train_cmd.cpp.
| void FreeTrainTrackReservation | ( | const Train * | v | ) |
Free the reserved path in front of a vehicle.
| v | Train owning the reserved path. |
Definition at line 2416 of file train_cmd.cpp.
References AddSideToSignalBuffer(), ClearPathReservation(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetAllCompatibleRailTypes(), GetRailDepotDirection(), GetReservedTrackbits(), GetSignalStateByTrackdir(), GetStationIndex(), Train::GetVehicleTrackdir(), HasPbsSignalOnTrackdir(), HasSignalOnTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_bridge, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_station, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_tunnel, Vehicle::IsFrontEngine(), IsOnewaySignal(), IsRailDepotTile(), IsRailStationTile(), IsTileType(), IsValidTrackdir(), MarkTileDirtyByTile(), MP_RAILWAY, MP_TUNNELBRIDGE, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_tile, SpecializedVehicle< T, Type >::Next(), Vehicle::owner, RemoveFirstTrackdir(), ReverseTrackdir(), SetSignalStateByTrackdir(), SIGNAL_STATE_RED, Vehicle::tile, TRACK_BIT_DEPOT, TrackBitsToTrackdirBits(), TRACKDIR_BIT_NONE, TrackdirToExitdir(), TrackdirToTrack(), TracksOverlap(), TrackToTrackBits(), UnreserveRailTrack(), and UpdateSignalsInBuffer().
Referenced by CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), Train::Crash(), DoClearBridge(), DoClearTunnel(), FreeTrainReservation(), and ReverseTrainDirection().
| uint8_t FreightWagonMult | ( | CargoType | cargo | ) |
Return the cargo weight multiplier to use for a rail vehicle.
| cargo | Cargo type to get multiplier for |
Definition at line 68 of file train_cmd.cpp.
References _settings_game, VehicleSettings::freight_trains, CargoSpec::Get(), and GameSettings::vehicle.
Referenced by DrawTrainDetails(), TrainDetailsCapacityTab(), and TrainDetailsCargoTab().
Definition at line 479 of file train_cmd.cpp.
Get a list of free wagons in a depot.
| tile | Tile of depot. |
Definition at line 611 of file train_cmd.cpp.
References Crashed, SpecializedVehicle< T, Type >::From(), and VEH_TRAIN.
Referenced by CmdBuildRailWagon(), and NormalizeTrainVehInDepot().
|
static |
Definition at line 513 of file train_cmd.cpp.
| void GetTrainSpriteSize | ( | EngineID | engine, |
| uint & | width, | ||
| uint & | height, | ||
| int & | xoffs, | ||
| int & | yoffs, | ||
| EngineImageType | image_type | ||
| ) |
Get the size of the sprite of a train sprite heading west, or both heads (used for lists).
| engine | The engine to get the sprite from. | |
| [out] | width | The width of the sprite. |
| [out] | height | The height of the sprite. |
| [out] | xoffs | Number of pixels to shift the sprite to the right. |
| [out] | yoffs | Number of pixels to shift the sprite downwards. |
| image_type | Context the sprite is used in. |
Definition at line 579 of file train_cmd.cpp.
References VehicleSpriteSeq::GetBounds(), Rect::Height(), RAILVEH_MULTIHEAD, ScaleSpriteTrad(), UnScaleGUI(), and Rect::Width().
Referenced by EnginePreviewWindow::UpdateWidgetSize().
| 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 260 of file train_cmd.cpp.
References GroundVehicleCache::cached_total_length, GroundVehicleCache::cached_veh_length, Vehicle::current_order, Vehicle::direction, DirToDiagDir(), FarEnd, GroundVehicle< T, Type >::gcache, SpecializedStation< Station, false >::Get(), Order::GetDestination(), Station::GetPlatformLength(), Order::GetStopLocation(), Order::IsType(), Middle, NearEnd, and TILE_SIZE.
Referenced by Train::GetCurrentMaxSpeed().
|
static |
Handle a crashed train.
| v | First train vehicle. |
Definition at line 3737 of file train_cmd.cpp.
References Chance16R(), ChangeTrainDirRandomly(), Train::crash_anim_pos, CreateEffectVehicleRel(), DeleteLastWagon(), EV_EXPLOSION_LARGE, EV_EXPLOSION_SMALL, GB(), Hidden, Vehicle::Next(), SpecializedVehicle< T, Type >::Next(), Random, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tick_counter, and Vehicle::vehstatus.
Inserts a chain into the train at dst.
| dst | the place where to append after. |
| chain | the chain to actually add. |
Definition at line 921 of file train_cmd.cpp.
References SpecializedVehicle< T, Type >::Last(), SpecializedVehicle< T, Type >::Next(), and Vehicle::SetNext().
Referenced by ArrangeTrains(), and NormaliseDualHeads().
|
static |
Definition at line 3609 of file train_cmd.cpp.
|
static |
Check if the vehicle is a train.
| v | vehicle on tile |
Definition at line 1688 of file train_cmd.cpp.
References BaseVehicle::type, and VEH_TRAIN.
Referenced by TrainOnCrossing().
| bool IsValidImageIndex< VEH_TRAIN > | ( | uint8_t | image_index | ) |
Definition at line 57 of file train_cmd.cpp.
|
static |
Definition at line 1970 of file train_cmd.cpp.
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 872 of file train_cmd.cpp.
References SpecializedVehicle< T, Type >::Next().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
Find adjacent level crossing tiles in this multi-track crossing and mark them dirty.
| tile | The tile which causes the update. |
| road_axis | The road axis. |
Definition at line 1820 of file train_cmd.cpp.
References AxisToDiagDir(), GetCrossingRoadAxis(), IsLevelCrossingTile(), MarkTileDirtyByTile(), ReverseDiagDir(), Map::Size(), and TileAddByDiagDir().
Referenced by CmdBuildRoad(), and CmdBuildSingleRail().
|
static |
Mark a train as stuck and stop it if it isn't stopped right now.
| v | Train to mark as being stuck. |
Definition at line 1557 of file train_cmd.cpp.
References Vehicle::cur_speed, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), GroundVehicle< T, Type >::SetLastSpeed(), SetWindowWidgetDirty(), Stuck, Vehicle::subspeed, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Train::wait_counter, WC_VEHICLE_VIEW, and WID_VV_START_STOP.
Referenced by CheckTrainStayInDepot(), ReverseTrainDirection(), TrainController(), and TryPathReserve().
|
inlinestatic |
Bars crossing and plays ding-ding sound if not barred already.
| tile | tile with crossing |
Definition at line 1875 of file train_cmd.cpp.
References IsCrossingBarred(), SetCrossingReservation(), and UpdateLevelCrossing().
Referenced by ReverseTrainDirection(), and TrainCheckIfLineEnds().
|
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 935 of file train_cmd.cpp.
References SpecializedVehicle< T, Type >::GetNextVehicle(), InsertInConsist(), GroundVehicle< T, Type >::IsEngine(), GroundVehicle< T, Type >::IsMultiheaded(), SpecializedVehicle< T, Type >::Next(), and RemoveFromConsist().
Referenced by ArrangeTrains().
|
static |
Normalise the sub types of the parts in this chain.
| chain | the chain to normalise. |
Definition at line 957 of file train_cmd.cpp.
References GroundVehicle< T, Type >::ClearFreeWagon(), GroundVehicle< T, Type >::ClearFrontEngine(), GroundVehicle< T, Type >::IsEngine(), GroundVehicle< T, Type >::IsWagon(), SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< T, Type >::Previous(), GroundVehicle< T, Type >::SetFreeWagon(), and GroundVehicle< T, Type >::SetFrontEngine().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
|
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 1188 of file train_cmd.cpp.
References CCF_ARRANGE, Train::ConsistChanged(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetFreeUnitNumber(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, InvalidateWindowData(), Vehicle::IsFrontEngine(), Vehicle::owner, SetWindowWidgetDirty(), BaseVehicle::type, Vehicle::unitnumber, UpdateTrainGroupID(), VEH_TRAIN, VIWD_CONSIST_CHANGED, WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, and WID_VV_REFIT.
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
| void NormalizeTrainVehInDepot | ( | const Train * | u | ) |
Move all free vehicles in the depot to the train.
Definition at line 714 of file train_cmd.cpp.
References Execute, GetFreeWagonsInDepot(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, GroundVehicle< T, Type >::IsEngine(), and Vehicle::tile.
Referenced by CmdBuildVehicle().
|
static |
Remove the given wagon from its consist.
| part | the part of the train to remove. |
| chain | whether to remove the whole chain. |
Definition at line 904 of file train_cmd.cpp.
References SpecializedVehicle< T, Type >::GetLastEnginePart(), SpecializedVehicle< T, Type >::Last(), SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< T, Type >::Previous(), and Vehicle::SetNext().
Referenced by ArrangeTrains(), and NormaliseDualHeads().
|
static |
Restore the train from the backup list.
| list | the train to restore. |
Definition at line 881 of file train_cmd.cpp.
References SpecializedVehicle< T, Type >::Previous(), and Vehicle::SetNext().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
| void ReverseTrainDirection | ( | Train * | v | ) |
Turn a train around.
| v | Train to turn around. |
Definition at line 1982 of file train_cmd.cpp.
References _settings_game, AdvanceWagonsAfterSwap(), AdvanceWagonsBeforeSwap(), CCF_TRACK, CheckNextTrainTile(), Train::ConsistChanged(), Vehicle::current_order, Vehicle::direction, FindFirstTrack(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Flip(), FreeTrainTrackReservation(), GetRailDepotDirection(), Order::GetType(), Train::GetVehicleTrackdir(), HasSignalOnTrackdir(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, INVALID_DIAGDIR, INVALID_TILE, InvalidateWindowData(), IsRailDepotTile(), IsRailStationTile(), IsTileType(), MarkTrainAsStuck(), MaybeBarCrossingWithSound(), MP_RAILWAY, MP_TUNNELBRIDGE, SpecializedVehicle< T, Type >::Next(), Vehicle::owner, GameSettings::pf, PathfinderSettings::reserve_paths, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), Reversed, ReverseTrainSwapVeh(), Reversing, SetRailStationPlatformReservation(), SetWindowWidgetDirty(), SIGSEG_PBS, Stuck, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, TRACK_BIT_DEPOT, TrackdirToExitdir(), TrainApproachingCrossingTile(), TryPathReserve(), UpdateLevelCrossing(), UpdateSignalsOnSegment(), SpecializedVehicle< T, Type >::UpdateViewport(), VehicleExitDir(), Train::wait_counter, WC_VEHICLE_DEPOT, WC_VEHICLE_VIEW, and WID_VV_START_STOP.
Referenced by CmdReverseTrainDirection(), TrainApproachingLineEnd(), and TrainController().
| void ReverseTrainSwapVeh | ( | Train * | v, |
| int | l, | ||
| int | r | ||
| ) |
Swap vehicles l and r in consist v, and reverse their direction.
| v | Consist to change. |
| l | Vehicle index in the consist of the first vehicle. |
| r | Vehicle index in the consist of the second vehicle. |
Definition at line 1646 of file train_cmd.cpp.
References Vehicle::direction, GroundVehicle< T, Type >::gv_flags, Hidden, SpecializedVehicle< T, Type >::Next(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SwapTrainFlags(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, UpdateStatusAfterSwap(), Vehicle::vehstatus, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by FixupTrainLengths(), and ReverseTrainDirection().
|
static |
Swap the two up/down flags in two ways:
| [in,out] | swap_flag1 | First train flag. |
| [in,out] | swap_flag2 | Second train flag. |
Definition at line 1581 of file train_cmd.cpp.
References ClrBit(), GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, HasBit(), and SetBit().
Referenced by ReverseTrainSwapVeh().
|
static |
Finds a vehicle approaching rail-road crossing.
| tile | tile to test |
Definition at line 1729 of file train_cmd.cpp.
References AxisToDiagDir(), GetCrossingRailAxis(), HasVehicleOnTile(), IsLevelCrossingTile(), ReverseDiagDir(), TileOffsByDiagDir(), and TrainApproachingCrossingEnum().
Referenced by CheckLevelCrossing().
Checks if a train is approaching a rail-road crossing.
| v | vehicle on tile |
| tile | tile with crossing we are testing |
Definition at line 1712 of file train_cmd.cpp.
References Crashed, SpecializedVehicle< T, Type >::From(), Vehicle::IsFrontEngine(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TrainApproachingCrossingTile(), BaseVehicle::type, VEH_TRAIN, and Vehicle::vehstatus.
Referenced by TrainApproachingCrossing().
Determines whether train is approaching a rail-road crossing (thus making it barred)
| v | front engine of train |
Definition at line 3864 of file train_cmd.cpp.
References Crashed, DiagDirToAxis(), Vehicle::direction, GetCrossingRoadAxis(), INVALID_TILE, Vehicle::IsFrontEngine(), IsLevelCrossingTile(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, TileOffsByDiagDir(), TrainCanLeaveTile(), VehicleExitDir(), and Vehicle::vehstatus.
Referenced by Train::Crash(), ReverseTrainDirection(), TrainApproachingCrossingEnum(), and TrainController().
|
static |
Train is approaching line end, slow down and possibly reverse.
| v | front train engine |
| signal | not line end, just a red signal |
| reverse | Set to false to not execute the vehicle reversing. This does not change any other logic. |
Definition at line 3789 of file train_cmd.cpp.
References _breakdown_speeds, GroundVehicleCache::cached_veh_length, Vehicle::cur_speed, DIR_E, DIR_N, DIR_NE, DIR_NW, DIR_S, DIR_SE, DIR_W, Vehicle::direction, GroundVehicle< T, Type >::gcache, IsDiagonalDirection(), ReverseTrainDirection(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), TILE_SIZE, TrainSlowing, Vehicle::vehstatus, Vehicle::x_pos, and Vehicle::y_pos.
Referenced by TrainCheckIfLineEnds().
|
static |
Determines whether train would like to leave the tile.
| v | train to test |
Definition at line 3834 of file train_cmd.cpp.
References DiagDirToDir(), Vehicle::direction, GetRailDepotDirection(), GetTunnelBridgeDirection(), IsRailDepotTile(), IsTileType(), MP_TUNNELBRIDGE, ReverseDiagDir(), Vehicle::tile, TRACK_BIT_DEPOT, and TRACK_BIT_WORMHOLE.
Referenced by TrainApproachingCrossingTile(), and TrainCheckIfLineEnds().
|
static |
Checks for line end.
Also, bars crossing at next tile if needed
| v | vehicle we are checking |
| reverse | Set to false to not execute the vehicle reversing. This does not change any other logic. |
Definition at line 3891 of file train_cmd.cpp.
References _breakdown_speeds, Vehicle::breakdown_ctr, Vehicle::cur_speed, DiagdirReachesTrackdirs(), Vehicle::direction, FindFirstTrack(), GB(), GetTileRailType(), GetTileTrackStatus(), IsLevelCrossingTile(), MaybeBarCrossingWithSound(), Rail90DegTurnDisallowed(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), ReverseDiagDir(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), Vehicle::tile, TileOffsByDiagDir(), TRACK_BIT_NONE, TrackdirBitsToTrackBits(), TrackStatusToRedSignals(), TrackStatusToTrackdirBits(), TrainApproachingLineEnd(), TrainCanLeaveTile(), TrainSlowing, TRANSPORT_RAIL, VehicleExitDir(), and Vehicle::vehstatus.
Referenced by TrainController().
Move a vehicle chain one movement stop forwards.
| v | First vehicle to move. |
| nomove | Stop moving this and all following vehicles. |
| reverse | Set to false to not execute the vehicle reversing. This does not change any other logic. |
Definition at line 3284 of file train_cmd.cpp.
References _accel_slowdown, _settings_client, _settings_game, AffectSpeedByZChange(), SoundSettings::ambient, TrainCache::cached_max_curve_speed, CannotEnter, CCF_TRACK, CheckNextTrainTile(), ClearPathReservation(), Crashed, Vehicle::cur_speed, Ticks::DAY_TICKS, DIAGDIR_BEGIN, DIAGDIR_END, DiagdirBetweenTiles(), DiagdirReachesTrackdirs(), DiagDirToDiagTrack(), DIRDIFF_45LEFT, DIRDIFF_45RIGHT, DirDifference(), Vehicle::direction, EnteredStation, EnteredWormhole, FindFirstBit(), FindFirstTrack(), FindFirstTrackdir(), SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::From(), Train::GetAccelerationType(), Train::GetCurveSpeedLimit(), GetNewVehiclePos(), GetOtherTunnelBridgeEnd(), GetReservedTrackbits(), GetStationIndex(), GetTileRailType(), GetTileTrackStatus(), GetTunnelBridgeDirection(), Train::GetVehicleTrackdir(), HasCrossingReservation(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), HasReservedTracks(), HasSignalOnTrackdir(), HasSignals(), HasVehicleOnTile(), Hidden, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, INVALID_TILE, Vehicle::IsFrontEngine(), IsLevelCrossingTile(), IsPlainRailTile(), IsTileType(), IsTunnel(), IsValidDiagDirection(), AccelerationSlowdownParams::large_turn, MarkTileDirtyByTile(), MarkTrainAsStuck(), MP_TUNNELBRIDGE, GetNewVehiclePosResult::new_tile, SpecializedVehicle< T, Type >::Next(), GetNewVehiclePosResult::old_tile, Vehicle::owner, PathfinderSettings::path_backoff_interval, GameSettings::pf, SpecializedVehicle< T, Type >::Previous(), Vehicle::progress, Rail90DegTurnDisallowed(), PathfinderSettings::reverse_at_signals, ReverseDiagDir(), ReverseTrackdir(), ReverseTrainDirection(), SetSignalStateByTrackdir(), SetWindowDirty(), SIGNAL_STATE_RED, SIGSEG_PBS, SIGTYPE_PBS, AccelerationSlowdownParams::small_turn, SND_0E_LEVEL_CROSSING, ClientSettings::sound, Stuck, Vehicle::subspeed, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TFP_NONE, TFP_SIGNAL, TFP_STUCK, Vehicle::tick_counter, Vehicle::tile, TileAddByDiagDir(), TRACK_BIT_DEPOT, TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_MASK, TRACK_BIT_NONE, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, TRACK_BIT_WORMHOLE, TRACK_BIT_X, TRACK_BIT_Y, TrackBitsToTrack(), TrackdirBitsToTrackBits(), TrackDirectionToTrackdir(), TrackdirToExitdir(), TrackdirToTrack(), TrackStatusToRedSignals(), TrackStatusToTrackdirBits(), TrackToTrackBits(), VehicleSettings::train_acceleration_model, TrainApproachingCrossingTile(), TrainCheckIfLineEnds(), TrainEnterStation(), TRANSPORT_RAIL, TryPathReserve(), TryReserveRailTrack(), BaseVehicle::type, Train::UpdateDeltaXY(), GroundVehicle< T, Type >::UpdateInclination(), UpdateLevelCrossing(), Vehicle::UpdatePosition(), UpdateSignalsOnSegment(), VEH_TRAIN, GameSettings::vehicle, VehicleEnterTile(), VehicleExitDir(), Vehicle::vehstatus, Train::wait_counter, PathfinderSettings::wait_oneway_signal, PathfinderSettings::wait_twoway_signal, WC_VEHICLE_VIEW, Vehicle::x_pos, GetNewVehiclePosResult::y, and Vehicle::y_pos.
Referenced by AdvanceWagonsAfterSwap(), AdvanceWagonsBeforeSwap(), and FixupTrainLengths().
|
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 3178 of file train_cmd.cpp.
References Train::Crash(), Crashed, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Game::NewEvent(), AI::NewEvent(), Vehicle::owner, Train::ReserveTrackUnderConsist(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, and Vehicle::vehstatus.
Referenced by CheckTrainCollision().
Trains enters a station, send out a news item if it is the first train, and start loading.
Definition at line 3033 of file train_cmd.cpp.
References _local_company, AddVehicleNewsItem(), ArrivalCompany, ArrivalOther, Vehicle::BeginLoading(), SpecializedStation< Station, false >::Get(), GetEncodedString(), HVOT_TRAIN, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Vehicle::last_station_visited, Game::NewEvent(), AI::NewEvent(), Vehicle::owner, SetWindowDirty(), TFP_NONE, Vehicle::tile, TriggerStationRandomisation(), VehicleArrives, and WC_VEHICLE_VIEW.
Referenced by TrainController().
|
static |
Definition at line 3942 of file train_cmd.cpp.
|
static |
Definition at line 3102 of file train_cmd.cpp.
| bool TrainOnCrossing | ( | TileIndex | tile | ) |
Check if a level crossing tile has a train on it.
| tile | tile to test |
Definition at line 1699 of file train_cmd.cpp.
References HasVehicleOnTile(), IsLevelCrossingTile(), and IsTrain().
Referenced by CheckLevelCrossing().
| 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 2896 of file train_cmd.cpp.
References _settings_client, DiagdirReachesTrackdirs(), DiagdirReachesTracks(), FollowTrainReservation(), GetRailDepotDirection(), GetTileRailType(), GetTileTrackStatus(), ClientSettings::gui, HasDepotReservation(), HasReservedTracks(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Vehicle::IsFrontEngine(), MarkTileDirtyByTile(), MarkTrainAsStuck(), PBSTileInfo::okay, Rail90DegTurnDisallowed(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), SetDepotReservation(), SetWindowWidgetDirty(), GUISettings::show_track_reservation, Stuck, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), PBSTileInfo::tile, Vehicle::tile, TileAddByDiagDir(), TRACK_BIT_DEPOT, PBSTileInfo::trackdir, TrackdirBitsToTrackBits(), TrackdirToExitdir(), TrackdirToTrack(), TrackStatusToTrackdirBits(), TRANSPORT_RAIL, Train::wait_counter, WC_VEHICLE_VIEW, and WID_VV_START_STOP.
Referenced by CheckTrainStayInDepot(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), DoClearBridge(), DoClearTunnel(), RestoreTrainReservation(), ReverseTrainDirection(), and TrainController().
|
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 2623 of file train_cmd.cpp.
References YapfTrainFindNearestSafeTile().
Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing tile.
| tile | The crossing tile which has been or is about to be removed, and which caused the update. |
| road_axis | The road axis. |
Definition at line 1837 of file train_cmd.cpp.
References AxisToDiagDir(), CheckLevelCrossing(), GetCrossingRoadAxis(), IsCrossingBarred(), IsLevelCrossingTile(), MarkTileDirtyByTile(), ReverseDiagDir(), SetCrossingBarred(), Map::Size(), and TileOffsByDiagDir().
Referenced by CmdRemoveSingleRail(), and RemoveRoad().
| void UpdateLevelCrossing | ( | TileIndex | tile, |
| bool | sound, | ||
| bool | force_bar | ||
| ) |
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
| tile | Tile which causes the update. |
| sound | Should we play sound? |
| force_bar | Should we force the crossing to be barred? |
Definition at line 1788 of file train_cmd.cpp.
References AxisToDiagDir(), CheckLevelCrossing(), GetCrossingRoadAxis(), IsLevelCrossingTile(), ReverseDiagDir(), Map::Size(), TileAddByDiagDir(), and UpdateLevelCrossingTile().
Referenced by AfterLoadGame(), ChangeOwnershipOfCompanyItems(), CmdBuildRoad(), CmdBuildSingleRail(), Train::Crash(), DeleteLastWagon(), MaybeBarCrossingWithSound(), ReverseTrainDirection(), TrainController(), TryReserveRailTrack(), and UnreserveRailTrack().
|
static |
Sets a level crossing tile to the correct state.
| tile | Tile to update. |
| sound | Should we play sound? |
| force_barred | Should we set the crossing to barred? |
Definition at line 1766 of file train_cmd.cpp.
References _settings_client, SoundSettings::ambient, CheckLevelCrossing(), IsCrossingBarred(), IsLevelCrossingTile(), MarkTileDirtyByTile(), SetCrossingBarred(), SND_0E_LEVEL_CROSSING, and ClientSettings::sound.
Referenced by UpdateLevelCrossing().
|
static |
Updates some variables after swapping the vehicle.
| v | swapped vehicle |
Definition at line 1609 of file train_cmd.cpp.
References Vehicle::direction, IsBridgeTile(), IsTileType(), MP_TUNNELBRIDGE, ReverseDir(), Vehicle::tile, TileVirtXY(), TRACK_BIT_DEPOT, TRACK_BIT_WORMHOLE, GroundVehicle< T, Type >::UpdateInclination(), Vehicle::UpdatePosition(), SpecializedVehicle< T, Type >::UpdateViewport(), VehicleEnterTile(), Vehicle::x_pos, and Vehicle::y_pos.
Referenced by ReverseTrainSwapVeh().
|
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_src | The original source chain. |
| src | The source chain after constructing the train. |
| check_limit | Whether to check the vehicle limit. |
Definition at line 1127 of file train_cmd.cpp.
References CheckNewTrain(), CheckTrainAttachment(), and CommandCost::Failed().
Referenced by CmdMoveRailVehicle(), and CmdSellRailWagon().
|
static |
Speed update fractions for each acceleration type.
Definition at line 3076 of file train_cmd.cpp.
Referenced by AffectSpeedByZChange(), and TrainController().
|
static |
Maximum speeds for train that is broken down or approaching line end.
Definition at line 3776 of file train_cmd.cpp.
Referenced by TrainApproachingLineEnd(), and TrainCheckIfLineEnds().
|
static |
Definition at line 2477 of file train_cmd.cpp.
|
static |
Definition at line 53 of file train_cmd.cpp.
|
static |
Definition at line 54 of file train_cmd.cpp.