OpenTTD Source 20250205-master-gfd85ab1e2c
train_cmd.h File Reference

Command definitions related to trains. More...

#include "command_type.h"
#include "engine_type.h"
#include "vehicle_type.h"

Go to the source code of this file.

Functions

CommandCost CmdBuildRailVehicle (DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
 Build a railroad vehicle.
 
CommandCost CmdSellRailWagon (DoCommandFlag flags, Vehicle *t, bool sell_chain, bool backup_order, ClientID user)
 Sell a (single) train wagon/engine.
 
CommandCost CmdMoveRailVehicle (DoCommandFlag flags, VehicleID src_veh, VehicleID dest_veh, bool move_chain)
 Move a rail vehicle around inside the depot.
 
CommandCost CmdForceTrainProceed (DoCommandFlag flags, VehicleID veh_id)
 Force a train through a red signal.
 
CommandCost CmdReverseTrainDirection (DoCommandFlag flags, VehicleID veh_id, bool reverse_single_veh)
 Reverse train.
 
void CcBuildWagon (Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoType, ClientID)
 Callback for building wagons.
 

Detailed Description

Command definitions related to trains.

Definition in file train_cmd.h.

Function Documentation

◆ CcBuildWagon()

void CcBuildWagon ( Commands  cmd,
const CommandCost result,
VehicleID  new_veh_id,
uint  ,
uint16_t  ,
CargoArray  ,
TileIndex  tile,
EngineID  ,
bool  ,
CargoType  ,
ClientID   
)

Callback for building wagons.

Parameters
resultThe result of the command.
new_veh_idID of the ne vehicle.
tileThe tile the command was executed on.

Definition at line 29 of file train_gui.cpp.

References CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), SpecializedVehicle< T, Type >::Iterate(), Vehicle::Last(), Vehicle::tile, and WC_TRAINS_LIST.

◆ CmdBuildRailVehicle()

CommandCost CmdBuildRailVehicle ( DoCommandFlag  flags,
TileIndex  tile,
const Engine e,
Vehicle **  ret 
)

Build a railroad vehicle.

Parameters
flagstype of operation.
tiletile of the depot where rail-vehicle is built.
ethe engine to build.
[out]retthe vehicle that has been built.
Returns
the cost of this operation or an error.

Definition at line 750 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, CmdBuildRailWagon(), Train::ConsistChanged(), TimerGameCalendar::date, TimerGameEconomy::date, Vehicle::date_of_last_service, Vehicle::date_of_last_service_newgrf, DC_EXEC, DEFAULT_GROUP, DiagDirToDir(), Vehicle::direction, Vehicle::engine_type, ExclusivePreview, GroundVehicleCache::first_engine, Engine::flags, GroundVehicle< T, Type >::gcache, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Engine::GetDefaultCargoType(), Engine::GetLifeLengthInDays(), GetRailDepotDirection(), GetRailType(), GetSlopePixelZ(), Vehicle::group_id, HasPowerOnRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_ENGINE, IsValidCargoType(), Vehicle::last_loading_station, Vehicle::last_station_visited, Vehicle::max_age, Vehicle::owner, RailVehicleInfo::railtype, RAILVEH_MULTIHEAD, RAILVEH_WAGON, Random, Vehicle::random_bits, Vehicle::refit_cap, Engine::reliability, Vehicle::reliability, Engine::reliability_spd_dec, Vehicle::reliability_spd_dec, VehicleSpriteSeq::Set(), SetBit(), GroundVehicle< T, Type >::SetEngine(), GroundVehicle< T, Type >::SetFrontEngine(), settings, Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, Vehicle::spritenum, EnumBitSet< Tenum, Tstorage >::Test(), TestVehicleBuildProbability(), Vehicle::tile, TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, Vehicle::UpdatePosition(), UpdateTrainGroupID(), BaseConsist::vehicle_flags, Vehicle::vehstatus, VF_BUILT_AS_PROTOTYPE, VRF_REVERSE_DIRECTION, VS_DEFPAL, VS_HIDDEN, VS_STOPPED, Vehicle::x_pos, Vehicle::y_pos, TimerGameCalendar::year, and Vehicle::z_pos.

Referenced by CmdBuildVehicle().

◆ CmdForceTrainProceed()

◆ CmdMoveRailVehicle()

CommandCost CmdMoveRailVehicle ( DoCommandFlag  flags,
VehicleID  src_veh,
VehicleID  dest_veh,
bool  move_chain 
)

Move a rail vehicle around inside the depot.

Parameters
flagstype of operation Note: DC_AUTOREPLACE is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot.
src_vehsource vehicle index
dest_vehwhat wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
move_chainmove all vehicles following the source vehicle
Returns
the cost of this operation or an error

Definition at line 1193 of file train_cmd.cpp.

References _current_company, Vehicle::AddToShared(), ArrangeTrains(), CheckCargoCapacity(), CheckOwnership(), CloseWindowById(), CMD_ERROR, Vehicle::CopyVehicleConfigAndStatistics(), GroupStatistics::CountVehicle(), DC_AUTOREPLACE, DC_EXEC, DC_NO_CARGO_CAP_CHECK, DEFAULT_GROUP, DeleteNewGRFInspectWindow(), DeleteVehicleOrders(), CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::GetFirstEnginePart(), SpecializedVehicle< T, Type >::GetIfValid(), SpecializedVehicle< T, Type >::GetLastEnginePart(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, InvalidateWindowClassesData(), InvalidateWindowData(), GroundVehicle< T, Type >::IsEngine(), Vehicle::IsFrontEngine(), GroundVehicle< T, Type >::IsRearDualheaded(), Vehicle::IsStoppedInDepot(), MakeTrainBackup(), BaseConsist::name, NormaliseSubtypes(), NormaliseTrainHead(), Vehicle::orders, Vehicle::owner, Vehicle::ReleaseUnitNumber(), RestoreTrainBackup(), SetTrainGroupID(), SetWindowDirty(), Vehicle::tile, ValidateTrains(), Vehicle::vehstatus, VS_CRASHED, WC_COMPANY, WC_TRAINS_LIST, WC_VEHICLE_DEPOT, WC_VEHICLE_DETAILS, WC_VEHICLE_ORDERS, WC_VEHICLE_REFIT, WC_VEHICLE_TIMETABLE, and WC_VEHICLE_VIEW.

◆ CmdReverseTrainDirection()

◆ CmdSellRailWagon()

CommandCost CmdSellRailWagon ( DoCommandFlag  flags,
Vehicle t,
bool  sell_chain,
bool  backup_order,
ClientID  user 
)

Sell a (single) train wagon/engine.

Parameters
flagstype of operation
tthe train wagon to sell
sell_chainthe selling mode
  • sell_chain = false: only sell the single dragged wagon/engine (and any belonging rear-engines)
  • sell_chain = true: sell the vehicle and all vehicles following it in the chain if the wagon is dragged, don't delete the possibly belonging rear-engine to some front
backup_ordermake order backup?
userthe user for the order backup.
Returns
the cost of this operation or an error

Definition at line 1391 of file train_cmd.cpp.

References CommandCost::AddCost(), Vehicle::AddToShared(), ArrangeTrains(), OrderBackup::Backup(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::CanAllocateItem(), Vehicle::CopyVehicleConfigAndStatistics(), GroupStatistics::CountVehicle(), DC_AUTOREPLACE, DC_EXEC, DeleteVehicleOrders(), 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(), Vehicle::tile, ValidateTrains(), WC_TRAINS_LIST, and WC_VEHICLE_DEPOT.

Referenced by CmdSellVehicle().