Commands for vehicles. More...
#include "stdafx.h"
#include "roadveh.h"
#include "news_func.h"
#include "airport.h"
#include "cmd_helper.h"
#include "command_func.h"
#include "company_func.h"
#include "vehicle_gui.h"
#include "train.h"
#include "aircraft.h"
#include "newgrf_text.h"
#include "functions.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "string_func.h"
#include "depot_map.h"
#include "vehiclelist.h"
#include "engine_func.h"
#include "articulated_vehicles.h"
#include "autoreplace_gui.h"
#include "company_base.h"
#include "order_backup.h"
#include "table/strings.h"
Go to the source code of this file.
Functions | |
CommandCost | CmdBuildRailVehicle (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v) |
Build a railroad vehicle. | |
CommandCost | CmdBuildRoadVehicle (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v) |
Build a road vehicle. | |
CommandCost | CmdBuildShip (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v) |
Build a ship. | |
CommandCost | CmdBuildAircraft (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v) |
Build an aircraft. | |
CommandCost | CmdBuildVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build a vehicle. | |
CommandCost | CmdSellRailWagon (DoCommandFlag flags, Vehicle *v, uint16 data, uint32 user) |
Sell a (single) train wagon/engine. | |
CommandCost | CmdSellVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Sell a vehicle. | |
static CommandCost | GetRefitCost (EngineID engine_type) |
Learn the price of refitting a certain engine. | |
static CommandCost | RefitVehicle (Vehicle *v, bool only_this, uint8 num_vehicles, CargoID new_cid, byte new_subtype, DoCommandFlag flags) |
Refits a vehicle (chain). | |
CommandCost | CmdRefitVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Refits a vehicle to the specified cargo type. | |
CommandCost | CmdStartStopVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Start/Stop a vehicle. | |
CommandCost | CmdMassStartStopVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Starts or stops a lot of vehicles. | |
CommandCost | CmdDepotSellAllVehicles (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Sells all vehicles in a depot. | |
CommandCost | CmdDepotMassAutoReplace (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Autoreplace all vehicles in the depot. | |
static bool | IsUniqueVehicleName (const char *name) |
Test if a name is unique among vehicle names. | |
static void | CloneVehicleName (const Vehicle *src, Vehicle *dst) |
Clone the custom name of a vehicle, adding or incrementing a number. | |
CommandCost | CmdCloneVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Clone a vehicle. | |
static CommandCost | SendAllVehiclesToDepot (DoCommandFlag flags, bool service, const VehicleListIdentifier &vli) |
Send all vehicles of type to depots. | |
CommandCost | CmdSendVehicleToDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Send a vehicle to the depot. | |
CommandCost | CmdRenameVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Give a custom name to your vehicle. | |
CommandCost | CmdChangeServiceInt (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change the service interval of a vehicle. | |
Variables | |
const uint32 | _veh_build_proc_table [] |
const uint32 | _veh_sell_proc_table [] |
const uint32 | _veh_refit_proc_table [] |
const uint32 | _send_to_depot_proc_table [] |
Commands for vehicles.
Definition in file vehicle_cmd.cpp.
Clone the custom name of a vehicle, adding or incrementing a number.
src | Source vehicle, with a custom name. | |
dst | Destination vehicle. |
Definition at line 589 of file vehicle_cmd.cpp.
References IsUniqueVehicleName(), lastof, Vehicle::name, seprintf(), strecat(), and strecpy().
Referenced by CmdCloneVehicle().
CommandCost CmdBuildAircraft | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
const Engine * | e, | |||
uint16 | data, | |||
Vehicle ** | ret | |||
) |
Build an aircraft.
tile | tile of the depot where aircraft is built. | |
flags | type of operation. | |
e | the engine to build. | |
data | unused. | |
ret[out] | the vehicle that has been built. |
Definition at line 227 of file aircraft_cmd.cpp.
References _cur_year, _current_company, _date, Vehicle::acceleration, AIR_AIRCRAFT, AIR_HELICOPTER, AIR_ROTOR, AIR_SHADOW, Station::airport, CanVehicleUseStation(), Vehicle::cargo_cap, Vehicle::cargo_type, CMD_ERROR, Vehicle::cur_image, DC_EXEC, DIR_N, DIR_SE, Vehicle::direction, ENGINE_EXCLUSIVE_PREVIEW, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), SpecializedStation< Station, false >::GetByTile(), Engine::GetDefaultCargoType(), Airport::GetHangarNum(), Airport::GetHangarTile(), Engine::GetLifeLengthInDays(), GetStationIndex(), GetVehicleCapacity(), GetVehiclePosOnBuild(), HANGAR, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIR, Vehicle::InvalidateNewGRFCacheOfChain(), Vehicle::max_age, Vehicle::name, Vehicle::owner, Aircraft::pos, Aircraft::previous_pos, Vehicle::reliability, Vehicle::reliability_spd_dec, ROTOR_Z_OFFSET, SetBit(), Vehicle::SetNext(), Vehicle::spritenum, Aircraft::state, Vehicle::subtype, Aircraft::targetairport, Vehicle::tile, TILE_SIZE, TileX(), TileY(), UpdateAircraftCache(), Aircraft::UpdateDeltaXY(), Vehicle::vehicle_flags, VehicleMove(), VehicleRandomBits(), Vehicle::vehstatus, VF_BUILT_AS_PROTOTYPE, VS_DEFPAL, VS_HIDDEN, VS_SHADOW, VS_STOPPED, VS_UNCLICKABLE, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CmdBuildVehicle().
CommandCost CmdBuildRailVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
const Engine * | e, | |||
uint16 | data, | |||
Vehicle ** | ret | |||
) |
Build a railroad vehicle.
tile | tile of the depot where rail-vehicle is built. | |
flags | type of operation. | |
e | the engine to build. | |
data | bit 0 prevents any free cars from being added to the train. | |
ret[out] | the vehicle that has been built. |
Definition at line 669 of file train_cmd.cpp.
References _cur_year, _current_company, _date, RailVehicleInfo::capacity, Vehicle::cargo_cap, Vehicle::cargo_type, CheckConsistencyOfArticulatedVehicle(), CMD_ERROR, CmdBuildRailWagon(), Train::ConsistChanged(), Vehicle::cur_image, DC_AUTOREPLACE, DC_EXEC, DEFAULT_GROUP, DiagDirToDir(), Vehicle::direction, ENGINE_EXCLUSIVE_PREVIEW, GroundVehicleCache::first_engine, GroundVehicle< T, Type >::gcache, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Engine::GetDefaultCargoType(), Engine::GetLifeLengthInDays(), GetRailDepotDirection(), GetRailType(), Vehicle::group_id, HasBit(), HasPowerOnRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::max_age, NormalizeTrainVehInDepot(), Vehicle::owner, RAILVEH_MULTIHEAD, RAILVEH_WAGON, Vehicle::reliability, Vehicle::reliability_spd_dec, SetBit(), Train::SetEngine(), Train::SetFrontEngine(), Vehicle::spritenum, Vehicle::tile, TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, UpdateTrainGroupID(), Vehicle::vehicle_flags, VehicleMove(), VehicleRandomBits(), Vehicle::vehstatus, VF_BUILT_AS_PROTOTYPE, VS_DEFPAL, VS_HIDDEN, VS_STOPPED, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CmdBuildVehicle().
CommandCost CmdBuildRoadVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
const Engine * | e, | |||
uint16 | data, | |||
Vehicle ** | ret | |||
) |
Build a road vehicle.
tile | tile of the depot where road vehicle is built. | |
flags | type of operation. | |
e | the engine to build. | |
data | unused. | |
ret[out] | the vehicle that has been built. |
Definition at line 211 of file roadveh_cmd.cpp.
References _cur_year, _current_company, _date, _settings_game, GroundVehicleCache::cached_veh_length, Vehicle::cargo_cap, Vehicle::cargo_type, GroundVehicle< T, Type >::CargoChanged(), CheckConsistencyOfArticulatedVehicle(), Vehicle::cur_image, DC_EXEC, DiagDirToDir(), Vehicle::direction, EF_ROAD_TRAM, ENGINE_EXCLUSIVE_PREVIEW, GroundVehicleCache::first_engine, GroundVehicle< T, Type >::gcache, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Engine::GetDefaultCargoType(), Engine::GetLifeLengthInDays(), GetRoadDepotDirection(), GetVehicleCapacity(), HasBit(), HasTileRoadType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::InvalidateNewGRFCache(), Vehicle::InvalidateNewGRFCacheOfChain(), Vehicle::max_age, SpecializedVehicle< T, Type >::Next(), Vehicle::owner, Vehicle::reliability, Vehicle::reliability_spd_dec, return_cmd_error, ROADTYPE_ROAD, ROADTYPE_TRAM, RoadTypeToRoadTypes(), VehicleSettings::roadveh_acceleration_model, RVSB_IN_DEPOT, SetBit(), RoadVehicle::SetRoadVehFront(), Vehicle::spritenum, RoadVehicle::state, Vehicle::tile, TILE_SIZE, TileX(), TileY(), GameSettings::vehicle, Vehicle::vehicle_flags, VehicleMove(), VehicleRandomBits(), Vehicle::vehstatus, VF_BUILT_AS_PROTOTYPE, VS_DEFPAL, VS_HIDDEN, VS_STOPPED, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CmdBuildVehicle().
CommandCost CmdBuildShip | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
const Engine * | e, | |||
uint16 | data, | |||
Vehicle ** | ret | |||
) |
Build a ship.
tile | tile of the depot where ship is built. | |
flags | type of operation. | |
e | the engine to build. | |
data | unused. | |
ret[out] | the vehicle that has been built. |
Definition at line 589 of file ship_cmd.cpp.
References _cur_year, _current_company, _date, Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::cur_image, DC_EXEC, Vehicle::direction, ENGINE_EXCLUSIVE_PREVIEW, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Engine::GetDefaultCargoType(), Engine::GetLifeLengthInDays(), GetShipDepotNorthTile(), GetVehicleCapacity(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::InvalidateNewGRFCacheOfChain(), Vehicle::max_age, Vehicle::owner, Vehicle::reliability, Vehicle::reliability_spd_dec, SetBit(), Vehicle::spritenum, Vehicle::tile, TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, Ship::UpdateDeltaXY(), Vehicle::vehicle_flags, VehicleMove(), VehicleRandomBits(), Vehicle::vehstatus, VF_BUILT_AS_PROTOTYPE, VS_DEFPAL, VS_HIDDEN, VS_STOPPED, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CmdBuildVehicle().
CommandCost CmdBuildVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Build a vehicle.
tile | tile of depot where the vehicle is built | |
flags | for command | |
p1 | various bitstuffed data bits 0-15: vehicle type being built. bits 16-31: vehicle type specific bits passed on to the vehicle build functions. | |
p2 | User | |
text | unused |
Definition at line 84 of file vehicle_cmd.cpp.
References _current_company, AIR_CTOL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::CanAllocateItem(), CMD_ERROR, CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRoadVehicle(), CmdBuildShip(), CT_INVALID, DC_AUTOREPLACE, DC_EXEC, EXPENSES_NEW_VEHICLES, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetCost(), Engine::GetDefaultCargoType(), GetFreeUnitNumber(), GetTileType(), GetWindowClassForVehicleType(), Vehicle::group_id, InvalidateAutoreplaceWindow(), InvalidateWindowClassesData(), InvalidateWindowData(), IsDepotTile(), IsEngineBuildable(), IsLocalCompany(), Vehicle::IsPrimaryVehicle(), IsTileOwner(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_WATER, RAILVEH_MULTIHEAD, RAILVEH_WAGON, OrderBackup::Restore(), return_cmd_error, SetWindowDirty(), Vehicle::tile, Vehicle::unitnumber, Vehicle::value, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
CommandCost CmdChangeServiceInt | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Change the service interval of a vehicle.
tile | unused | |
flags | type of operation | |
p1 | vehicle ID that is being service-interval-changed | |
p2 | new service interval | |
text | unused |
Definition at line 922 of file vehicle_cmd.cpp.
References CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), GetServiceIntervalClamped(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsPrimaryVehicle(), Vehicle::owner, and SetWindowDirty().
CommandCost CmdCloneVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Clone a vehicle.
If it is a train, it will clone all the cars too
tile | tile of the depot where the cloned vehicle is build | |
flags | type of operation | |
p1 | the original vehicle's index | |
p2 | 1 = shared orders, else copied orders | |
text | unused |
Definition at line 643 of file vehicle_cmd.cpp.
References CommandCost::AddCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::CanAllocateItem(), Engine::CanCarryCargo(), Vehicle::cargo_subtype, Vehicle::cargo_type, CheckCompanyHasMoney(), CheckOwnership(), CloneVehicleName(), CMD_ADD_VEHICLE_GROUP, CMD_CLONE_ORDER, CMD_ERROR, CMD_MOVE_RAIL_VEHICLE, CT_INVALID, DC_AUTOREPLACE, DC_EXEC, DoCommand(), EXPENSES_NEW_VEHICLES, CommandCost::Failed(), SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetBestFittingSubType(), Engine::GetDefaultCargoType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Train::GetNextArticPart(), Train::GetNextVehicle(), GetRefitCost(), Vehicle::group_id, RoadVehicle::HasArticulatedPart(), Train::HasArticulatedPart(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsFrontEngine(), Vehicle::IsPrimaryVehicle(), Train::IsRearDualheaded(), Vehicle::name, Vehicle::Next(), Vehicle::owner, return_cmd_error, SetBit(), CommandCost::Succeeded(), Vehicle::tile, BaseVehicle::type, VEH_ROAD, and VEH_TRAIN.
CommandCost CmdDepotMassAutoReplace | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Autoreplace all vehicles in the depot.
tile | Tile of the depot where the vehicles are | |
flags | type of operation | |
p1 | Type of vehicle | |
p2 | unused | |
text | unused |
Definition at line 543 of file vehicle_cmd.cpp.
References _current_company, CommandCost::AddCost(), BuildDepotVehicleList(), CMD_AUTOREPLACE_VEHICLE, CMD_ERROR, DoCommand(), EXPENSES_NEW_VEHICLES, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsCompanyBuildableVehicleType(), IsDepotTile(), Vehicle::IsInDepot(), IsTileOwner(), SmallVector< T, S >::Length(), and CommandCost::Succeeded().
CommandCost CmdDepotSellAllVehicles | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Sells all vehicles in a depot.
tile | Tile of the depot where the depot is | |
flags | type of operation | |
p1 | Vehicle type | |
p2 | unused | |
text | unused |
Definition at line 506 of file vehicle_cmd.cpp.
References CommandCost::AddCost(), BuildDepotVehicleList(), CMD_ERROR, DoCommand(), EXPENSES_NEW_VEHICLES, IsCompanyBuildableVehicleType(), SmallVector< T, S >::Length(), and CommandCost::Succeeded().
CommandCost CmdMassStartStopVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Starts or stops a lot of vehicles.
tile | Tile of the depot where the vehicles are started/stopped (only used for depots) | |
flags | type of operation | |
p1 | bitmask
| |
p2 | packed VehicleListIdentifier | |
text | unused |
Definition at line 460 of file vehicle_cmd.cpp.
References BuildDepotVehicleList(), CMD_ERROR, CMD_START_STOP_VEHICLE, DoCommand(), SpecializedVehicle< Train, Type >::From(), GenerateVehicleSortList(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsCompanyBuildableVehicleType(), Train::IsInDepot(), SmallVector< T, S >::Length(), VehicleListIdentifier::Unpack(), VEH_TRAIN, Vehicle::vehstatus, VS_HIDDEN, VS_STOPPED, and VehicleListIdentifier::vtype.
CommandCost CmdRefitVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Refits a vehicle to the specified cargo type.
tile | unused | |
flags | type of operation | |
p1 | vehicle ID to refit | |
p2 | various bitstuffed elements
| |
text | unused |
Definition at line 326 of file vehicle_cmd.cpp.
References _settings_game, GroundVehicle< T, Type >::CargoChanged(), CheckOwnership(), CMD_ERROR, Vehicle::colourmap, Train::ConsistChanged(), DC_EXEC, CommandCost::Failed(), Vehicle::First(), SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::From(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), GetWindowClassForVehicleType(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::InvalidateNewGRFCacheOfChain(), InvalidateWindowClassesData(), InvalidateWindowData(), IsCompanyBuildableVehicleType(), Vehicle::IsStoppedInDepot(), NUM_CARGO, Vehicle::owner, RefitVehicle(), return_cmd_error, VehicleSettings::roadveh_acceleration_model, SetWindowDirty(), Vehicle::tile, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, GameSettings::vehicle, Vehicle::vehstatus, and VS_CRASHED.
CommandCost CmdRenameVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Give a custom name to your vehicle.
tile | unused | |
flags | type of operation | |
p1 | vehicle ID to name | |
p2 | unused | |
text | the new name or an empty string when resetting to the default |
Definition at line 887 of file vehicle_cmd.cpp.
References CheckOwnership(), CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), InvalidateWindowClassesData(), Vehicle::IsPrimaryVehicle(), IsUniqueVehicleName(), MarkWholeScreenDirty(), MAX_LENGTH_VEHICLE_NAME_CHARS, Vehicle::name, Vehicle::owner, return_cmd_error, StrEmpty(), and Utf8StringLength().
CommandCost CmdSellRailWagon | ( | DoCommandFlag | flags, | |
Vehicle * | t, | |||
uint16 | data, | |||
uint32 | user | |||
) |
Sell a (single) train wagon/engine.
flags | type of operation | |
t | the train wagon to sell | |
data | the selling mode
| |
user | the user for the order backup. |
Definition at line 1294 of file train_cmd.cpp.
References CommandCost::AddCost(), Vehicle::AddToShared(), ArrangeTrains(), OrderBackup::Backup(), Vehicle::CopyVehicleConfigAndStatistics(), DC_AUTOREPLACE, DC_EXEC, DeleteVehicleOrders(), EXPENSES_NEW_VEHICLES, CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), Vehicle::first, SpecializedVehicle< Train, Type >::From(), Train::GetFirstEnginePart(), Vehicle::group_id, HasBit(), InvalidateWindowClassesData(), InvalidateWindowData(), Train::IsEngine(), Train::IsFrontEngine(), IsLocalCompany(), Train::IsPrimaryVehicle(), Train::IsRearDualheaded(), Vehicle::list, MAKE_ORDER_BACKUP_FLAG, MakeTrainBackup(), Vehicle::Next(), NormaliseSubtypes(), NormaliseTrainHead(), RestoreTrainBackup(), return_cmd_error, ShowVehicleViewWindow(), Vehicle::tile, ValidateTrains(), and Vehicle::value.
Referenced by CmdSellVehicle().
CommandCost CmdSellVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Sell a vehicle.
tile | unused. | |
flags | for command. | |
p1 | various bitstuffed data. bits 0-19: vehicle ID being sold. bits 20-30: vehicle type specific bits passed on to the vehicle build functions. bit 31: make a backup of the vehicle's order (if an engine). | |
p2 | User. | |
text | unused. |
Definition at line 167 of file vehicle_cmd.cpp.
References OrderBackup::Backup(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_order_pool >::CanAllocateItem(), CheckOwnership(), CMD_ERROR, CmdSellRailWagon(), DC_EXEC, EXPENSES_NEW_VEHICLES, CommandCost::Failed(), Vehicle::First(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), OrderList::GetNumOrders(), Vehicle::IsPrimaryVehicle(), OrderList::IsShared(), Vehicle::IsStoppedInDepot(), Vehicle::list, MAKE_ORDER_BACKUP_FLAG, Vehicle::owner, return_cmd_error, BaseVehicle::type, Vehicle::value, VEH_TRAIN, Vehicle::vehstatus, and VS_CRASHED.
CommandCost CmdSendVehicleToDepot | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Send a vehicle to the depot.
tile | unused | |
flags | for command type | |
p1 | bitmask
| |
p2 | packed VehicleListIdentifier. | |
text | unused |
Definition at line 863 of file vehicle_cmd.cpp.
References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), SendAllVehiclesToDepot(), Vehicle::SendToDepot(), and VehicleListIdentifier::Unpack().
CommandCost CmdStartStopVehicle | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Start/Stop a vehicle.
tile | unused | |
flags | type of operation | |
p1 | vehicle to start/stop, don't forget to change CcStartStopVehicle if you modify this! | |
p2 | bit 0: Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety) | |
text | unused |
Definition at line 396 of file vehicle_cmd.cpp.
References GroundVehicleCache::cached_power, CALLBACK_FAILED, CBID_VEHICLE_START_STOP_CHECK, CheckOwnership(), CMD_ERROR, Vehicle::cur_speed, DC_AUTOREPLACE, DC_EXEC, DeleteVehicleNews(), error(), CommandCost::Failed(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Train, Type >::From(), GB(), GroundVehicle< T, Type >::gcache, GetEngineGRFID(), GetGRFStringID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), GetVehicleCallback(), GetWindowClassForVehicleType(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsPrimaryVehicle(), Vehicle::IsStoppedInDepot(), Vehicle::MarkDirty(), Vehicle::owner, return_cmd_error, SetBit(), SetWindowClassesDirty(), SetWindowDirty(), SetWindowWidgetDirty(), STARTTAKEOFF, Aircraft::state, TERM7, Vehicle::tile, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, Vehicle::vehstatus, VS_CRASHED, and VS_STOPPED.
static CommandCost GetRefitCost | ( | EngineID | engine_type | ) | [static] |
Learn the price of refitting a certain engine.
engine_type | Which engine to refit |
Definition at line 210 of file vehicle_cmd.cpp.
References EXPENSES_AIRCRAFT_RUN, EXPENSES_ROADVEH_RUN, EXPENSES_SHIP_RUN, EXPENSES_TRAIN_RUN, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetPrice(), Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, RAILVEH_WAGON, Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by CmdCloneVehicle(), and RefitVehicle().
static bool IsUniqueVehicleName | ( | const char * | name | ) | [static] |
Test if a name is unique among vehicle names.
name | Name to test. |
Definition at line 573 of file vehicle_cmd.cpp.
References Vehicle::name.
Referenced by CloneVehicleName(), and CmdRenameVehicle().
static CommandCost RefitVehicle | ( | Vehicle * | v, | |
bool | only_this, | |||
uint8 | num_vehicles, | |||
CargoID | new_cid, | |||
byte | new_subtype, | |||
DoCommandFlag | flags | |||
) | [static] |
Refits a vehicle (chain).
This is the vehicle-type independent part of the CmdRefitXXX functions.
v | The vehicle to refit. | |
only_this | Whether to only refit this vehicle, or to check the rest of them. | |
num_vehicles | Number of vehicles to refit. Zero means the whole chain. | |
new_cid | Cargotype to refit to | |
new_subtype | Cargo subtype to refit to | |
flags | Command flags |
Definition at line 254 of file vehicle_cmd.cpp.
References _returned_mail_refit_capacity, _returned_refit_capacity, Engine::CanCarryCargo(), Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_subtype, Vehicle::cargo_type, SmallVector< T, S >::Contains(), DC_EXEC, Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Vehicle::GetExpenseType(), GetRefitCost(), GetVehicleCapacity(), GetVehicleSet(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::InvalidateNewGRFCacheOfChain(), Vehicle::Next(), CargoList< Tinst >::Truncate(), BaseVehicle::type, VEH_AIRCRAFT, and VEH_TRAIN.
Referenced by CmdRefitVehicle().
static CommandCost SendAllVehiclesToDepot | ( | DoCommandFlag | flags, | |
bool | service, | |||
const VehicleListIdentifier & | vli | |||
) | [static] |
Send all vehicles of type to depots.
flags | the flags used for DoCommand() | |
service | should the vehicles only get service in the depots | |
vli | identifier of the vehicle list |
Definition at line 826 of file vehicle_cmd.cpp.
References CMD_ERROR, DC_EXEC, DEPOT_DONT_CANCEL, DEPOT_SERVICE, DoCommand(), GenerateVehicleSortList(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, SmallVector< T, S >::Length(), CommandCost::Succeeded(), Vehicle::tile, and VehicleListIdentifier::vtype.
Referenced by CmdSendVehicleToDepot().
const uint32 _send_to_depot_proc_table[] |
{ CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT) | CMD_NO_TEST_IF_IN_NETWORK, CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT), CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT), CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR), }
Definition at line 59 of file vehicle_cmd.cpp.
const uint32 _veh_build_proc_table[] |
{ CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN), CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_ROAD_VEHICLE), CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_SHIP), CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_AIRCRAFT), }
Definition at line 38 of file vehicle_cmd.cpp.
const uint32 _veh_refit_proc_table[] |
{ CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_TRAIN), CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_ROAD_VEHICLE), CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_SHIP), CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_AIRCRAFT), }
Definition at line 52 of file vehicle_cmd.cpp.
const uint32 _veh_sell_proc_table[] |
{ CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_TRAIN), CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_ROAD_VEHICLE), CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_SHIP), CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_AIRCRAFT), }
Definition at line 45 of file vehicle_cmd.cpp.