# command.cpp File Reference

Handling of commands. More...

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "landscape.h"`
`#include "gui.h"`
`#include "command_func.h"`
`#include "network/network.h"`
`#include "genworld.h"`
`#include "newgrf_storage.h"`
`#include "strings_func.h"`
`#include "gfx_func.h"`
`#include "functions.h"`
`#include "town.h"`
`#include "date_func.h"`
`#include "debug.h"`
`#include "company_func.h"`
`#include "company_base.h"`
`#include "signal_func.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Defines

#define | DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Helper macro to define the header of all command handler macros.

## Functions

CommandCost | CmdBuildRailroadTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build rail on a stretch of track.
CommandCost | CmdRemoveRailroadTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build rail on a stretch of track.
CommandCost | CmdBuildSingleRail (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a single piece of rail.
CommandCost | CmdRemoveSingleRail (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a single piece of track.
CommandCost | CmdLandscapeClear (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Clear a piece of landscape.
CommandCost | CmdBuildBridge (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a Bridge.
CommandCost | CmdBuildRailStation (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build rail station.
CommandCost | CmdRemoveFromRailStation (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a single tile from a rail station.
CommandCost | CmdConvertRail (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Convert one rail type to the other.
CommandCost | CmdBuildSingleSignal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals, and what-else not.
CommandCost | CmdRemoveSingleSignal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove signals.
CommandCost | CmdTerraformLand (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Terraform land.
CommandCost | CmdPurchaseLandArea (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Purchase a land area.
CommandCost | CmdSellLandArea (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Sell a land area.
CommandCost | CmdBuildTunnel (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build Tunnel.
CommandCost | CmdBuildTrainDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a train depot.
CommandCost | CmdBuildRailWaypoint (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Convert existing rail to waypoint.
CommandCost | CmdRenameWaypoint (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Rename a waypoint.
CommandCost | CmdRemoveFromRailWaypoint (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a single tile from a waypoint.
CommandCost | CmdBuildRoadStop (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a bus or truck stop.
CommandCost | CmdRemoveRoadStop (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a bus or truck stop.
CommandCost | CmdBuildLongRoad (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a long piece of road.
CommandCost | CmdRemoveLongRoad (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a long piece of road.
CommandCost | CmdBuildRoad (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a piece of road.
CommandCost | CmdRemoveRoad (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Delete a piece of road.
CommandCost | CmdBuildRoadDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a road depot.
CommandCost | CmdBuildAirport (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Place an Airport.
CommandCost | CmdBuildDock (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a dock/haven.
CommandCost | CmdBuildShipDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a ship depot.
CommandCost | CmdBuildBuoy (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a buoy.
CommandCost | CmdPlantTree (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Plant a tree.
CommandCost | CmdBuildRailVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a railroad vehicle.
CommandCost | CmdMoveRailVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Move a rail vehicle around inside the depot.
CommandCost | CmdSellRailWagon (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Sell a (single) train wagon/engine.
CommandCost | CmdSendTrainToDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Send a train to a depot.
CommandCost | CmdForceTrainProceed (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Force a train through a red signal.
CommandCost | CmdReverseTrainDirection (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Reverse train.
CommandCost | CmdModifyOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Modify an order in the orderlist of a vehicle.
CommandCost | CmdSkipToOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Goto order of order-list.
CommandCost | CmdDeleteOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Delete an order from the orderlist of a vehicle.
CommandCost | CmdInsertOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Add an order to the orderlist of a vehicle.
CommandCost | CmdChangeServiceInt (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the service interval of a vehicle.
CommandCost | CmdRestoreOrderIndex (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Restore the current order-index of a vehicle and sets service-interval.
CommandCost | CmdBuildIndustry (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build/Fund an industry.
CommandCost | CmdBuildCompanyHQ (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build or relocate the HQ.
CommandCost | CmdSetCompanyManagerFace (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the company manager's face.
CommandCost | CmdSetCompanyColour (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the company's company-colour.
CommandCost | CmdIncreaseLoan (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Increase the loan of your company.
CommandCost | CmdDecreaseLoan (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Decrease the loan of your company.
CommandCost | CmdWantEnginePreview (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Accept an engine prototype.
CommandCost | CmdRenameVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Give a custom name to your vehicle.
CommandCost | CmdRenameEngine (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Rename an engine.
CommandCost | CmdRenameCompany (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the name of the company.
CommandCost | CmdRenamePresident (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the name of the president.
CommandCost | CmdRenameStation (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Rename a station.
CommandCost | CmdSellAircraft (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Sell an aircraft.
CommandCost | CmdBuildAircraft (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build an aircraft.
CommandCost | CmdSendAircraftToHangar (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Send an aircraft to the hangar.
CommandCost | CmdRefitAircraft (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Refits an aircraft to the specified cargo type.
CommandCost | CmdPlaceSign (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Place a sign at the given coordinates.
CommandCost | CmdRenameSign (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Rename a sign.
CommandCost | CmdBuildRoadVeh (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a road vehicle.
CommandCost | CmdSellRoadVeh (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Sell a road vehicle.
CommandCost | CmdSendRoadVehToDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Send a road vehicle to the depot.
CommandCost | CmdTurnRoadVeh (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Turn a roadvehicle around.
CommandCost | CmdRefitRoadVeh (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Refit a road vehicle to the specified cargo type.
CommandCost | CmdPause (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Pause/Unpause the game (server-only).
CommandCost | CmdBuyShareInCompany (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Acquire shares in an opposing company.
CommandCost | CmdSellShareInCompany (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Sell shares in an opposing company.
CommandCost | CmdBuyCompany (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Buy up another company.
CommandCost | CmdFoundTown (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Create a new town.
CommandCost | CmdRenameTown (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Rename a town (server-only).
CommandCost | CmdDoTownAction (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Do a town action.
CommandCost | CmdChangeSetting (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Network-safe changing of settings (server-only).
CommandCost | CmdChangeCompanySetting (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change one of the per-company settings.
CommandCost | CmdSellShip (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Sell a ship.
CommandCost | CmdBuildShip (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a ship.
CommandCost | CmdSendShipToDepot (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Send a ship to the depot.
CommandCost | CmdRefitShip (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Refits a ship to the specified cargo type.
CommandCost | CmdOrderRefit (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Add/remove refit orders from an order.
CommandCost | CmdCloneOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Clone/share/copy an order-list of an other vehicle.
CommandCost | CmdClearArea (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Clear a big piece of landscape.
CommandCost | CmdGiveMoney (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Transfer funds (money) from one company to another.
CommandCost | CmdMoneyCheat (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the financial flow of your company.
CommandCost | CmdBuildCanal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a piece of canal.
CommandCost | CmdBuildLock (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Builds a lock (ship-lift).
CommandCost | CmdCompanyCtrl (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Control the companies: add, delete, etc.
CommandCost | CmdLevelLand (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Levels a selected (rectangle) area of land.
CommandCost | CmdRefitRailVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Refits a train to the specified cargo type.
CommandCost | CmdBuildSignalTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build signals on a stretch of track.
CommandCost | CmdRemoveSignalTrack (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove signals on a stretch of track.
CommandCost | CmdSetAutoReplace (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change engine renewal parameters.
CommandCost | CmdCloneVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Clone a vehicle.
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 | CmdAutoreplaceVehicle (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Autoreplaces a vehicle Trains are replaced as a whole chain, free wagons in depot are replaced on their own.
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 Note: this command can make incorrect cost estimations Luckily the final price can only drop, not increase.
CommandCost | CmdCreateGroup (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Create a new vehicle group.
CommandCost | CmdRenameGroup (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Rename a group.
CommandCost | CmdDeleteGroup (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Add all vehicles in the given group to the default group and then deletes the group.
CommandCost | CmdAddVehicleGroup (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Add a vehicle to a group.
CommandCost | CmdAddSharedVehicleGroup (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Add all shared vehicles of all vehicles from a group.
CommandCost | CmdRemoveAllVehiclesGroup (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove all vehicles from a group.
CommandCost | CmdSetGroupReplaceProtection (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| (Un)set global replace protection from a group
CommandCost | CmdMoveOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Move an order inside the orderlist.
CommandCost | CmdChangeTimetable (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Add or remove waiting times from an order.
CommandCost | CmdSetVehicleOnTime (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Clear the lateness counter to make the vehicle on time.
CommandCost | CmdAutofillTimetable (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Start or stop filling the timetable automatically from the time the vehicle actually takes to complete it.
CommandCost | CmdSetTimetableStart (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Set the start date of the timetable.
bool | IsValidCommand (uint32 cmd)
| Checks if a integer value belongs to a command.
byte | GetCommandFlags (uint32 cmd)
| Returns the flags from a given command.
CommandCost | DoCommand (const CommandContainer *container, DoCommandFlag flags)
| Shorthand for calling the long DoCommand with a container.
CommandCost | DoCommand (TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text)
| Execute a command.
Money | GetAvailableMoneyForCommand ()
| Returns the current money available which can be used for a command.
bool | DoCommandP (const CommandContainer *container, bool my_cmd)
| Shortcut for the long DoCommandP when having a container with the data.
bool | DoCommandP (TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd)
| Execute a network safe DoCommand function.

## Variables

StringID | _error_message
static const Command | _command_proc_table []
| The master command table.
static int | _docommand_recursive = 0

## Detailed Description

Handling of commands.

Definition in file command.cpp.

## Define Documentation

#define DEF_COMMAND | ( | yyyy |  | ) | CommandCost yyyy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)

Helper macro to define the header of all command handler macros.

This macro create the function header for a given command handler function, as all command handler functions got the parameters from the CommandProc callback type.

Parameters:

  | yyyy | The desired function name of the new command handler function.

Definition at line 43 of file command.cpp.

## Function Documentation

CommandCost CmdAddSharedVehicleGroup | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Add all shared vehicles of all vehicles from a group.

Parameters:

  | tile | unused
  | flags | type of operation

  p1

  index of group array
  - p1 bit 0-15 : GroupID

  | p2 | type of vehicles
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 259 of file group_cmd.cpp.

References CMD_ERROR, CmdAddVehicleGroup(), DC_EXEC, GetWindowClassForVehicleType(), and InvalidateWindowData().

CommandCost CmdAddVehicleGroup | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Add a vehicle to a group.

Parameters:

  | tile | unused
  | flags | type of operation

  p1

  index of array group
  - p1 bit 0-15 : GroupID

  p2

  vehicle to add to a group
  - p2 bit 0-15 : VehicleID

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 210 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, SpecializedVehicle< Train, VEH_TRAIN >::From(), GetWindowClassForVehicleType(), InvalidateWindowData(), SetTrainGroupID(), SetWindowDirty(), UpdateNumEngineGroup(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by CmdAddSharedVehicleGroup(), and CmdRemoveAllVehiclesGroup().

CommandCost CmdAutofillTimetable | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Start or stop filling the timetable automatically from the time the vehicle actually takes to complete it.

When starting to autofill the current times are cleared and the timetable will start again from scratch.

Parameters:

  | tile | Not used.
  | flags | Operation to perform.
  | p1 | Vehicle index.

  p2

  Various bitstuffed elements
  - p2 = (bit 0) - Set to 1 to enable, 0 to disable autofill.
  - p2 = (bit 1) - Set to 1 to preserve waiting times in non-destructive mode

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 186 of file timetable_cmd.cpp.

References _settings_game, ClrBit(), CMD_ERROR, DC_EXEC, GB(), HasBit(), GameSettings::order, SetBit(), SetWindowDirty(), OrderSettings::timetabling, VF_AUTOFILL_PRES_WAIT_TIME, VF_AUTOFILL_TIMETABLE, and VF_TIMETABLE_STARTED.

CommandCost CmdAutoreplaceVehicle | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Autoreplaces a vehicle Trains are replaced as a whole chain, free wagons in depot are replaced on their own.

Parameters:

  | tile | not used
  | flags | type of operation
  | p1 | Index of vehicle
  | p2 | not used
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 624 of file autoreplace_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), SpecializedVehicle< Train, VEH_TRAIN >::From(), CommandCost::GetCost(), GetNewEngineType(), Train::GetNextUnit(), Train::IsArticulatedPart(), Train::IsFrontEngine(), Train::IsRearDualheaded(), ReplaceChain(), ReplaceFreeUnit(), RestoreRandomSeeds(), SaveRandomSeeds(), StartStopVehicle(), CommandCost::Succeeded(), and VEH_TRAIN.

CommandCost CmdBuildAircraft | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build an aircraft.

Parameters:

  | tile | tile of depot where aircraft is built
  | flags | for command
  | p1 | aircraft type being built (engine)
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 237 of file aircraft_cmd.cpp.

References _cur_year, _date, _settings_game, AIR_AIRCRAFT, AIR_HELICOPTER, AIR_ROTOR, AIR_SHADOW, Aircraft::Aircraft(), Station::Airport(), AirportFTAClass::airport_depots, Station::airport_tile, CanVehicleUseStation(), CheckInfraUsageAllowed(), CMD_ERROR, CT_INVALID, DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, DIR_N, DIR_SE, ENGINE_EXCLUSIVE_PREVIEW, SpecializedStation< Station, false >::GetByTile(), GetStationIndex(), GetTileOwner(), GetVehicleCapacity(), AirportFTA::heading, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIR, InvalidateAutoreplaceWindow(), InvalidateWindowClassesData(), InvalidateWindowData(), IsEngineBuildable(), AirportFTAClass::layout, VehicleSettings::max_aircraft, AirportFTAClass::nof_depots, Aircraft::pos, AirportFTA::position, Aircraft::previous_pos, return_cmd_error, SetBit(), SetWindowDirty(), Aircraft::state, Aircraft::targetairport, TILE_SIZE, TileX(), TileY(), ToTileIndexDiff(), UpdateAircraftCache(), Aircraft::UpdateDeltaXY(), VEH_AIRCRAFT, GameSettings::vehicle, VehicleMove(), and VehicleRandomBits().

CommandCost CmdBuildAirport | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Place an Airport.

Parameters:

  | tile | tile where airport will be built
  | flags | operation to perform
  | p1 | airport type,

See also:
  airport.h

Parameters:

  p2

  various bitstuffed elements
  - p2 = (bit 0) - allow airports directly adjacent to other airports.
  - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1893 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), Station::AddFacility(), Station::airport_flags, Station::airport_tile, Station::airport_type, AirportGetNearestTown(), StationRect::BeforeAddRect(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem(), CheckFlatLandBelow(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CmdFailed(), DC_EXEC, StationSettings::distant_join_stations, GameSettings::economy, FACIL_AIRPORT, BaseStation::facilities, FindJoiningStation(), AirportFTAClass::flags, GB(), GetAirportNoiseLevelForTown(), GetClosestDeletedStation(), SpecializedStation< Station, false >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, InvalidateWindowData(), AirportFTAClass::IsAvailable(), SpecializedStation< Station, false >::IsValidID(), BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, SetBit(), SetDParam(), SetWindowDirty(), SetWindowWidgetDirty(), AirportFTAClass::size_x, AirportFTAClass::size_y, GameSettings::station, EconomySettings::station_noise_level, StationSettings::station_spread, BaseStation::string_id, SVW_PLANES, TILE_LOOP, BaseStation::town, UpdateAirplanesOnNewStation(), UpdateStationAcceptance(), and Station::UpdateVirtCoord().

CommandCost CmdBuildBridge | ( | TileIndex | end_tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a Bridge.

Parameters:

  | end_tile | end tile
  | flags | type of operation
  | p1 | packed start tile coords (~ dx)

  p2

  various bitstuffed elements
  - p2 = (bit 0- 7) - bridge type (hi bh)
  - p2 = (bit 8-14) - rail type or road types.
  - p2 = (bit 15-16) - transport type.

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 189 of file tunnelbridge_cmd.cpp.

References _settings_game, CommandCost::AddCost(), AddSideToSignalBuffer(), AreValidRoadTypes(), AXIS_X, AXIS_Y, AxisToDiagDir(), AxisToTrack(), ConstructionSettings::build_on_slopes, CalcBridgeLenCostFactor(), CheckBridgeSlopeNorth(), CheckBridgeSlopeSouth(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), GameSettings::construction, DC_EXEC, DiagDirToAxis(), DoCommand(), GB(), GetBridgeAxis(), GetBridgeHeight(), GetBridgeType(), CommandCost::GetCost(), GetNorthernBridgeEnd(), GetOtherBridgeEnd(), GetRailType(), GetTileMaxZ(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasRoadTypesAvail(), INVALID_DIAGDIR, INVALID_RAILTYPE, IsBridgeAbove(), IsBridgeTile(), IsOwnedLand(), IsPlainRail(), IsTileOwner(), IsTunnel(), IsWater(), ConstructionSettings::longbridges, MakeAqueductBridgeRamp(), MakeRailBridgeRamp(), MakeRoadBridgeRamp(), MapSize(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), MP_CLEAR, MP_RAILWAY, MP_ROAD, MP_TUNNELBRIDGE, MP_UNMOVABLE, MP_WATER, OWNER_TOWN, return_cmd_error, ReverseDiagDir(), ROADTYPES_NONE, SetBridgeMiddle(), SetDParam(), SLOPE_FLAT, Swap(), TILE_HEIGHT, TileDiffXY(), TileX(), TileY(), TRANSPORT_RAIL, TRANSPORT_ROAD, TRANSPORT_WATER, ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildBuoy | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a buoy.

Parameters:

  | tile | tile where to place the bouy
  | flags | operation to perform
  | p1 | unused
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 333 of file waypoint_cmd.cpp.

References _date, DC_EXEC, FACIL_DOCK, FindDeletedWaypointCloseTo(), GetTileSlope(), InvalidateWindowData(), IsBridgeAbove(), MakeDefaultWaypointName(), MayHaveBridgeAbove(), OWNER_NONE, return_cmd_error, and SLOPE_FLAT.

CommandCost CmdBuildCanal | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a piece of canal.

Parameters:

  | tile | end tile of stretch-dragging
  | flags | type of operation
  | p1 | start tile of stretch-dragging
  | p2 | specifies canal (0), water (1) or river (2); last two can only be built in scenario editor
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 296 of file water_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DoCommand(), CommandCost::GetCost(), GetTileSlope(), IsInclinedSlope(), IsTileOwner(), IsTileType(), MakeCanal(), MakeRiver(), MakeSea(), MapSize(), MarkCanalsAndRiversAroundDirty(), MarkTileDirtyByTile(), MP_WATER, OWNER_WATER, return_cmd_error, SLOPE_FLAT, Swap(), TILE_LOOP, TileHeight(), TileX(), TileXY(), and TileY().

CommandCost CmdBuildCompanyHQ | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build or relocate the HQ.

This depends if the HQ is already built or not

Parameters:

  | tile | tile where the HQ will be built or relocated to
  | flags | type of operation
  | p1 | unused
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 109 of file unmovable_cmd.cpp.

References CommandCost::AddCost(), CheckFlatLandBelow(), CmdFailed(), DC_EXEC, DestroyCompanyHQ(), INVALID_TILE, MakeCompanyHQ(), SetWindowDirty(), and UpdateCompanyRatingAndValue().

CommandCost CmdBuildDock | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a dock/haven.

Parameters:

  | tile | tile where dock will be built
  | flags | operation to perform
  | p1 | (bit 0) - allow docks directly adjacent to other docks.
  | p2 | bit 16-31: station ID to join (NEW_STATION if build new one)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 2145 of file station_cmd.cpp.

References _settings_game, Station::AddFacility(), StationRect::BeforeAddRect(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, StationSettings::distant_join_stations, Station::dock_tile, DoCommand(), FACIL_DOCK, FindJoiningStation(), GB(), GetClosestDeletedStation(), SpecializedStation< Station, false >::GetIfValid(), GetInclinedSlopeDirection(), GetTileSlope(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIAGDIR, INVALID_TILE, InvalidateWindowData(), IsBridgeAbove(), IsTileType(), SpecializedStation< Station, false >::IsValidID(), MayHaveBridgeAbove(), MP_WATER, BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ReverseDiagDir(), SetBit(), SetWindowWidgetDirty(), SLOPE_FLAT, GameSettings::station, BaseStation::string_id, SVW_SHIPS, TileOffsByDiagDir(), ToTileIndexDiff(), BaseStation::town, UpdateStationAcceptance(), and Station::UpdateVirtCoord().

CommandCost CmdBuildIndustry | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build/Fund an industry.

Parameters:

  | tile | tile where industry is built
  | flags | of operations to conduct

  p1

  various bitstuffed elements
  - p1 = (bit 0 - 7) - industry type see build_industry.h and see industry.h
  - p1 = (bit 8 - 15) - first layout to try

  | p2 | seed to use for variable 8F
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1723 of file industry_cmd.cpp.

References _settings_game, CMD_ERROR, GameSettings::construction, CreateNewIndustryHelper(), IndustrySpec::enabled, GB(), IndustrySpec::GetConstructionCost(), GetIndustrySpec(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IndustrySpec::IsRawIndustry(), IndustrySpec::name, IndustrySpec::new_industry_text, NS_INDUSTRY_OPEN, NUM_INDUSTRYTYPES, IndustrySpec::num_table, OWNER_TOWN, IndustrySpec::prospecting_chance, RandomTile, ConstructionSettings::raw_industry_construction, SetDParam(), IndustrySpec::table, and Industry::town.

CommandCost CmdBuildLock | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Builds a lock (ship-lift).

Parameters:

  | tile | tile where to place the lock
  | flags | type of operation
  | p1 | unused
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 277 of file water_cmd.cpp.

References DoBuildShiplift(), GetInclinedSlopeDirection(), GetTileSlope(), INVALID_DIAGDIR, and return_cmd_error.

CommandCost CmdBuildLongRoad | ( | TileIndex | end_tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a long piece of road.

Parameters:

  | end_tile | end tile of drag
  | flags | operation to perform
  | p1 | start tile of drag

  p2

  various bitstuffed elements
  - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
  - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
  - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
  - p2 = (bit 3 + 4) - road type
  - p2 = (bit 5) - set road direction

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 712 of file road_cmd.cpp.

References CommandCost::AddCost(), CMD_BUILD_ROAD, CMD_ERROR, CmdFailed(), DIAGDIR_SE, DIAGDIR_SW, DoCommand(), DRD_BOTH, DRD_NONE, DRD_NORTHBOUND, DRD_SOUTHBOUND, GB(), GetTunnelBridgeDirection(), HasBit(), INVALID_STRING_ID, IsBridge(), IsInsideMM(), IsTileType(), IsValidRoadType(), MapSize(), MP_TUNNELBRIDGE, ROAD_NE, ROAD_NW, ROAD_SE, ROAD_SW, ROAD_X, ROAD_Y, TileDiffXY(), TileX(), TileY(), and ValParamRoadType().

CommandCost CmdBuildRailroadTrack | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build rail on a stretch of track.

Stub for the unified rail builder/remover

Parameters:

  | tile | start tile of drag
  | flags | operation to perform
  | p1 | end tile of drag

  p2

  various bitstuffed elements
  - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
  - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
  - p2 = (bit 7) - 0 = build, 1 = remove tracks

  | text | unused

Returns:
  the cost of this operation or an error

See also:
  CmdRailTrackHelper

Definition at line 734 of file rail_cmd.cpp.

References ClrBit(), and CmdRailTrackHelper().

CommandCost CmdBuildRailStation | ( | TileIndex | tile_org,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build rail station.

Parameters:

  | tile_org | northern most position of station dragging/placement
  | flags | operation to perform

  p1

  various bitstuffed elements
  - p1 = (bit 0- 3) - railtype
  - p1 = (bit 4) - orientation (Axis)
  - p1 = (bit 8-15) - number of tracks
  - p1 = (bit 16-23) - platform length
  - p1 = (bit 24) - allow stations directly adjacent to other stations.

  p2

  various bitstuffed elements
  - p2 = (bit 0- 7) - custom station class
  - p2 = (bit 8-15) - custom station id
  - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 949 of file station_cmd.cpp.

References _settings_game, Station::AddFacility(), AddTrackToSignalBuffer(), AllocaM, AllocateSpecToStation(), SmallVector< T, S >::Append(), AXIS_X, AxisToTrack(), StationRect::BeforeAddRect(), BaseStation::cached_anim_triggers, CALLBACK_FAILED, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem(), CanExpandRailStation(), CBID_STATION_AVAILABILITY, CBID_STATION_TILE_LAYOUT, CBM_STATION_AVAIL, CheckFlatLandBelow(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CmdFailed(), DC_EXEC, DeallocateSpecFromStation(), DeleteAnimatedTile(), StationSettings::distant_join_stations, FACIL_TRAIN, FindJoiningStation(), FreeTrainTrackReservation(), GB(), GetClosestDeletedStation(), CommandCost::GetCost(), GetCustomStationSpec(), GetNumCustomStations(), GetNumStationClasses(), GetTrainForReservation(), Train::GetVehicleTrackdir(), HasBit(), HasStationReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, InvalidateWindowData(), IsRailStationTile(), IsTileType(), SpecializedStation< Station, false >::IsValidID(), StationSettings::join_stations, SmallVector< T, S >::Length(), Station::MarkTilesDirty(), MP_STATION, SpecializedVehicle< T, Type >::Next(), StationSettings::nonuniform_stations, BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ReverseTrackdir(), SetBit(), SetRailStationPlatformReservation(), SetStationAnimationFrame(), SetStationGfx(), SetWindowWidgetDirty(), GameSettings::station, StationSettings::station_spread, BaseStation::string_id, SVW_TRAINS, TileArea::tile, TileDiffXY(), BaseStation::town, TrackdirToExitdir(), BaseStation::train_station, TryPathReserve(), UpdateStationAcceptance(), Station::UpdateVirtCoord(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildRailVehicle | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a railroad vehicle.

Parameters:

  | tile | tile of the depot where rail-vehicle is built
  | flags | type of operation
  | p1 | engine type id
  | p2 | bit 1 prevents any free cars from being added to the train
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 838 of file train_cmd.cpp.

References _cur_year, _date, _settings_game, CheckConsistencyOfArticulatedVehicle(), CheckInfraUsageAllowed(), CMD_ERROR, CmdBuildRailWagon(), CT_INVALID, DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, DEFAULT_GROUP, DiagDirToDir(), ENGINE_EXCLUSIVE_PREVIEW, TrainCache::first_engine, GetRailDepotDirection(), GetRailType(), GetTileOwner(), HasBit(), HasPowerOnRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateAutoreplaceWindow(), InvalidateWindowClassesData(), InvalidateWindowData(), IsEngineBuildable(), IsRailDepotTile(), VehicleSettings::max_trains, NormalizeTrainVehInDepot(), Train::railtype, RAILVEH_MULTIHEAD, RAILVEH_WAGON, return_cmd_error, SetBit(), Train::SetEngine(), Train::SetFrontEngine(), SetWindowDirty(), Train::tcache, TILE_SIZE, TileX(), TileY(), Train::track, TRACK_BIT_DEPOT, Train::Train(), TrainConsistChanged(), UpdateTrainGroupID(), VEH_TRAIN, GameSettings::vehicle, VehicleMove(), and VehicleRandomBits().

CommandCost CmdBuildRailWaypoint | ( | TileIndex | start_tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Convert existing rail to waypoint.

Eg build a waypoint station over piece of rail

Parameters:

  | start_tile | northern most tile where waypoint will be built
  | flags | type of operation

  p1

  various bitstuffed elements
  - p1 = (bit 4) - orientation (Axis)
  - p1 = (bit 8-15) - width of waypoint
  - p1 = (bit 16-23) - height of waypoint
  - p1 = (bit 24) - allow waypoints directly adjacent to other waypoints.

  p2

  various bitstuffed elements
  - p2 = (bit 0- 7) - custom station class
  - p2 = (bit 8-15) - custom station id

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 213 of file waypoint_cmd.cpp.

References _date, _settings_game, AllocaM, AllocateSpecToStation(), AXIS_X, AxisToDiagDir(), AxisToTrack(), CanExpandRailStation(), CMD_ERROR, DC_EXEC, DeallocateSpecFromStation(), StationSettings::distant_join_stations, FACIL_TRAIN, CommandCost::Failed(), FindDeletedWaypointCloseTo(), FindJoiningWaypoint(), GB(), GetCustomStationSpec(), GetNumCustomStations(), GetRailReservationTrackBits(), GetRailType(), GetTileOwner(), HasBit(), HasStationReservation(), INVALID_TILE, IsTileType(), IsValidTileForWaypoint(), MakeDefaultWaypointName(), MarkTileDirtyByTile(), MP_RAILWAY, MP_STATION, StationSettings::nonuniform_stations, OtherAxis(), return_cmd_error, SetRailStationReservation(), STAT_CLASS_WAYP, GameSettings::station, StationSettings::station_spread, TileOffsByDiagDir(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildRoad | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a piece of road.

Parameters:

  | tile | tile where to build road
  | flags | operation to perform
  | p1 | bit 0..3 road pieces to build (RoadBits) bit 4..5 road type bit 6..7 disallowed directions to toggle
  | p2 | the town that is building the road (0 if not applicable)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 458 of file road_cmd.cpp.

References _settings_game, CommandCost::AddCost(), AXIS_X, AXIS_Y, AxisToRoadBits(), AxisToTrack(), ConstructionSettings::build_on_slopes, CheckRoadSlope(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), ComplementRoadBits(), GameSettings::construction, CountBits(), DC_EXEC, DiagDirToAxis(), DiagDirToRoadBits(), DoCommand(), DRD_NONE, GB(), GetAnyRoadBits(), CommandCost::GetCost(), GetDisallowedRoadDirections(), GetOtherRoadBits(), GetOtherTunnelBridgeEnd(), GetRailReservationTrackBits(), GetRailTileType(), GetRailType(), GetRoadFoundation(), GetRoadStopDir(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasBit(), HasVehicleOnTunnelBridge(), IsBridge(), IsDriveThroughStopTile(), IsSteepSlope(), IsStraightRoad(), IsTileType(), IsValidRoadType(), MarkTileDirtyByTile(), MirrorRoadBits(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, CommandCost::MultiplyCost(), OtherAxis(), OWNER_NONE, OWNER_TOWN, RAIL_TILE_NORMAL, return_cmd_error, ROAD_NONE, ROAD_X, ROAD_Y, ROADTYPE_END, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ROAD, RoadTypeToRoadTypes(), SetCrossingReservation(), SetDisallowedRoadDirections(), SetTownIndex(), TileOffsByDiagDir(), TRACK_BIT_X, TRACK_BIT_Y, TRANSPORT_ROAD, UpdateLevelCrossing(), ValParamRoadType(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildRoadDepot | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a road depot.

Parameters:

  | tile | tile where to build the depot
  | flags | operation to perform
  | p1 | bit 0..1 entrance direction (DiagDirection) bit 2..3 road type
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Todo:
  When checking for the tile slope, distingush between "Flat land required" and "land sloped in wrong direction"

Definition at line 867 of file road_cmd.cpp.

References _settings_game, CommandCost::AddCost(), ConstructionSettings::build_on_slopes, CanBuildDepotByTileh(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), GameSettings::construction, DC_EXEC, DoCommand(), GB(), GetTileSlope(), IsBridgeAbove(), IsSteepSlope(), IsValidRoadType(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), return_cmd_error, SLOPE_FLAT, and ValParamRoadType().

CommandCost CmdBuildRoadStop | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a bus or truck stop.

Parameters:

  | tile | tile to build the stop at
  | flags | operation to perform
  | p1 | entrance direction (DiagDirection)
  | p2 | bit 0: 0 for Bus stops, 1 for truck stops bit 1: 0 for normal, 1 for drive-through bit 2..3: the roadtypes bit 5: allow stations directly adjacent to other stations. bit 16..31: station ID to join (NEW_STATION if build new one)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1505 of file station_cmd.cpp.

References _settings_game, TileArea::Add(), CommandCost::AddCost(), Station::AddFacility(), AreValidRoadTypes(), AXIS_X, StationRect::BeforeAddTile(), Station::bus_station, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem(), CheckFlatLandBelow(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CmdFailed(), GameSettings::construction, CountBits(), DC_EXEC, StationSettings::distant_join_stations, FACIL_BUS_STOP, FACIL_TRUCK_STOP, FindJoiningStation(), FindRoadStopSpot(), GB(), GetAllRoadBits(), GetClosestDeletedStation(), HasBit(), HasRoadTypesAvail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowData(), IsValidAxis(), IsValidDiagDirection(), SpecializedStation< Station, false >::IsValidID(), RoadStop::MakeDriveThrough(), BaseStation::owner, OWNER_NONE, OWNER_TOWN, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ConstructionSettings::road_stop_on_competitor_road, ConstructionSettings::road_stop_on_town_road, ROAD_X, ROAD_Y, ROADSTOP_BUS, ROADSTOP_TRUCK, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, SetBit(), SetWindowWidgetDirty(), GameSettings::station, BaseStation::string_id, SVW_ROADVEHS, BaseStation::town, Station::truck_station, UpdateStationAcceptance(), and Station::UpdateVirtCoord().

CommandCost CmdBuildRoadVeh | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a road vehicle.

Parameters:

  | tile | tile of depot where road vehicle is built
  | flags | operation to perform
  | p1 | bus/truck type being built (engine)
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 199 of file roadveh_cmd.cpp.

References _cur_year, _date, _settings_game, RoadVehicleCache::cached_veh_length, CheckConsistencyOfArticulatedVehicle(), CheckInfraUsageAllowed(), CMD_ERROR, RoadVehicle::compatible_roadtypes, CT_INVALID, DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, DiagDirToDir(), EF_ROAD_TRAM, ENGINE_EXCLUSIVE_PREVIEW, RoadVehicleCache::first_engine, GetTileOwner(), GetVehicleCapacity(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateAutoreplaceWindow(), InvalidateWindowClassesData(), InvalidateWindowData(), IsEngineBuildable(), VehicleSettings::max_roadveh, SpecializedVehicle< T, Type >::Next(), RoadVehicle::rcache, return_cmd_error, RoadVehicle::roadtype, ROADTYPE_ROAD, ROADTYPE_TRAM, RoadTypeToRoadTypes(), RoadVehicle::RoadVehicle(), RVSB_IN_DEPOT, SetBit(), RoadVehicle::SetRoadVehFront(), SetWindowDirty(), RoadVehicle::state, TILE_SIZE, TileX(), TileY(), VEH_ROAD, GameSettings::vehicle, VehicleMove(), and VehicleRandomBits().

CommandCost CmdBuildShip | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a ship.

Parameters:

  | tile | tile of depot where ship is built
  | flags | type of operation
  | p1 | ship type being built (engine)
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 610 of file ship_cmd.cpp.

References _cur_year, _date, _settings_game, CheckInfraUsageAllowed(), CMD_ERROR, CT_INVALID, DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, ENGINE_EXCLUSIVE_PREVIEW, GetTileOwner(), GetVehicleCapacity(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateAutoreplaceWindow(), InvalidateWindowClassesData(), InvalidateWindowData(), IsEngineBuildable(), VehicleSettings::max_ships, return_cmd_error, SetBit(), SetWindowDirty(), Ship::Ship(), Ship::state, TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, Ship::UpdateDeltaXY(), VEH_SHIP, GameSettings::vehicle, VehicleMove(), and VehicleRandomBits().

CommandCost CmdBuildShipDepot | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a ship depot.

Parameters:

  | tile | tile where ship depot is built
  | flags | type of operation
  | p1 | bit 0 depot orientation (Axis)
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 111 of file water_cmd.cpp.

References AXIS_X, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), GetTileSlope(), IsBridgeAbove(), MarkTileDirtyByTile(), return_cmd_error, SLOPE_FLAT, and TileDiffXY().

CommandCost CmdBuildSignalTrack | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build signals on a stretch of track.

Stub for the unified signal builder/remover

Parameters:

  | tile | start tile of drag
  | flags | operation to perform
  | p1 | end tile of drag

  p2

  various bitstuffed elements
  - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
  - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
  - p2 = (bit 4) - 0 = signals, 1 = semaphores
  - p2 = (bit 5) - 0 = build, 1 = remove signals
  - p2 = (bit 6) - 0 = selected stretch, 1 = auto fill
  - p2 = (bit 7- 9) - default signal type
  - p2 = (bit 24-31) - user defined signals_density

  | text | unused

Returns:
  the cost of this operation or an error

See also:
  CmdSignalTrackHelper

Definition at line 1187 of file rail_cmd.cpp.

References CmdSignalTrackHelper().

CommandCost CmdBuildSingleRail | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a single piece of rail.

Parameters:

  | tile | tile to build on
  | flags | operation to perform
  | p1 | railtype of being built piece (normal, mono, maglev)
  | p2 | rail track to build
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 315 of file rail_cmd.cpp.

References CommandCost::AddCost(), AddTrackToSignalBuffer(), AXIS_X, AXIS_Y, CheckRailSlope(), CMD_CONVERT_RAIL, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), DRD_NONE, EnsureNoTrainOnTrack(), GetDisallowedRoadDirections(), GetRailType(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), HasBit(), HasPowerOnRail(), IsCompatibleRail(), IsPlainRail(), IsSlopeWithOneCornerRaised(), IsTileType(), M, MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_WATER, RAIL_GROUND_BARREN, RAIL_GROUND_WATER, RailBuildCost(), return_cmd_error, ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ALL, ROADTYPES_ROAD, ROADTYPES_TRAM, SetTrackBits(), SLOPE_ENW, SLOPE_EW, SLOPE_FLAT, SLOPE_NS, SLOPE_NWS, SLOPE_SEN, SLOPE_WSE, TRACK_BIT_NONE, TRACK_X, TRACK_Y, TrackToTrackBits(), UpdateLevelCrossing(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildSingleSignal | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals, and what-else not.

If the rail piece does not have any signals, bit 4 (cycle signal-type) is ignored

Parameters:

  | tile | tile where to build the signals
  | flags | operation to perform

  p1

  various bitstuffed elements
  - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
  - p1 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal or (for bit 7) toggle variant (CTRL-toggle)
  - p1 = (bit 4) - 0 = signals, 1 = semaphores
  - p1 = (bit 5-7) - type of the signal, for valid values see enum SignalType in rail_map.h
  - p1 = (bit 8) - convert the present signal type and variant
  - p1 = (bit 9-11)- start cycle from this signal type
  - p1 = (bit 12-14)-wrap around after this signal type
  - p1 = (bit 15-16)-cycle the signal direction this many times
  - p1 = (bit 17) - 1 = don't modify an existing signal but don't fail either, 0 = always set new signal type

  | p2 | used for CmdBuildManySignals() to copy direction of first signal
  | text | unused

Returns:
  the cost of this operation or an error

Todo:
  p2 should be replaced by two bits for "along" and "against" the track.

Definition at line 835 of file rail_cmd.cpp.

References _settings_game, AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, EnsureNoTrainOnTrack(), PathfinderSettings::forbid_90_deg, FreeTrainTrackReservation(), GB(), GetPresentSignals(), GetRailReservationTrackBits(), GetSignalStates(), GetTrackBits(), GetTrainForReservation(), Train::GetVehicleTrackdir(), HasBit(), HasReservedTracks(), HasSignalOnTrack(), HasSignals(), HasTrack(), IsPlainRailTile(), IsSafeWaitingPosition(), KillFirstBit(), MarkTileDirtyByTile(), GameSettings::pf, return_cmd_error, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SIG_SEMAPHORE, SignalOnTrack(), TRACK_BIT_HORZ, TRACK_BIT_NONE, TRACK_BIT_VERT, TrackToTrackBits(), TryPathReserve(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildTrainDepot | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build a train depot.

Parameters:

  | tile | position of the train depot
  | flags | operation to perform
  | p1 | rail type
  | p2 | bit 0..1 entrance direction (DiagDirection)
  | text | unused

Returns:
  the cost of this operation or an error

Todo:
  When checking for the tile slope, distingush between "Flat land required" and "land sloped in wrong direction"

Definition at line 768 of file rail_cmd.cpp.

References _settings_game, CommandCost::AddCost(), AddSideToSignalBuffer(), ConstructionSettings::build_on_slopes, CanBuildDepotByTileh(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), GameSettings::construction, DC_EXEC, DiagDirToDiagTrack(), DoCommand(), GetTileSlope(), INVALID_DIAGDIR, IsBridgeAbove(), IsSteepSlope(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), return_cmd_error, SLOPE_FLAT, ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildTunnel | ( | TileIndex | start_tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build Tunnel.

Parameters:

  | start_tile | start tile of tunnel
  | flags | type of operation
  | p1 | railtype or roadtypes. bit 9 set means road tunnel
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 462 of file tunnelbridge_cmd.cpp.

References CommandCost::AddCost(), AddSideToSignalBuffer(), AreValidRoadTypes(), AXIS_Y, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CMD_TERRAFORM_LAND, CmdFailed(), ComplementSlope(), Cheats::crossing_tunnels, DC_AUTO, DC_EXEC, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), DiagDirToDiagTrack(), DoCommand(), GB(), CommandCost::GetCost(), GetInclinedSlopeDirection(), GetTileSlope(), HasRoadTypesAvail(), INVALID_DIAGDIR, IsTunnelInWayDir(), IsValidTile(), MakeRailTunnel(), MakeRoadTunnel(), MapMaxX(), return_cmd_error, ReverseDiagDir(), TileOffsByDiagDir(), TileX(), TileY(), TRANSPORT_RAIL, ValParamRailtype(), Cheat::value, and YapfNotifyTrackLayoutChange().

CommandCost CmdBuyCompany | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Buy up another company.

When a competing company is gone bankrupt you get the chance to purchase that company.

Todo:
  currently this only works for AI companies

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | company to buy up
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1556 of file economy.cpp.

References CMD_ERROR, DC_EXEC, and HasBit().

CommandCost CmdBuyShareInCompany | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Acquire shares in an opposing company.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | company to buy the shares from
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1474 of file economy.cpp.

References _cur_year, _settings_game, CommandCost::AddCost(), EconomySettings::allow_shares, CMD_ERROR, COMPANY_SPECTATOR, DC_EXEC, GameSettings::economy, return_cmd_error, and SetWindowDirty().

CommandCost CmdChangeCompanySetting | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change one of the per-company settings.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the index of the setting in the _company_settings array which identifies it
  | p2 | the new value for the setting The new value is properly clamped to its minimum/maximum when setting
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1503 of file settings.cpp.

References CMD_ERROR, DC_EXEC, GetVariableAddress(), lengthof, ReadValue(), SetWindowDirty(), Write_ValidateSetting(), and WriteValue().

CommandCost CmdChangeServiceInt | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change the service interval of a vehicle.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle ID that is being service-interval-changed
  | p2 | new service interval
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 672 of file vehicle_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetServiceIntervalClamped(), and SetWindowDirty().

CommandCost CmdChangeSetting | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Network-safe changing of settings (server-only).

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the index of the setting in the SettingDesc array which identifies it
  | p2 | the new value for the setting The new value is properly clamped to its minimum/maximum when setting
  | text | unused

Returns:
  the cost of this operation or an error

See also:
  _settings

Definition at line 1450 of file settings.cpp.

References CMD_ERROR, DC_EXEC, GamelogSetting(), GamelogStartAction(), GamelogStopAction(), GetVariableAddress(), GLAT_SETTING, ReadValue(), SetWindowDirty(), SGF_NETWORK_ONLY, SGF_NEWGAME_ONLY, SGF_NO_NETWORK, SGF_SCENEDIT_TOO, SlIsObjectCurrentlyValid(), Write_ValidateSetting(), and WriteValue().

CommandCost CmdChangeTimetable | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Add or remove waiting times from an order.

Parameters:

  | tile | Not used.
  | flags | Operation to perform.

  p1

  Various bitstuffed elements
  - p1 = (bit 0-15) - Vehicle with the orders to change.
  - p1 = (bit 16-23) - Order index to modify.
  - p1 = (bit 24) - Whether to change the waiting time or the travelling time.
  - p1 = (bit 25) - Whether p2 contains waiting and travelling time.

  p2

  The amount of time to wait.
  - p2 = (bit 0-15) - Waiting or travelling time as specified by p1 bit 24 if p1 bit 25 is not set, Travelling time if p1 bit 25 is set.
  - p2 = (bit 16-31) - Waiting time if p1 bit 25 is set

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 64 of file timetable_cmd.cpp.

References _settings_game, CMD_ERROR, DC_EXEC, GB(), HasBit(), ONSF_NO_STOP_AT_DESTINATION_STATION, GameSettings::order, return_cmd_error, and OrderSettings::timetabling.

CommandCost CmdClearArea | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Clear a big piece of landscape.

Parameters:

  | tile | end tile of area dragging
  | p1 | start tile of area dragging
  | flags | of operation to conduct
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 612 of file landscape.cpp.

References CommandCost::AddCost(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), MapSize(), Swap(), TILE_SIZE, TileX(), TileXY(), and TileY().

CommandCost CmdCloneOrder | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Clone/share/copy an order-list of an other vehicle.

Parameters:

  | tile | unused
  | flags | operation to perform

  p1

  various bitstuffed elements
  - p1 = (bit 0-15) - destination vehicle to clone orders to (p1 & 0xFFFF)
  - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)

  | p2 | mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1123 of file order_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem(), CanVehicleUseStation(), CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteVehicleOrders(), OrderList::first, SpecializedVehicle< RoadVehicle, VEH_ROAD >::From(), GB(), SpecializedStation< Station, false >::Get(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), InvalidateWindowClassesData(), RoadVehicle::IsBus(), OrderGoesToStation(), OrderList::OrderList(), return_cmd_error, and VEH_ROAD.

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

Parameters:

  | 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

Returns:
  the cost of this operation or an error

Definition at line 423 of file vehicle_cmd.cpp.

References CommandCost::AddCost(), CloneVehicleName(), CMD_ADD_VEHICLE_GROUP, CMD_CLONE_ORDER, CMD_ERROR, CMD_MOVE_RAIL_VEHICLE, CmdFailed(), CmdSucceeded(), Train::crash_anim_pos, CT_INVALID, DC_AUTOREPLACE, DC_EXEC, DoCommand(), SpecializedVehicle< RoadVehicle, VEH_ROAD >::From(), SpecializedVehicle< Train, VEH_TRAIN >::From(), GetBestFittingSubType(), Train::GetNextArticPart(), Train::GetNextVehicle(), GetRefitCost(), RoadVehicle::HasArticulatedPart(), Train::HasArticulatedPart(), HasBit(), Train::IsFrontEngine(), Train::IsRearDualheaded(), SpecializedVehicle< T, Type >::Next(), return_cmd_error, SetBit(), VEH_ROAD, and VEH_TRAIN.

CommandCost CmdCompanyCtrl | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Control the companies: add, delete, etc.

Parameters:

  | tile | unused
  | flags | operation to perform

  p1

  various functionality
  - p1 = 0 - create a new company, Which company (network) it will be is in p2
  - p1 = 1 - create a new AI company
  - p1 = 2 - delete a company. Company is identified by p2

  p2

  various functionality, dictated by p1
  - p1 = 0 - ClientID of the newly created client
  - p1 = 1 - CompanyID to start AI (INVALID_COMPANY for first available)
  - p1 = 2 - CompanyID of the that is getting deleted

  | text | unused

Returns:
  the cost of this operation or an error

Todo:
  In the case of p1=0, create new company, the clientID of the new client is in parameter p2. This parameter is passed in at function DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) on the server itself. First of all this is unbelievably ugly; second of all, well, it IS ugly! Someone fix this up :) So where to fix?

- - network_server.c:838 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
- - network_client.c:536 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) from where the map has been received

Definition at line 700 of file company_cmd.cpp.

References _settings_client, CMD_ERROR, CMD_RENAME_PRESIDENT, CompanyNewsInformation::company_name, COMPANY_SPECTATOR, DC_EXEC, DeleteCompanyWindows(), DeleteWindowById(), DoStartupNewCompany(), CompanyNewsInformation::FillData(), INVALID_COMPANY, INVALID_OWNER, InvalidateWindowData(), MarkWholeScreenDirty(), MAX_COMPANIES, ClientSettings::network, NS_COMPANY_BANKRUPT, OWNER_NONE, SetDParam(), SetDParamStr(), SetLocalCompany(), and StrEmpty().

CommandCost CmdConvertRail | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Convert one rail type to the other.

You can convert normal rail to monorail/maglev easily or vice-versa.

Parameters:

  | tile | end tile of rail conversion drag
  | flags | operation to perform
  | p1 | start tile of drag
  | p2 | new railtype to convert to
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1302 of file rail_cmd.cpp.

References _settings_game, CommandCost::AddCost(), SmallVector< T, S >::Append(), CMD_ERROR, CountBits(), DC_EXEC, DiagDirToDiagTrack(), VehicleSettings::disable_elrails, FindVehicleOnPos(), FreeTrainTrackReservation(), CommandCost::GetCost(), GetOtherTunnelBridgeEnd(), GetRailDepotTrack(), GetRailTileType(), GetRailType(), GetReservedTrackbits(), GetTileType(), GetTrackBits(), GetTrainForReservation(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasPowerOnRail(), HasStationRail(), HasTunnelBridgeReservation(), HasVehicleOnTunnelBridge(), INVALID_TRACK, InvalidateWindowData(), IsBridge(), IsCompatibleRail(), SmallVector< T, S >::Length(), MapSize(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, RAIL_TILE_DEPOT, RailConvertCost(), Train::railtype, RAILTYPE_ELECTRIC, RAILTYPE_RAIL, RemoveFirstTrack(), SetRailType(), Swap(), TileOffsByDiagDir(), TileX(), TileXY(), TileY(), TRACK_BIT_NONE, TRANSPORT_RAIL, TryPathReserve(), UpdateTrainPowerProc(), ValParamRailtype(), GameSettings::vehicle, and YapfNotifyTrackLayoutChange().

CommandCost CmdCreateGroup | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Create a new vehicle group.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle type
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 83 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetWindowClassForVehicleType(), and InvalidateWindowData().

CommandCost CmdDecreaseLoan | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Decrease the loan of your company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | amount to decrease the loan with, multitude of LOAN_INTERVAL. Only used when p2 == 2.
  | p2 | when 0: pays back LOAN_INTERVAL when 1: pays back the maximum loan permitting money (press CTRL), when 2: pays back the amount specified in p1
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 196 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, LOAN_INTERVAL, max(), min(), return_cmd_error, and SetDParam().

CommandCost CmdDeleteGroup | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Add all vehicles in the given group to the default group and then deletes the group.

Parameters:

  | tile | unused
  | flags | type of operation

  p1

  index of array group
  - p1 bit 0-15 : GroupID

  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 114 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, DEFAULT_GROUP, DeleteWindowById(), EngineRenew::from, GetWindowClassForVehicleType(), EngineRenew::group_id, InvalidateWindowData(), MAX_COMPANIES, and RemoveEngineReplacementForCompany().

CommandCost CmdDeleteOrder | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Delete an order from the orderlist of a vehicle.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the ID of the vehicle
  | p2 | the order to delete (max 255)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 711 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteOrderWarnings(), GetWindowClassForVehicleType(), INVALID_VEH_ORDER_ID, InvalidateVehicleOrder(), InvalidateWindowClassesData(), max(), and ONSF_STOP_EVERYWHERE.

CommandCost CmdDepotMassAutoReplace | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Autoreplace all vehicles in the depot Note: this command can make incorrect cost estimations Luckily the final price can only drop, not increase.

This is due to the fact that estimation can't predict wagon removal so it presumes worst case which is no income from selling wagons.

Parameters:

  | tile | Tile of the depot where the vehicles are
  | flags | type of operation
  | p1 | Type of vehicle
  | p2 | If bit 0 is set, then either replace all or nothing (instead of replacing until money runs out)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 214 of file vehicle_cmd.cpp.

References CommandCost::AddCost(), BuildDepotVehicleList(), CheckInfraUsageAllowed(), CMD_AUTOREPLACE_VEHICLE, CMD_ERROR, CmdSucceeded(), DC_EXEC, DoCommand(), GB(), CommandCost::GetErrorMessage(), GetTileOwner(), HasBit(), IsDepotTile(), and SmallVector< T, S >::Length().

CommandCost CmdDepotSellAllVehicles | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Sells all vehicles in a depot.

Parameters:

  | tile | Tile of the depot where the depot is
  | flags | type of operation
  | p1 | Vehicle type
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 183 of file vehicle_cmd.cpp.

References CommandCost::AddCost(), BuildDepotVehicleList(), CMD_ERROR, CmdSucceeded(), DoCommand(), GB(), CommandCost::GetCost(), and SmallVector< T, S >::Length().

CommandCost CmdDoTownAction | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Do a town action.

This performs an action such as advertising, building a statue, funding buildings, but also bribing the town-council

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | town to do the action at
  | p2 | action to perform,

See also:
  _town_action_proc for the list of available actions

Parameters:

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 2540 of file town_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetMaskOfTownActions(), HasBit(), lengthof, and SetWindowDirty().

CommandCost CmdForceTrainProceed | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Force a train through a red signal.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | train to ignore the red signal
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 2040 of file train_cmd.cpp.

References CheckVehicleControlAllowed(), CMD_ERROR, DC_EXEC, Train::flags, Train::force_proceed, SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsInDepot(), and SetWindowDirty().

CommandCost CmdFoundTown | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Create a new town.

Parameters:

  | tile | coordinates where town is built
  | flags | type of operation
  | p1 | 0..1 size of the town (

See also:
  TownSize) 2 true iff it should be a city 3..5 town road layout (

  TownLayout) 6 use random location (randomize `tile` )

Parameters:

  | p2 | town name parts
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1521 of file town_cmd.cpp.

References _settings_game, AddNewsItem(), assert_compile(), CMD_ERROR, CmdFailed(), DC_EXEC, DoCreateTown(), GameSettings::economy, EconomySettings::found_town, GameSettings::game_creation, GB(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), HasBit(), IsUniqueTownName(), lastof, lengthof, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_TOWN_NAME_BYTES, CommandCost::MultiplyCost(), NR_NONE, NR_TILE, NS_INDUSTRY_OPEN, return_cmd_error, SetDParam(), SetDParamStr(), StrEmpty(), TF_CUSTOM_LAYOUT, TF_FORBIDDEN, TL_RANDOM, EconomySettings::town_layout, GameCreationSettings::town_name, TownCanBePlacedHere(), TS_LARGE, TS_RANDOM, UpdateNearestTownForRoadTiles(), and VerifyTownName().

CommandCost CmdGiveMoney | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Transfer funds (money) from one company to another.

To prevent abuse in multiplayer games you can only send money to other companies if you have paid off your loan (either explicitely, or implicitely given the fact that you have more money than loan).

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the amount of money to transfer; max 20.000.000
  | p2 | the company to transfer the money to
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 419 of file misc_cmd.cpp.

References _settings_game, CMD_ERROR, DC_EXEC, GameSettings::economy, CommandCost::GetCost(), EconomySettings::give_money, and min().

CommandCost CmdIncreaseLoan | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Increase the loan of your company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | amount to increase the loan with, multitude of LOAN_INTERVAL. Only used when p2 == 2.
  | p2 | when 0: loans LOAN_INTERVAL when 1: loans the maximum loan permitting money (press CTRL), when 2: loans the amount specified in p1
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 150 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, LOAN_INTERVAL, return_cmd_error, and SetDParam().

CommandCost CmdInsertOrder | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Add an order to the orderlist of a vehicle.

Parameters:

  | tile | unused
  | flags | operation to perform

  p1

  various bitstuffed elements
  - p1 = (bit 0 - 15) - ID of the vehicle
  - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given, the order will be inserted before that one the maximum vehicle order id is 254.

  | p2 | packed order to insert
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 452 of file order_cmd.cpp.

References _settings_game, Station::Airport(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem(), CanVehicleUseStation(), CheckInfraUsageAllowed(), CMD_ERROR, DC_EXEC, DeleteOrderWarnings(), FACIL_DOCK, FACIL_TRAIN, GB(), SpecializedStation< Station, false >::GetIfValid(), OrderList::GetNumOrders(), GetTileOwner(), GetWindowClassForVehicleType(), INVALID_VEH_ORDER_ID, InvalidateVehicleOrder(), InvalidateWindowClassesData(), IsRailDepotTile(), MAX_VEH_ORDER_ID, AirportFTAClass::nof_depots, OCC_EQUALS, OCC_IS_FALSE, OCC_IS_TRUE, OCV_LOAD_PERCENTAGE, OCV_RELIABILITY, OCV_REQUIRES_SERVICE, OCV_UNCONDITIONALLY, ODATFB_HALT, ODATFB_NEAREST_DEPOT, ODTFB_PART_OF_ORDERS, ODTFB_SERVICE, OLF_FULL_LOAD_ANY, OLF_LOAD_IF_POSSIBLE, OLFB_FULL_LOAD, OLFB_NO_LOAD, ONSF_STOP_EVERYWHERE, OrderList::OrderList(), OSL_PLATFORM_FAR_END, OSL_PLATFORM_MIDDLE, OSL_PLATFORM_NEAR_END, OUF_UNLOAD_IF_POSSIBLE, OUFB_NO_UNLOAD, OUFB_TRANSFER, OUFB_UNLOAD, BaseStation::owner, PathfinderSettings::pathfinder_for_ships, GameSettings::pf, return_cmd_error, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and VPF_NPF.

CommandCost CmdLandscapeClear | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Clear a piece of landscape.

Parameters:

  | tile | tile to clear
  | flags | of operation to conduct
  | p1 | unused
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 599 of file landscape.cpp.

References TileTypeProcs::clear_tile_proc, and GetTileType().

CommandCost CmdLevelLand | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Levels a selected (rectangle) area of land.

Parameters:

  | tile | end tile of area-drag
  | flags | for this command type
  | p1 | start tile of area drag
  | p2 | height difference; eg raise (+1), lower (-1) or level (0)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 365 of file terraform_cmd.cpp.

References _terraform_err_tile, CommandCost::AddCost(), CMD_ERROR, CMD_TERRAFORM_LAND, CmdFailed(), DC_EXEC, DoCommand(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), INVALID_TILE, MapSize(), MAX_TILE_HEIGHT, return_cmd_error, SLOPE_N, Swap(), TILE_LOOP, TileHeight(), TileX(), TileXY(), and TileY().

CommandCost CmdMassStartStopVehicle | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Starts or stops a lot of vehicles.

Parameters:

  | tile | Tile of the depot where the vehicles are started/stopped (only used for depots)
  | flags | type of operation
  | p1 | Station/Order/Depot ID (only used for vehicle list windows)

  p2

  bitmask
  - bit 0-4 Vehicle type
  - bit 5 false = start vehicles, true = stop vehicles
  - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
  - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 131 of file vehicle_cmd.cpp.

References BuildDepotVehicleList(), CMD_ERROR, CMD_START_STOP_VEHICLE, CmdSucceeded(), DC_EXEC, DoCommand(), SpecializedVehicle< Train, VEH_TRAIN >::From(), GB(), GenerateVehicleSortList(), HasBit(), Train::IsInDepot(), SmallVector< T, S >::Length(), and VEH_TRAIN.

CommandCost CmdModifyOrder | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Modify an order in the orderlist of a vehicle.

Parameters:

  | tile | unused
  | flags | operation to perform

  p1

  various bitstuffed elements
  - p1 = (bit 0 - 15) - ID of the vehicle
  - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given, the order will be inserted before that one only the first 8 bits used currently (bit 16 - 23) (max 255)

  p2

  various bitstuffed elements
  - p2 = (bit 0 - 3) - what data to modify (

See also:
  ModifyOrderFlags)
  - p2 = (bit 4 - 15) - the data to modify

Parameters:

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 896 of file order_cmd.cpp.

References CMD_ERROR, DA_ALWAYS_GO, DA_SERVICE, DA_STOP, DC_EXEC, DeleteOrderWarnings(), GB(), InvalidateVehicleOrder(), MOF_COND_COMPARATOR, MOF_COND_DESTINATION, MOF_COND_VALUE, MOF_COND_VARIABLE, MOF_DEPOT_ACTION, MOF_LOAD, MOF_NON_STOP, MOF_STOP_LOCATION, MOF_UNLOAD, OCC_EQUALS, OCC_IS_FALSE, OCC_IS_TRUE, OCV_LOAD_PERCENTAGE, OCV_RELIABILITY, OCV_REQUIRES_SERVICE, OCV_UNCONDITIONALLY, ODATFB_HALT, ODTFB_SERVICE, OLFB_NO_LOAD, OUFB_NO_UNLOAD, OUFB_TRANSFER, OUFB_UNLOAD, VEH_ROAD, and VEH_TRAIN.

CommandCost CmdMoneyCheat | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change the financial flow of your company.

This is normally only enabled in offline mode, but if there is a debug build, you can cheat (to test).

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the amount of money to receive (if negative), or spend (if positive)
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 400 of file misc_cmd.cpp.

References CMD_ERROR.

CommandCost CmdMoveOrder | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Move an order inside the orderlist.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the ID of the vehicle
  | p2 | order to move and target bit 0-15 : the order to move bit 16-31 : the target order
  | text | unused

Returns:
  the cost of this operation or an error

Note:
  The target order will move one place down in the orderlist if you move the order upwards else it'll move it one place down

Definition at line 818 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, DeleteOrderWarnings(), GB(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), and InvalidateWindowClassesData().

CommandCost CmdMoveRailVehicle | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Move a rail vehicle around inside the depot.

Parameters:

  | tile | unused
  | flags | type of operation Note: DC_AUTOREPLACE is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot.

  p1

  various bitstuffed elements
  - p1 (bit 0 - 15) source vehicle index
  - p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line

  | p2 | (bit 0) move all vehicles following the source vehicle
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1320 of file train_cmd.cpp.

References ArrangeTrains(), CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, DEFAULT_GROUP, DeleteVehicleOrders(), DeleteWindowById(), CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), GB(), Train::GetFirstEnginePart(), SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), Train::GetLastEnginePart(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, InvalidateWindowClassesData(), InvalidateWindowData(), Train::IsEngine(), Train::IsFrontEngine(), Train::IsRearDualheaded(), Train::IsStoppedInDepot(), MakeTrainBackup(), NormaliseSubtypes(), NormaliseTrainHead(), Train::other_multiheaded_part, RemoveVehicleFromGroup(), RestoreTrainBackup(), return_cmd_error, SetTrainGroupID(), and ValidateTrains().

CommandCost CmdOrderRefit | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Add/remove refit orders from an order.

Parameters:

  | tile | Not used
  | flags | operation to perform
  | p1 | VehicleIndex of the vehicle having the order

  p2

  bitmask
  - bit 0-7 CargoID
  - bit 8-15 Cargo subtype
  - bit 16-23 number of order to modify

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1246 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, GB(), InvalidateVehicleOrder(), and ODTFB_PART_OF_ORDERS.

CommandCost CmdPause | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Pause/Unpause the game (server-only).

Set or unset a bit in the pause mode. If pause mode is zero the game is unpaused. A bitset is used instead of a boolean value/counter to have more control over the game when saving/loading, etc.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the pause mode to change
  | p2 | 1 pauses, 0 unpauses this mode
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 343 of file misc_cmd.cpp.

References _pause_mode, AskUnsafeUnpauseCallback(), CMD_ERROR, DC_EXEC, PM_PAUSED_ACTIVE_CLIENTS, PM_PAUSED_ERROR, PM_PAUSED_JOIN, PM_PAUSED_NORMAL, PM_PAUSED_SAVELOAD, SetWindowDirty(), and ShowQuery().

CommandCost CmdPlaceSign | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Place a sign at the given coordinates.

Ownership of sign has no effect whatsoever except for the colour the sign gets for easy recognition, but everybody is able to rename/remove it.

Parameters:

  | tile | tile to place sign at
  | flags | type of operation
  | p1 | unused
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 37 of file signs_cmd.cpp.

References CMD_ERROR, DC_EXEC, InvalidateWindowData(), MAX_LENGTH_SIGN_NAME_BYTES, return_cmd_error, StrEmpty(), TILE_SIZE, TileX(), and TileY().

CommandCost CmdPlantTree | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Plant a tree.

Parameters:

  | tile | start tile of area-drag of tree plantation
  | flags | type of operation
  | p1 | tree type, -1 means random.
  | p2 | end tile of area-drag
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 342 of file tree_cmd.cpp.

References _settings_game, CommandCost::AddCost(), AddTreeCount(), ChangeTownRating(), CLEAR_FIELDS, CLEAR_ROCKS, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, EconomySettings::dist_local_authority, DoCommand(), GameSettings::economy, GameSettings::game_creation, GB(), GetClearGround(), CommandCost::GetCost(), GetRandomTreeType(), GetTileSlope(), GetTileType(), GetTreeCount(), INVALID_STRING_ID, IsBridgeAbove(), IsInsideMM(), IsSlopeWithOneCornerRaised(), IsTileType(), GameCreationSettings::landscape, MapSize(), MarkTileDirtyByTile(), MP_CLEAR, MP_TREES, MP_WATER, PlantTreesOnTile(), return_cmd_error, SetTropicZone(), Swap(), TileX(), TileXY(), TileY(), TREE_CACTUS, TREE_INVALID, TREE_RAINFOREST, and TROPICZONE_RAINFOREST.

CommandCost CmdPurchaseLandArea | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Purchase a land area.

Actually you only purchase one tile, so the name is a bit confusing ;p

Parameters:

  | tile | the tile the company is purchasing
  | flags | for this command type
  | p1 | unused
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 144 of file unmovable_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), GetUnmovableSpec(), IsOwnedLandTile(), IsTileOwner(), MakeOwnedLand(), MarkTileDirtyByTile(), return_cmd_error, and UNMOVABLE_OWNED_LAND.

CommandCost CmdRefitAircraft | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Refits an aircraft to the specified cargo type.

Parameters:

  | tile | unused
  | flags | for command type
  | p1 | vehicle ID of the aircraft to refit

  p2

  various bitstuffed elements
  - p2 = (bit 0-7) - the new cargo type to refit to
  - p2 = (bit 8-15) - the new cargo subtype to refit to
  - p2 = (bit 16) - refit only this vehicle (ignored)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 491 of file aircraft_cmd.cpp.

References CMD_ERROR, DC_EXEC, GB(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), NUM_CARGO, RefitVehicle(), return_cmd_error, and SetWindowDirty().

CommandCost CmdRefitRailVehicle | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Refits a train to the specified cargo type.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle ID of the train to refit

  p2

  various bitstuffed elements
  - p2 = (bit 0-7) - the new cargo type to refit to
  - p2 = (bit 8-15) - the new cargo subtype to refit to
  - p2 = (bit 16) - refit only this vehicle

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 2069 of file train_cmd.cpp.

References CMD_ERROR, DC_EXEC, SpecializedVehicle< T, Type >::First(), GB(), SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), Train::IsStoppedInDepot(), NUM_CARGO, RefitVehicle(), return_cmd_error, SetWindowDirty(), and TrainConsistChanged().

CommandCost CmdRefitRoadVeh | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Refit a road vehicle to the specified cargo type.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | Vehicle ID of the vehicle to refit

  p2

  Bitstuffed elements
  - p2 = (bit 0-7) - the new cargo type to refit to
  - p2 = (bit 8-15) - the new cargo subtype to refit to
  - p2 = (bit 16) - refit only this vehicle

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1732 of file roadveh_cmd.cpp.

References CMD_ERROR, DC_EXEC, SpecializedVehicle< T, Type >::First(), GB(), SpecializedVehicle< RoadVehicle, VEH_ROAD >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), RoadVehicle::IsStoppedInDepot(), NUM_CARGO, RefitVehicle(), return_cmd_error, and SetWindowDirty().

CommandCost CmdRefitShip | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Refits a ship to the specified cargo type.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle ID of the ship to refit

  p2

  various bitstuffed elements
  - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
  - p2 = (bit 8-15) - the new cargo subtype to refit to
  - p2 = (bit 16) - refit only this vehicle (ignored)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 779 of file ship_cmd.cpp.

References CMD_ERROR, DC_EXEC, GB(), SpecializedVehicle< Ship, VEH_SHIP >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), NUM_CARGO, RefitVehicle(), return_cmd_error, and SetWindowDirty().

CommandCost CmdRemoveAllVehiclesGroup | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove all vehicles from a group.

Parameters:

  | tile | unused
  | flags | type of operation

  p1

  index of group array
  - p1 bit 0-15 : GroupID

  | p2 | type of vehicles
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 299 of file group_cmd.cpp.

References CMD_ERROR, CmdAddVehicleGroup(), DC_EXEC, DEFAULT_GROUP, GetWindowClassForVehicleType(), and InvalidateWindowData().

CommandCost CmdRemoveFromRailStation | ( | TileIndex | start,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove a single tile from a rail station.

This allows for custom-built station with holes and weird layouts

Parameters:

  | start | tile of station piece to remove
  | flags | operation to perform
  | p1 | start_tile

  p2

  various bitstuffed elements
  - p2 = bit 0 - if set keep the rail

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1326 of file station_cmd.cpp.

References SmallVector< T, S >::Begin(), CMD_ERROR, SmallVector< T, S >::End(), CommandCost::Failed(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, MapSize(), Station::MarkTilesDirty(), Station::RecomputeIndustriesNear(), RemoveFromRailBaseStation(), SetWindowWidgetDirty(), SVW_TRAINS, TileArea::tile, and BaseStation::train_station.

CommandCost CmdRemoveFromRailWaypoint | ( | TileIndex | start,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove a single tile from a waypoint.

This allows for custom-built waypoint with holes and weird layouts

Parameters:

  | start | tile of waypoint piece to remove
  | flags | operation to perform
  | p1 | start_tile

  p2

  various bitstuffed elements
  - p2 = bit 0 - if set keep the rail

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1360 of file station_cmd.cpp.

References CMD_ERROR, HasBit(), MapSize(), and RemoveFromRailBaseStation().

CommandCost CmdRemoveLongRoad | ( | TileIndex | end_tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove a long piece of road.

Parameters:

  | end_tile | end tile of drag
  | flags | operation to perform
  | p1 | start tile of drag

  p2

  various bitstuffed elements
  - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
  - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
  - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
  - p2 = (bit 3 + 4) - road type

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 800 of file road_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, CMD_REMOVE_LONG_ROAD, CmdSucceeded(), DC_EXEC, DoCommand(), GB(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), HasBit(), IsInsideMM(), IsValidRoadType(), MapSize(), RemoveRoad(), ROAD_NE, ROAD_NW, ROAD_SE, ROAD_SW, ROAD_X, ROAD_Y, TileDiffXY(), TileX(), and TileY().

CommandCost CmdRemoveRailroadTrack | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build rail on a stretch of track.

Stub for the unified rail builder/remover

Parameters:

  | tile | start tile of drag
  | flags | operation to perform
  | p1 | end tile of drag

  p2

  various bitstuffed elements
  - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
  - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
  - p2 = (bit 7) - 0 = build, 1 = remove tracks

  | text | unused

Returns:
  the cost of this operation or an error

See also:
  CmdRailTrackHelper

Definition at line 752 of file rail_cmd.cpp.

References CmdRailTrackHelper(), and SetBit().

CommandCost CmdRemoveRoad | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Delete a piece of road.

Parameters:

  | tile | tile where to remove road from
  | flags | operation to perform
  | p1 | bit 0..3 road pieces to remove (RoadBits) bit 4..5 road type
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 362 of file road_cmd.cpp.

References CMD_ERROR, GB(), IsValidRoadType(), and RemoveRoad().

CommandCost CmdRemoveRoadStop | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove a bus or truck stop.

Parameters:

  | tile | tile to remove the stop from
  | flags | operation to perform
  | p1 | not used
  | p2 | bit 0: 0 for Bus stops, 1 for truck stops
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1754 of file station_cmd.cpp.

References CMD_ERROR, CmdSucceeded(), DC_EXEC, DIAGDIR_NE, DiagDirToRoadBits(), GB(), GetRoadStopDir(), GetRoadStopType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsDriveThroughStopTile(), IsRoadStop(), IsTileType(), MP_STATION, RemoveRoadStop(), ROAD_X, ROAD_Y, ROADTYPE_ROAD, and ROADTYPE_TRAM.

CommandCost CmdRemoveSignalTrack | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove signals on a stretch of track.

Stub for the unified signal builder/remover

Parameters:

  | tile | start tile of drag
  | flags | operation to perform
  | p1 | end tile of drag

  p2

  various bitstuffed elements
  - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
  - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
  - p2 = (bit 4) - 0 = signals, 1 = semaphores
  - p2 = (bit 5) - 0 = build, 1 = remove signals
  - p2 = (bit 6) - 0 = selected stretch, 1 = auto fill
  - p2 = (bit 7- 9) - default signal type
  - p2 = (bit 24-31) - user defined signals_density

  | text | unused

Returns:
  the cost of this operation or an error

See also:
  CmdSignalTrackHelper

Definition at line 1272 of file rail_cmd.cpp.

References CmdSignalTrackHelper(), and SetBit().

CommandCost CmdRemoveSingleRail | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove a single piece of track.

Parameters:

  | tile | tile to remove track from
  | flags | operation to perform
  | p1 | unused
  | p2 | rail orientation
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 454 of file rail_cmd.cpp.

References CommandCost::AddCost(), AddTrackToSignalBuffer(), CMD_ERROR, CMD_REMOVE_SIGNALS, DC_BANKRUPT, DC_EXEC, DoCommand(), EnsureNoTrainOnTrack(), FreeTrainTrackReservation(), GetRailReservationTrackBits(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTownIndex(), GetTrackBits(), GetTrainForReservation(), HasReservedTracks(), HasSignalOnTrack(), INVALID_OWNER, IsPlainRail(), IsSlopeWithOneCornerRaised(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, OWNER_WATER, RAIL_GROUND_WATER, ROADTYPE_ROAD, ROADTYPE_TRAM, SetTrackBits(), SetTrackReservation(), TRACK_BIT_X, TRACK_BIT_Y, TRACK_X, TRACK_Y, TrackToTrackBits(), TryPathReserve(), and YapfNotifyTrackLayoutChange().

CommandCost CmdRemoveSingleSignal | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove signals.

Parameters:

  | tile | coordinates where signal is being deleted from
  | flags | operation to perform

  p1

  various bitstuffed elements, only track information is used
  - (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
  - (bit 3) - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
  - (bit 4) - 0 = signals, 1 = semaphores

  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1203 of file rail_cmd.cpp.

References AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, EnsureNoTrainOnTrack(), GB(), GetPresentSignals(), GetReservedTrackbits(), GetTileOwner(), GetTrainForReservation(), HasReservedTracks(), HasSignalOnTrack(), HasSignalOnTrackdir(), HasTrack(), INVALID_TRACK, IsPlainRailTile(), MarkTileDirtyByTile(), OWNER_WATER, ReverseTrackdir(), SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SignalOnTrack(), TileAddByDiagDir(), TrackBitsToTrack(), TrackdirBitsToTrackBits(), TrackdirReachesTrackdirs(), TrackdirToExitdir(), TrackToTrackBits(), TrackToTrackdir(), TryPathReserve(), and YapfNotifyTrackLayoutChange().

CommandCost CmdRenameCompany | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change the name of the company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 250 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, MarkWholeScreenDirty(), MAX_LENGTH_COMPANY_NAME_BYTES, return_cmd_error, and StrEmpty().

CommandCost CmdRenameEngine | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Rename an engine.

Parameters:

  | tile | unused
  | flags | operation to perfom
  | p1 | engine ID to rename
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 761 of file engine.cpp.

References CMD_ERROR, DC_EXEC, MarkWholeScreenDirty(), MAX_LENGTH_ENGINE_NAME_BYTES, return_cmd_error, and StrEmpty().

CommandCost CmdRenameGroup | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Rename a group.

Parameters:

  | tile | unused
  | flags | type of operation

  p1

  index of array group
  - p1 bit 0-15 : GroupID

  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 174 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetWindowClassForVehicleType(), InvalidateWindowData(), MAX_LENGTH_GROUP_NAME_BYTES, return_cmd_error, and StrEmpty().

CommandCost CmdRenamePresident | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change the name of the president.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 288 of file misc_cmd.cpp.

References CMD_ERROR, CMD_RENAME_COMPANY, DC_EXEC, DoCommand(), lengthof, MarkWholeScreenDirty(), MAX_LENGTH_PRESIDENT_NAME_BYTES, return_cmd_error, and StrEmpty().

CommandCost CmdRenameSign | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Rename a sign.

If the new name of the sign is empty, we assume the user wanted to delete it. So delete it. Ownership of signs has no meaning/effect whatsoever except for eyecandy

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | index of the sign to be renamed/removed
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 75 of file signs_cmd.cpp.

References CMD_ERROR, DC_EXEC, InvalidateWindowData(), MAX_LENGTH_SIGN_NAME_BYTES, and StrEmpty().

CommandCost CmdRenameStation | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Rename a station.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | station ID that is to be renamed
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 2924 of file station_cmd.cpp.

References CMD_ERROR, DC_EXEC, SpecializedStation< Station, false >::GetIfValid(), InvalidateWindowData(), MAX_LENGTH_STATION_NAME_BYTES, BaseStation::name, BaseStation::owner, return_cmd_error, StrEmpty(), and Station::UpdateVirtCoord().

CommandCost CmdRenameTown | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Rename a town (server-only).

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | town ID to rename
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 2284 of file town_cmd.cpp.

References CMD_ERROR, DC_EXEC, InvalidateWindowData(), IsUniqueTownName(), MAX_LENGTH_TOWN_NAME_BYTES, return_cmd_error, StrEmpty(), and UpdateAllStationVirtCoords().

CommandCost CmdRenameVehicle | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Give a custom name to your vehicle.

Parameters:

  | 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

Returns:
  the cost of this operation or an error

Definition at line 641 of file vehicle_cmd.cpp.

References CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, InvalidateWindowClassesData(), IsUniqueVehicleName(), MarkWholeScreenDirty(), MAX_LENGTH_VEHICLE_NAME_BYTES, return_cmd_error, and StrEmpty().

CommandCost CmdRenameWaypoint | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Rename a waypoint.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | id of waypoint
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 431 of file waypoint_cmd.cpp.

References CMD_ERROR, DC_EXEC, MakeDefaultWaypointName(), MAX_LENGTH_STATION_NAME_BYTES, OWNER_NONE, return_cmd_error, and StrEmpty().

CommandCost CmdRestoreOrderIndex | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Restore the current order-index of a vehicle and sets service-interval.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the ID of the vehicle

  p2

  various bistuffed elements
  - p2 = (bit 0-15) - current order-index (p2 & 0xFFFF)
  - p2 = (bit 16-31) - service interval (p2 >> 16)

  | text | unused

Returns:
  the cost of this operation or an error

Todo:
  Unfortunately you cannot safely restore the unitnumber or the old vehicle as far as I can see. We can store it in BackuppedOrders, and restore it, but but we have no way of seeing it has been tampered with or not, as we have no legit way of knowing what that ID was.
  If we do want to backup/restore it, just add UnitID uid to BackuppedOrders, and restore it as parameter 'y' (ugly hack I know) for example. "v->unitnumber = y;"

Definition at line 1399 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, GB(), and GetServiceIntervalClamped().

CommandCost CmdReverseTrainDirection | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Reverse train.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | train to reverse
  | p2 | if true, reverse a unit in a train (needs to be in a depot)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1973 of file train_cmd.cpp.

References _settings_game, CBM_VEHICLE_ARTIC_ENGINE, CheckVehicleControlAllowed(), CMD_ERROR, DC_EXEC, SpecializedVehicle< T, Type >::First(), Train::flags, Train::force_proceed, SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), GetStationIndex(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Train::IsMultiheaded(), Train::IsStoppedInDepot(), IsTileType(), MP_STATION, SpecializedVehicle< T, Type >::Next(), return_cmd_error, SetWindowDirty(), ToggleBit(), VehicleSettings::train_acceleration_model, and GameSettings::vehicle.

CommandCost CmdSellAircraft | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Sell an aircraft.

Parameters:

  | tile | unused
  | flags | for command type
  | p1 | vehicle ID to be sold
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 418 of file aircraft_cmd.cpp.

References CMD_ERROR, DC_EXEC, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::GetIfValid(), and return_cmd_error.

CommandCost CmdSellLandArea | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Sell a land area.

Actually you only sell one tile, so the name is a bit confusing ;p

Parameters:

  | tile | the tile the company is selling
  | flags | for this command type
  | p1 | unused
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 172 of file unmovable_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetUnmovableSpec(), IsOwnedLandTile(), OWNER_WATER, and UNMOVABLE_OWNED_LAND.

CommandCost CmdSellRailWagon | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Sell a (single) train wagon/engine.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | the wagon/engine index

  p2

  the selling mode
  - p2 = 0: only sell the single dragged wagon/engine (and any belonging rear-engines)
  - p2 = 1: 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

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1494 of file train_cmd.cpp.

References CommandCost::AddCost(), ArrangeTrains(), CMD_ERROR, DC_EXEC, DeleteVehicleOrders(), CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), Train::GetFirstEnginePart(), SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), HasBit(), InvalidateWindowClassesData(), InvalidateWindowData(), Train::IsEngine(), Train::IsFrontEngine(), Train::IsRearDualheaded(), Train::IsStoppedInDepot(), MakeTrainBackup(), SpecializedVehicle< T, Type >::Next(), NormaliseSubtypes(), NormaliseTrainHead(), RestoreTrainBackup(), return_cmd_error, ShowVehicleViewWindow(), and ValidateTrains().

CommandCost CmdSellRoadVeh | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Sell a road vehicle.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | vehicle ID to be sold
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 340 of file roadveh_cmd.cpp.

References CMD_ERROR, DC_EXEC, SpecializedVehicle< RoadVehicle, VEH_ROAD >::GetIfValid(), RoadVehicle::IsStoppedInDepot(), and return_cmd_error.

CommandCost CmdSellShareInCompany | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Sell shares in an opposing company.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | company to sell the shares from
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1521 of file economy.cpp.

References _settings_game, EconomySettings::allow_shares, CMD_ERROR, COMPANY_SPECTATOR, DC_EXEC, GameSettings::economy, and SetWindowDirty().

CommandCost CmdSellShip | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Sell a ship.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle ID to be sold
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 711 of file ship_cmd.cpp.

References CMD_ERROR, DC_EXEC, SpecializedVehicle< Ship, VEH_SHIP >::GetIfValid(), and return_cmd_error.

CommandCost CmdSendAircraftToHangar | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Send an aircraft to the hangar.

Parameters:

  | tile | unused
  | flags | for command type
  | p1 | vehicle ID to send to the hangar

  p2

  various bitmasked elements
  - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  - p2 bit 8-10 - VLW flag (for mass goto depot)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 465 of file aircraft_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::GetIfValid(), SendAllVehiclesToDepot(), and VEH_AIRCRAFT.

CommandCost CmdSendRoadVehToDepot | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Send a road vehicle to the depot.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | vehicle ID to send to the depot

  p2

  various bitmasked elements
  - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  - p2 bit 8-10 - VLW flag (for mass goto depot)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 393 of file roadveh_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, SpecializedVehicle< RoadVehicle, VEH_ROAD >::GetIfValid(), SendAllVehiclesToDepot(), and VEH_ROAD.

CommandCost CmdSendShipToDepot | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Send a ship to the depot.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle ID to send to the depot

  p2

  various bitmasked elements
  - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  - p2 bit 8-10 - VLW flag (for mass goto depot)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 753 of file ship_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, SpecializedVehicle< Ship, VEH_SHIP >::GetIfValid(), SendAllVehiclesToDepot(), and VEH_SHIP.

CommandCost CmdSendTrainToDepot | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Send a train to a depot.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | train to send to the depot

  p2

  various bitmasked elements
  - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  - p2 bit 8-10 - VLW flag (for mass goto depot)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 2141 of file train_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, SpecializedVehicle< Train, VEH_TRAIN >::GetIfValid(), SendAllVehiclesToDepot(), and VEH_TRAIN.

CommandCost CmdSetAutoReplace | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change engine renewal parameters.

Parameters:

  | tile | unused
  | flags | operation to perform

  p1

  packed data
  - bits 16-31 = engine group

  p2

  packed data
  - bits 0-15 = old engine type
  - bits 16-31 = new engine type

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 629 of file company_cmd.cpp.

References AddEngineReplacementForCompany(), CheckAutoreplaceValidity(), CMD_ERROR, GB(), InvalidateAutoreplaceWindow(), IsAllGroupID(), and RemoveEngineReplacementForCompany().

CommandCost CmdSetCompanyColour | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change the company's company-colour.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | bitstuffed: p1 bits 0-7 scheme to set p1 bits 8-9 set in use state or first/second colour
  | p2 | new colour for vehicles, property, etc.
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 61 of file misc_cmd.cpp.

References _company_colours, CMD_ERROR, DC_EXEC, GB(), and MarkWholeScreenDirty().

CommandCost CmdSetCompanyManagerFace | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Change the company manager's face.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | face bitmasked
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 38 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, IsValidCompanyManagerFace(), and MarkWholeScreenDirty().

CommandCost CmdSetGroupReplaceProtection | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

(Un)set global replace protection from a group

Parameters:

  | tile | unused
  | flags | type of operation

  p1

  index of group array
  - p1 bit 0-15 : GroupID

  p2

  - p2 bit 0 : 1 to set or 0 to clear protection.

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 338 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetWindowClassForVehicleType(), HasBit(), and InvalidateWindowData().

CommandCost CmdSetTimetableStart | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Set the start date of the timetable.

Parameters:

  | tile | Not used.
  | flags | Operation to perform.
  | p1 | Vehicle id.
  | p2 | The timetable start date in ticks.

Definition at line 148 of file timetable_cmd.cpp.

References _date, _settings_game, ClrBit(), CMD_ERROR, DAYS_IN_LEAP_YEAR, DC_EXEC, GB(), MAX_DAY, GameSettings::order, SetWindowDirty(), OrderSettings::timetabling, and VF_TIMETABLE_STARTED.

CommandCost CmdSetVehicleOnTime | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Clear the lateness counter to make the vehicle on time.

Parameters:

  | tile | Not used.
  | flags | Operation to perform.

  p1

  Various bitstuffed elements
  - p1 = (bit 0-15) - Vehicle with the orders to change.

  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 124 of file timetable_cmd.cpp.

References _settings_game, CMD_ERROR, DC_EXEC, GB(), GameSettings::order, SetWindowDirty(), and OrderSettings::timetabling.

CommandCost CmdSkipToOrder | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Goto order of order-list.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | The ID of the vehicle which order is skipped
  | p2 | the selected order to which we want to skip
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 778 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, InvalidateVehicleOrder(), SetWindowClassesDirty(), VEH_AIRCRAFT, and VEH_SHIP.

CommandCost CmdStartStopVehicle | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Start/Stop a vehicle.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle to start/stop
  | p2 | bit 0: Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 72 of file vehicle_cmd.cpp.

References TrainCache::cached_power, CALLBACK_FAILED, CBID_VEHICLE_START_STOP_CHECK, CheckVehicleControlAllowed(), CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, DeleteVehicleNews(), error(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Train, VEH_TRAIN >::From(), GB(), GetEngineGRFID(), GetGRFStringID(), GetVehicleCallback(), GetWindowClassForVehicleType(), HasBit(), return_cmd_error, SetBit(), SetWindowClassesDirty(), SetWindowDirty(), SetWindowWidgetDirty(), Aircraft::state, Train::tcache, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

CommandCost CmdTerraformLand | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Terraform land.

Parameters:

  | tile | tile to terraform
  | flags | for this command type
  | p1 | corners to terraform (SLOPE_xxx)
  | p2 | direction; eg up (non-zero) or down (zero)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 238 of file terraform_cmd.cpp.

References _terraform_err_tile, _tile_type_procs, CommandCost::AddCost(), CmdFailed(), DC_AUTO, DC_EXEC, GetBridgeHeight(), GetSouthernBridgeEnd(), GetTileType(), INVALID_TILE, IsBridgeAbove(), IsTileType(), IsTunnelInWay(), MapSize(), MarkTileDirtyByTile(), max(), MayHaveBridgeAbove(), min(), MP_VOID, return_cmd_error, SetTileHeight(), SLOPE_E, SLOPE_FLAT, SLOPE_N, SLOPE_S, SLOPE_STEEP, SLOPE_W, TileTypeProcs::terraform_tile_proc, TerraformGetHeightOfTile(), TerraformTileHeight(), TILE_HEIGHT, TileDiffXY(), and TileHeight().

CommandCost CmdTurnRoadVeh | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Turn a roadvehicle around.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | vehicle ID to turn
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 415 of file roadveh_cmd.cpp.

References CheckVehicleControlAllowed(), CMD_ERROR, DC_EXEC, DirToDiagDir(), DRD_NONE, GetDisallowedRoadDirections(), SpecializedVehicle< RoadVehicle, VEH_ROAD >::GetIfValid(), GetTunnelBridgeDirection(), RoadVehicle::IsInDepot(), IsTileType(), MP_TUNNELBRIDGE, RoadVehicle::overtaking, RoadVehicle::reverse_ctr, RVSB_WORMHOLE, and RoadVehicle::state.

CommandCost CmdWantEnginePreview | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Accept an engine prototype.

XXX - it is possible that the top-company changes while you are waiting to accept the offer? Then it becomes invalid

Parameters:

  | tile | unused
  | flags | operation to perfom
  | p1 | engine-prototype offered
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 650 of file engine.cpp.

References CMD_ERROR, and DC_EXEC.

CommandCost DoCommand | ( | TileIndex | tile,
|  | uint32 | p1,
|  | uint32 | p2,
|  | DoCommandFlag | flags,
|  | uint32 | cmd,
|  | const char * | text |
| ) |  |  |

Execute a command.

This function executes a given command with the parameters from the CommandProc parameter list. Depending on the flags parameter it execute or test a command.

Parameters:

  | tile | The tile to apply the command on (for the CommandProc)
  | p1 | Additional data for the command (for the CommandProc)
  | p2 | Additional data for the command (for the CommandProc)
  | flags | Flags for the command and how to execute the command
  | cmd | The command-id to execute (a value of the CMD_* enums)
  | text | The text to pass

See also:
  CommandProc

Returns:
  the cost

Definition at line 407 of file command.cpp.

References CMD_ERROR, CMD_ID_MASK, CmdFailed(), DC_ALL_TILES, DC_BANKRUPT, DC_EXEC, DC_QUERY_COST, error(), CommandCost::GetCost(), INVALID_STRING_ID, IsValidTile(), MapSize(), Command::proc, and CommandCost::SetGlobalErrorMessage().

CommandCost DoCommand | ( | const CommandContainer * | container,
|  | DoCommandFlag | flags |
| ) |  |  |

Shorthand for calling the long DoCommand with a container.

Parameters:

  | container | Container with (almost) all information
  | flags | Flags for the command and how to execute the command

See also:
  CommandProc

Returns:
  the cost

Definition at line 389 of file command.cpp.

References CommandContainer::cmd, CMD_ID_MASK, DoCommand(), CommandContainer::p1, CommandContainer::p2, CommandContainer::text, and CommandContainer::tile.

Referenced by BuildReplacementVehicle(), CanBuildHouseHere(), CanBuildTramTrackOnTile(), CheckFlatLandBelow(), CheckIfCanLevelIndustryPlatform(), ClearMakeHouseTile(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildRailWagon(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdClearArea(), CmdCloneVehicle(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdLevelLand(), CmdMassStartStopVehicle(), CmdPlantTree(), CmdPurchaseLandArea(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdRemoveSingleRail(), CmdRenamePresident(), CmdSignalTrackHelper(), CopyHeadSpecificThings(), DoBuildShiplift(), DoCommand(), DoDryUp(), DoFloodTile(), RefitWindow::DrawWidget(), FloodHalftile(), GrowTown(), GrowTownWithBridge(), GrowTownWithRoad(), IsRoadAllowedHere(), MoveVehicle(), NormalizeTrainVehInDepot(), BuildRailToolbarWindow::OnPlacePresize(), RemoveRailStation(), RemoveRailWaypoint(), RemoveRoad(), ReplaceChain(), ReplaceFreeUnit(), ResetLandscapeConfirmationCallback(), SearchLumberMillTrees(), SendAllVehiclesToDepot(), ShowBuildBridgeWindow(), ShowNewGrfVehicleError(), StartStopVehicle(), StationJoinerNeeded(), and UpdateOrderDest().

bool DoCommandP | ( | TileIndex | tile,
|  | uint32 | p1,
|  | uint32 | p2,
|  | uint32 | cmd,
|  | CommandCallback * | callback,
|  | const char * | text,
|  | bool | my_cmd |
| ) |  |  |

Execute a network safe DoCommand function.

Toplevel network safe docommand function for the current company. Must not be called recursively. The callback is called when the command succeeded or failed. The parameters tile, p1 and p2 are from the CommandProc function. The paramater cmd is the command to execute. The parameter my_cmd is used to indicate if the command is from a company or the server.

Parameters:

  | tile | The tile to perform a command on (see CommandProc)
  | p1 | Additional data for the command (see CommandProc)
  | p2 | Additional data for the command (see CommandProc)
  | cmd | The command to execute (a CMD_* value)
  | callback | A callback function to call after the command is finished
  | text | The text to pass
  | my_cmd | indicator if the command is from a company or server (to display error messages for a user)

Returns:
  true if the command succeeded, else false

Definition at line 503 of file command.cpp.

References _date, _shift_pressed, ClearStorageChanges(), CMD_ALL_TILES, CMD_COMPANY_CTRL, CMD_FLAGS_MASK, CMD_ID_MASK, CMD_NETWORK_COMMAND, CMD_NO_TEST, CMD_NO_TEST_IF_IN_NETWORK, CMD_PAUSE, CMD_SERVER, CMD_SPECTATOR, CmdFailed(), CommandFlagsToDCFlags(), COMPANY_SPECTATOR, DC_EXEC, GB(), GetCommandFlags(), CommandCost::GetCost(), INVALID_STRING_ID, IsGeneratingWorld(), IsValidTile(), lengthof, MapSize(), Command::proc, SetDParam(), CommandCost::SetGlobalErrorMessage(), ShowErrorMessage(), TILE_SIZE, TileX(), TileY(), and UpdateSignalsInBuffer().

bool DoCommandP | ( | const CommandContainer * | container,
|  | bool | my_cmd |
| ) |  |  |

Shortcut for the long DoCommandP when having a container with the data.

Parameters:

  | container | the container with information.
  | my_cmd | indicator if the command is from a company or server (to display error messages for a user)

Returns:
  true if the command succeeded, else false

Definition at line 483 of file command.cpp.

References CommandContainer::callback, CommandContainer::cmd, DoCommandP(), CommandContainer::p1, CommandContainer::p2, CommandContainer::text, and CommandContainer::tile.

Referenced by _GenerateWorld(), AskUnsafeUnpauseCallback(), ChangeTimetableStartCallback(), CheckTrainsLengths(), CommonRaiseLowerBigLand(), AIObject::DoCommand(), DoCommandP(), GenerateDesertArea(), GenericPlaceSignals(), GUIPlaceProcDragXY(), HandleAutoSignalPlacement(), VehicleViewWindow::OnClick(), VehicleDetailsWindow::OnClick(), VehicleListWindow::OnClick(), RefitWindow::OnClick(), SelectStationWindow< T >::OnClick(), OrdersWindow::OnClick(), BuildIndustryWindow::OnClick(), CompanyWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), SelectCompanyLiveryWindow::OnClick(), CompanyFinancesWindow::OnClick(), ReplaceVehicleWindow::OnClick(), AIDebugWindow::OnClick(), OrdersWindow::OnDragDrop(), VehicleListWindow::OnDropdownSelect(), OrdersWindow::OnDropdownSelect(), SelectCompanyLiveryWindow::OnDropdownSelect(), BuildTreesWindow::OnPlaceMouseUp(), BuildRailToolbarWindow::OnPlaceMouseUp(), OrdersWindow::OnPlaceObject(), BuildIndustryWindow::OnPlaceObject(), CompanyWindow::OnPlaceObject(), OrdersWindow::OnPlaceObjectAbort(), VehicleDetailsWindow::OnQueryTextFinished(), StationViewWindow::OnQueryTextFinished(), OrdersWindow::OnQueryTextFinished(), CompanyWindow::OnQueryTextFinished(), OrdersWindow::OrderClick_Delete(), OrdersWindow::OrderClick_FullLoad(), OrdersWindow::OrderClick_NearestDepot(), OrdersWindow::OrderClick_Nonstop(), OrdersWindow::OrderClick_Refit(), OrdersWindow::OrderClick_Service(), OrdersWindow::OrderClick_Skip(), OrdersWindow::OrderClick_Unload(), PlaceExtraDepotRail(), PlaceProc_Sign(), RenameSign(), RestoreVehicleOrders(), SetCompanySetting(), SetSettingValue(), ShowBuildBridgeWindow(), and ShowSelectBaseStationIfNeeded().

Money GetAvailableMoneyForCommand | ( |  | ) |

Returns the current money available which can be used for a command.

This functions returns the money which can be used to execute a command. This is either the money of the current company or INT64_MAX if there is no such a company "at the moment" like the server itself.

Returns:
  The available money of a company or INT64_MAX

Definition at line 470 of file command.cpp.

Referenced by CmdClearArea(), CmdFoundTown(), CmdLevelLand(), and CmdRemoveLongRoad().

byte GetCommandFlags | ( | uint32 | cmd | ) |

Returns the flags from a given command.

This function mask the parameter with CMD_ID_MASK and returns the flags which belongs to the given command.

Parameters:

  | cmd | The integer value of the command

Returns:
  The flags for this command

Definition at line 372 of file command.cpp.

References CMD_ID_MASK, Command::flags, and IsValidCommand().

Referenced by AIObject::DoCommand(), DoCommandP(), and StationJoinerNeeded().

bool IsValidCommand | ( | uint32 | cmd | ) |

Checks if a integer value belongs to a command.

This function range-checks a cmd, and checks if the cmd is not NULL

Parameters:

  | cmd | The integervalue of a command

Returns:
  true if the command is valid (and got a CommandProc function)

Definition at line 356 of file command.cpp.

References CMD_ID_MASK, lengthof, and Command::proc.

Referenced by GetCommandFlags().

## Variable Documentation

const Command _command_proc_table[]`[static]`

The master command table.

This table contains all possible CommandProc functions with the flags which belongs to it. The indizes are the same as the value from the CMD_* enums.

Definition at line 211 of file command.cpp.