# command.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "landscape.h"`
`#include "tile_map.h"`
`#include "gui.h"`
`#include "command_func.h"`
`#include "network/network.h"`
`#include "variables.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 "player_func.h"`
`#include "player_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, uint32 flags, uint32 p1, uint32 p2)
| Helper macro to define the header of all command handler macros.
## Functions
CommandCost | CmdBuildRailroadTrack (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build rail on a stretch of track.
CommandCost | CmdRemoveRailroadTrack (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build rail on a stretch of track.
CommandCost | CmdBuildSingleRail (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a single piece of rail.
CommandCost | CmdRemoveSingleRail (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove a single piece of track.
CommandCost | CmdLandscapeClear (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Clear a piece of landscape.
CommandCost | CmdBuildBridge (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a Bridge.
CommandCost | CmdBuildRailroadStation (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build railroad station.
CommandCost | CmdRemoveFromRailroadStation (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove a single tile from a railroad station.
CommandCost | CmdConvertRail (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Convert one rail type to the other.
CommandCost | CmdBuildSingleSignal (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals, and what-else not.
CommandCost | CmdRemoveSingleSignal (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove signals.
CommandCost | CmdTerraformLand (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Terraform land.
CommandCost | CmdPurchaseLandArea (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Purchase a land area.
CommandCost | CmdSellLandArea (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Sell a land area.
CommandCost | CmdBuildTunnel (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build Tunnel.
CommandCost | CmdBuildTrainDepot (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a train depot.
CommandCost | CmdBuildTrainWaypoint (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Convert existing rail to waypoint.
CommandCost | CmdRenameWaypoint (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename a waypoint.
CommandCost | CmdRemoveTrainWaypoint (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Delete a waypoint.
CommandCost | CmdBuildRoadStop (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a bus or truck stop.
CommandCost | CmdRemoveRoadStop (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove a bus or truck stop.
CommandCost | CmdBuildLongRoad (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a long piece of road.
CommandCost | CmdRemoveLongRoad (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove a long piece of road.
CommandCost | CmdBuildRoad (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a piece of road.
CommandCost | CmdRemoveRoad (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Delete a piece of road.
CommandCost | CmdBuildRoadDepot (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a road depot.
CommandCost | CmdBuildAirport (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Place an Airport.
CommandCost | CmdBuildDock (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a dock/haven.
CommandCost | CmdBuildShipDepot (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a ship depot.
CommandCost | CmdBuildBuoy (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a buoy.
CommandCost | CmdPlantTree (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Plant a tree.
CommandCost | CmdBuildRailVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a railroad vehicle.
CommandCost | CmdMoveRailVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Move a rail vehicle around inside the depot.
CommandCost | CmdStartStopTrain (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Start/Stop a train.
CommandCost | CmdSellRailWagon (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Sell a (single) train wagon/engine.
CommandCost | CmdSendTrainToDepot (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Send a train to a depot.
CommandCost | CmdForceTrainProceed (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Force a train through a red signal.
CommandCost | CmdReverseTrainDirection (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Reverse train.
CommandCost | CmdModifyOrder (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Modify an order in the orderlist of a vehicle.
CommandCost | CmdSkipToOrder (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Goto order of order-list.
CommandCost | CmdDeleteOrder (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Delete an order from the orderlist of a vehicle.
CommandCost | CmdInsertOrder (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Add an order to the orderlist of a vehicle.
CommandCost | CmdChangeServiceInt (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change the service interval of a vehicle.
CommandCost | CmdRestoreOrderIndex (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Restore the current order-index of a vehicle and sets service-interval.
CommandCost | CmdBuildIndustry (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build/Fund an industry.
CommandCost | CmdBuildCompanyHQ (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build or relocate the HQ.
CommandCost | CmdSetPlayerFace (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change the player's face.
CommandCost | CmdSetPlayerColor (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change the player's company-colour.
CommandCost | CmdIncreaseLoan (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Increase the loan of your company.
CommandCost | CmdDecreaseLoan (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Decrease the loan of your company.
CommandCost | CmdWantEnginePreview (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Accept an engine prototype.
CommandCost | CmdNameVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Give a custom name to your vehicle.
CommandCost | CmdRenameEngine (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename an engine.
CommandCost | CmdChangeCompanyName (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change the name of the company.
CommandCost | CmdChangePresidentName (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change the name of the president.
CommandCost | CmdRenameStation (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename a station.
CommandCost | CmdSellAircraft (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Sell an aircraft.
CommandCost | CmdStartStopAircraft (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Start/Stop an aircraft.
CommandCost | CmdBuildAircraft (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build an aircraft.
CommandCost | CmdSendAircraftToHangar (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Send an aircraft to the hangar.
CommandCost | CmdRefitAircraft (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Refits an aircraft to the specified cargo type.
CommandCost | CmdPlaceSign (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Place a sign at the given coordinates.
CommandCost | CmdRenameSign (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename a sign.
CommandCost | CmdBuildRoadVeh (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a road vehicle.
CommandCost | CmdStartStopRoadVeh (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Start/Stop a road vehicle.
CommandCost | CmdSellRoadVeh (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Sell a road vehicle.
CommandCost | CmdSendRoadVehToDepot (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Send a road vehicle to the depot.
CommandCost | CmdTurnRoadVeh (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Turn a roadvehicle around.
CommandCost | CmdRefitRoadVeh (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Refit a road vehicle to the specified cargo type.
CommandCost | CmdPause (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Pause/Unpause the game (server-only).
CommandCost | CmdBuyShareInCompany (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Acquire shares in an opposing company.
CommandCost | CmdSellShareInCompany (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Sell shares in an opposing company.
CommandCost | CmdBuyCompany (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Buy up another company.
CommandCost | CmdBuildTown (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Create a new town.
CommandCost | CmdRenameTown (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename a town (server-only).
CommandCost | CmdDoTownAction (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Do a town action.
CommandCost | CmdSetRoadDriveSide (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change the side of the road vehicles drive on (server only).
CommandCost | CmdChangeDifficultyLevel (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change difficulty level/settings (server-only).
CommandCost | CmdChangePatchSetting (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Network-safe changing of patch-settings (server-only).
CommandCost | CmdStartStopShip (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Start/Stop a ship.
CommandCost | CmdSellShip (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Sell a ship.
CommandCost | CmdBuildShip (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a ship.
CommandCost | CmdSendShipToDepot (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Send a ship to the depot.
CommandCost | CmdRefitShip (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Refits a ship to the specified cargo type.
CommandCost | CmdOrderRefit (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Add/remove refit orders from an order.
CommandCost | CmdCloneOrder (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Clone/share/copy an order-list of an other vehicle.
CommandCost | CmdClearArea (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Clear a big piece of landscape.
CommandCost | CmdGiveMoney (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Transfer funds (money) from one player to another.
CommandCost | CmdMoneyCheat (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change the financial flow of your company.
CommandCost | CmdBuildCanal (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a piece of canal.
CommandCost | CmdBuildLock (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Builds a lock (ship-lift).
CommandCost | CmdPlayerCtrl (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Control the players: add, delete, etc.
CommandCost | CmdLevelLand (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Levels a selected (rectangle) area of land.
CommandCost | CmdRefitRailVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Refits a train to the specified cargo type.
CommandCost | CmdBuildSignalTrack (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build signals on a stretch of track.
CommandCost | CmdRemoveSignalTrack (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove signals on a stretch of track.
CommandCost | CmdSetAutoReplace (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Change engine renewal parameters.
CommandCost | CmdCloneVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Clone a vehicle.
CommandCost | CmdMassStartStopVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Starts or stops a lot of vehicles.
CommandCost | CmdDepotSellAllVehicles (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Sells all vehicles in a depot.
CommandCost | CmdDepotMassAutoReplace (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Autoreplace all vehicles in the depot.
CommandCost | CmdCreateGroup (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Create a new vehicle group.
CommandCost | CmdRenameGroup (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename a group.
CommandCost | CmdDeleteGroup (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Add all vehicles in the given group to the default group and then deletes the group.
CommandCost | CmdAddVehicleGroup (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Add a vehicle to a group.
CommandCost | CmdAddSharedVehicleGroup (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Add all shared vehicles of all vehicles from a group.
CommandCost | CmdRemoveAllVehiclesGroup (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove all vehicles from a group.
CommandCost | CmdSetGroupReplaceProtection (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| (Un)set global replace protection from a group
CommandCost | CmdMoveOrder (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Move an order inside the orderlist.
CommandCost | CmdChangeTimetable (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Add or remove waiting times from an order.
CommandCost | CmdSetVehicleOnTime (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Clear the lateness counter to make the vehicle on time.
CommandCost | CmdAutofillTimetable (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Start or stop filling the timetable automatically from the time the vehicle actually takes to complete it.
bool | IsValidCommand (uint cmd)
| Checks if a integer value belongs to a command.
byte | GetCommandFlags (uint cmd)
| Returns the flags from a given command.
CommandCost | DoCommand (TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
| Execute a command.
Money | GetAvailableMoneyForCommand ()
| Returns the current money available which can be used for a command.
bool | DoCommandP (TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd)
| Execute a network safe DoCommand function.
## Variables
const char * | _cmd_text = NULL
| Text, which gets sent with a command.
StringID | _error_message
static const Command | _command_proc_table []
| The master command table.
static int | _docommand_recursive = 0

## Detailed Description

Definition in file command.cpp.

## Define Documentation

#define DEF_COMMAND | ( | yyyy |  | ) | CommandCost yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)

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 39 of file command.cpp.

## Function Documentation

CommandCost CmdAddSharedVehicleGroup | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Add all shared vehicles of all vehicles from a group.

Parameters:

  | tile | unused
  | p1 | index of group array p1 bit 0-15 : GroupID
  | p2 | type of vehicles

Definition at line 254 of file group_cmd.cpp.

References CMD_ERROR, CmdAddVehicleGroup(), DC_EXEC, and GetFirstVehicleFromSharedList().

CommandCost CmdAddVehicleGroup | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Add a vehicle to a group.

Parameters:

  | tile | unused
  | p1 | index of array group p1 bit 0-15 : GroupID
  | p2 | vehicle to add to a group p2 bit 0-15 : VehicleID

Definition at line 207 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, IsEngineCountable(), IsValidVehicleID(), SetTrainGroupID(), and UpdateNumEngineGroup().

Referenced by CmdAddSharedVehicleGroup(), and CmdRemoveAllVehiclesGroup().

CommandCost CmdAutofillTimetable | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 | Set to 1 to enable, 0 to disable.

Definition at line 116 of file timetable_cmd.cpp.

References ClrBit(), CMD_ERROR, DC_EXEC, GB(), GetFirstVehicleFromSharedList(), IsValidVehicleID(), SetBit(), VF_AUTOFILL_TIMETABLE, and VF_TIMETABLE_STARTED.

CommandCost CmdBuildAircraft | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build an aircraft.

Parameters:

  | tile | tile of depot where aircraft is built
  | flags | for command
  | p1 | aircraft type being built (engine)
  | p2 | unused return result of operation. Could be cost, error

Definition at line 277 of file aircraft_cmd.cpp.

References AIR_AIRCRAFT, AIR_CTOL, AIR_HELICOPTER, AIR_ROTOR, AIR_SHADOW, Aircraft::Aircraft(), AircraftDefaultCargoCapacity(), CALLBACK_FAILED, CanAircraftUseStation(), CBID_VEHICLE_REFIT_CAPACITY, CBM_VEHICLE_REFIT_CAPACITY, CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, DIR_N, DIR_SE, ENGINE_EXCLUSIVE_PREVIEW, FindFirstRefittableCargo(), CommandCost::GetCost(), GetVehicleCallback(), HasBit(), INVALID_DIR, InvalidateAutoreplaceWindow(), IsEngineBuildable(), IsTileOwner(), return_cmd_error, SetBit(), TILE_SIZE, TileX(), TileY(), ToTileIndexDiff(), UpdateAircraftCache(), and VehicleRandomBits().

CommandCost CmdBuildAirport | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Place an Airport.

Parameters:

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

See also:
  airport.h

Parameters:

  | p2 | (bit 0) - allow airports directly adjacent to other airports.

Definition at line 1651 of file station_cmd.cpp.

References CommandCost::AddCost(), BEGIN_TILE_LOOP, CheckFlatLandBelow(), CMD_ERROR, CmdFailed(), DC_NO_TOWN_RATING, END_TILE_LOOP, GetValidAirports(), HasBit(), RebuildStationLists(), return_cmd_error, SetBit(), SVW_PLANES, UpdateAirplanesOnNewStation(), UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdBuildBridge | ( | TileIndex | end_tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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-..) - rail type or road types. p2 = (bit 15 ) - set means road bridge.

Definition at line 181 of file tunnelbridge_cmd.cpp.

References CommandCost::AddCost(), AddSideToSignalBuffer(), AreValidRoadTypes(), AXIS_X, AXIS_Y, AxisToDiagDir(), AxisToTrack(), CalcBridgeLenCostFactor(), CheckBridgeSlopeNorth(), CheckBridgeSlopeSouth(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DiagDirToAxis(), DoCommand(), GB(), GetBridgeAxis(), GetBridgeHeight(), GetBridgeType(), CommandCost::GetCost(), GetNorthernBridgeEnd(), GetOtherBridgeEnd(), GetRailType(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), INVALID_DIAGDIR, INVALID_RAILTYPE, IsBridgeAbove(), IsBridgeTile(), IsOwnedLand(), IsPlainRailTile(), IsTileOwner(), IsTunnel(), IsWater(), 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(), Swap(), TILE_HEIGHT, TileDiffXY(), TileX(), TileXY(), TileY(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildBuoy | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build a buoy.

Parameters:

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

Definition at line 1819 of file station_cmd.cpp.

References IsBridgeAbove(), MayHaveBridgeAbove(), OWNER_NONE, RebuildStationLists(), return_cmd_error, SetBit(), SLOPE_FLAT, SVW_SHIPS, UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdBuildCanal | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 343 of file water_cmd.cpp.

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

CommandCost CmdBuildCompanyHQ | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 88 of file unmovable_cmd.cpp.

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

CommandCost CmdBuildDock | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 | unused

Definition at line 1930 of file station_cmd.cpp.

References CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_NO_TOWN_RATING, DoCommand(), GetInclinedSlopeDirection(), HasBit(), INVALID_DIAGDIR, IsBridgeAbove(), IsTileType(), MayHaveBridgeAbove(), MP_WATER, RebuildStationLists(), return_cmd_error, ReverseDiagDir(), SetBit(), SLOPE_FLAT, SVW_SHIPS, TileOffsByDiagDir(), ToTileIndexDiff(), UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdBuildIndustry | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build/Fund an industry.

Parameters:

  | tile | tile where industry is built
  | flags | of operations to conduct
  | p1 | various bitstuffed elements p1 = (bit 0 - 15) - industry type see build_industry.h and see industry.h p1 = (bit 16 - 31) - first layout to try
  | p2 | seed to use for variable 8F

Returns:
  index of the newly create industry, or CMD_ERROR if it failed

Definition at line 1625 of file industry_cmd.cpp.

References AddNewsItem(), Clamp(), CMD_ERROR, CreateNewIndustryHelper(), IndustrySpec::enabled, GB(), IndustrySpec::GetConstructionCost(), GetIndustrySpec(), IndustrySpec::IsRawIndustry(), IndustrySpec::name, IndustrySpec::new_industry_text, NEWS_FLAGS, NF_TILE, NF_VIEWPORT, NM_THIN, NT_OPENCLOSE, IndustrySpec::num_table, IndustrySpec::prospecting_chance, RandomTile, IndustrySpec::table, Industry::town, and Industry::xy.

CommandCost CmdBuildLock | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Builds a lock (ship-lift).

Parameters:

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

Definition at line 326 of file water_cmd.cpp.

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

CommandCost CmdBuildLongRoad | ( | TileIndex | end_tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 649 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(), IsBridge(), IsInsideMM(), IsTileType(), IsValidRoadType(), MapSize(), MP_TUNNELBRIDGE, ROAD_NE, ROAD_NW, ROAD_SE, ROAD_SW, ROAD_X, ROAD_Y, TileDiffXY(), TileX(), and TileY().

CommandCost CmdBuildRailroadStation | ( | TileIndex | tile_org,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build railroad station.

Parameters:

  | tile_org | starting position of station dragging/placement
  | flags | operation to perform
  | p1 | various bitstuffed elements p1 = (bit 0) - 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- 3) - railtype (p2 & 0xF) p2 = (bit 8-15) - custom station class p2 = (bit 16-23) - custom station id

Definition at line 898 of file station_cmd.cpp.

References AddTrackToSignalBuffer(), AllocateSpecToStation(), AXIS_X, AxisToTrack(), CALLBACK_FAILED, CBID_STATION_AVAILABILITY, CBID_STATION_TILE_LAYOUT, CBM_STATION_AVAIL, CheckFlatLandBelow(), CMD_ERROR, CmdFailed(), DC_EXEC, DC_NO_TOWN_RATING, GB(), CommandCost::GetCost(), GetCustomStationSpec(), GetNumStationClasses(), HasBit(), INVALID_TILE, RebuildStationLists(), return_cmd_error, SetBit(), SVW_TRAINS, TileDiffXY(), UpdateStationAcceptance(), UpdateStationVirtCoordDirty(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildRailroadTrack | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

See also:
  CmdRailTrackHelper

Definition at line 702 of file rail_cmd.cpp.

References ClrBit(), and CmdRailTrackHelper().

CommandCost CmdBuildRailVehicle | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 766 of file train_cmd.cpp.

References CMD_ERROR, CmdBuildRailWagon(), DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, DEFAULT_GROUP, DiagDirToDir(), ENGINE_EXCLUSIVE_PREVIEW, CommandCost::GetCost(), GetRailDepotDirection(), GetRailType(), HasBit(), HasPowerOnRail(), InvalidateAutoreplaceWindow(), IsEngineBuildable(), IsTileDepotType(), IsTileOwner(), NormalizeTrainVehInDepot(), RAILVEH_MULTIHEAD, RAILVEH_WAGON, return_cmd_error, SetBit(), SetFrontEngine(), SetMultiheaded(), SetTrainEngine(), TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, Train::Train(), TrainConsistChanged(), UpdateTrainGroupID(), and VehicleRandomBits().

CommandCost CmdBuildRoad | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Definition at line 413 of file road_cmd.cpp.

References CommandCost::AddCost(), AXIS_X, AXIS_Y, AxisToRoadBits(), CheckRoadSlope(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), ComplementRoadBits(), CountBits(), DC_EXEC, DiagDirToAxis(), DoCommand(), DRD_NONE, FindFirstTrack(), GB(), CommandCost::GetCost(), GetDisallowedRoadDirections(), GetOtherTunnelBridgeEnd(), GetRailTileType(), GetRailType(), GetRoadStopDir(), GetTileOwner(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasBit(), HasVehicleOnTunnelBridge(), IsBridge(), IsSteepSlope(), IsTileType(), IsValidRoadType(), IsValidTownID(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, CommandCost::MultiplyCost(), OWNER_TOWN, RAIL_TILE_NORMAL, return_cmd_error, ROAD_NONE, ROAD_X, ROAD_Y, ROADTYPE_END, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ROAD, RoadTypeToRoadTypes(), SetDisallowedRoadDirections(), SetTownIndex(), TileOffsByDiagDir(), TRACK_BIT_X, TRACK_BIT_Y, UpdateLevelCrossing(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildRoadDepot | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

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

Definition at line 802 of file road_cmd.cpp.

References CommandCost::AddCost(), CanBuildDepotByTileh(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), GB(), IsBridgeAbove(), IsSteepSlope(), IsValidRoadType(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), return_cmd_error, and SLOPE_FLAT.

CommandCost CmdBuildRoadStop | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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..4: the roadtypes bit 5: allow stations directly adjacent to other stations.

Definition at line 1321 of file station_cmd.cpp.

References CommandCost::AddCost(), AreValidRoadTypes(), AXIS_X, RoadStop::BUS, PoolItem< T, Tid, Tpool >::CanAllocateItem(), CheckFlatLandBelow(), CMD_ERROR, CmdFailed(), CountBits(), DC_NO_TOWN_RATING, FindRoadStopSpot(), GB(), HasBit(), IsValidAxis(), IsValidDiagDirection(), RoadStop::LIMIT, OWNER_NONE, OWNER_TOWN, RebuildStationLists(), return_cmd_error, ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, SetBit(), SVW_ROADVEHS, RoadStop::TRUCK, UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdBuildRoadVeh | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 168 of file roadveh_cmd.cpp.

References CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, DiagDirToDir(), EF_ROAD_TRAM, ENGINE_EXCLUSIVE_PREVIEW, CommandCost::GetCost(), HasBit(), InvalidateAutoreplaceWindow(), IsEngineBuildable(), IsTileDepotType(), IsTileOwner(), return_cmd_error, ROADTYPE_ROAD, ROADTYPE_TRAM, RoadTypeToRoadTypes(), RoadVehicle::RoadVehicle(), RVSB_IN_DEPOT, SetBit(), TILE_SIZE, TileX(), TileY(), and VehicleRandomBits().

CommandCost CmdBuildShip | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build a ship.

Parameters:

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

Definition at line 807 of file ship_cmd.cpp.

References CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, DC_QUERY_COST, ENGINE_EXCLUSIVE_PREVIEW, CommandCost::GetCost(), InvalidateAutoreplaceWindow(), IsEngineBuildable(), IsTileDepotType(), IsTileOwner(), return_cmd_error, SetBit(), Ship::Ship(), TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, and VehicleRandomBits().

CommandCost CmdBuildShipDepot | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build a ship depot.

Parameters:

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

Definition at line 171 of file water_cmd.cpp.

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

CommandCost CmdBuildSignalTrack | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 24-31) - user defined signals_density

See also:
  CmdSignalTrackHelper

Definition at line 1090 of file rail_cmd.cpp.

References CmdSignalTrackHelper().

CommandCost CmdBuildSingleRail | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 305 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(), GetTileType(), GetTownIndex(), GetTrackBits(), HasBit(), HasPowerOnRail(), IsCompatibleRail(), IsSlopeWithOneCornerRaised(), IsTileOwner(), IsTileType(), M, MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_WATER, RAIL_GROUND_BARREN, RAIL_GROUND_WATER, RailBuildCost(), return_cmd_error, ROAD_X, ROAD_Y, ROADTYPE_HWAY, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ALL, ROADTYPES_ROAD, ROADTYPES_ROADHWAY, ROADTYPES_ROADTRAM, ROADTYPES_TRAM, ROADTYPES_TRAMHWAY, 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,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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-6) - type of the signal, for valid values see enum SignalType in rail_map.h p1 = (bit 7) - convert the present signal type and variant
  | p2 | used for CmdBuildManySignals() to copy direction of first signal TODO: p2 should be replaced by two bits for "along" and "against" the track.

Definition at line 795 of file rail_cmd.cpp.

References AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, EnsureNoTrainOnTrack(), GB(), GetPresentSignals(), GetTrackBits(), HasBit(), HasSignalOnTrack(), HasSignals(), HasTrack(), IsPlainRailTile(), IsTileType(), KillFirstBit(), MarkTileDirtyByTile(), MP_RAILWAY, return_cmd_error, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SIG_SEMAPHORE, SignalOnTrack(), SIGTYPE_COMBO, SIGTYPE_NORMAL, TRACK_BIT_HORZ, TRACK_BIT_NONE, TRACK_BIT_VERT, and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildTown | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Create a new town.

This obviously only works in the scenario editor. Function not removed as it might be possible in the future to fund your own town :)

Parameters:

  | tile | coordinates where town is built
  | flags | type of operation
  | p1 | size of the town (0 = small, 1 = medium, 2 = large)
  | p2 | size mode (

See also:
  TownSizeMode)

Definition at line 1486 of file town_cmd.cpp.

References CMD_ERROR, DC_EXEC, DistanceFromEdge(), DoCreateTown(), IsCloseToTown(), IsTileType(), MP_CLEAR, MP_TREES, return_cmd_error, and SLOPE_FLAT.

CommandCost CmdBuildTrainDepot | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

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

Definition at line 732 of file rail_cmd.cpp.

References CommandCost::AddCost(), AddSideToSignalBuffer(), CanBuildDepotByTileh(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DiagdirToDiagTrackdir(), DoCommand(), INVALID_DIAGDIR, IsBridgeAbove(), IsSteepSlope(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), return_cmd_error, SLOPE_FLAT, TrackdirToTrack(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildTrainWaypoint | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Convert existing rail to waypoint.

Eg build a waypoint station over piece of rail

Parameters:

  | tile | tile where waypoint will be built
  | flags | type of operation
  | p1 | graphics for waypoint type, 0 indicates standard graphics
  | p2 | unused

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

Definition at line 188 of file waypoint.cpp.

References AXIS_X, AXIS_Y, AxisToTrack(), CMD_ERROR, DC_EXEC, FindDeletedWaypointCloseTo(), GetCustomStationSpec(), GetNumCustomStations(), GetRailTileType(), GetRailType(), GetTileOwner(), GetTrackBits(), IsBridgeAbove(), IsSteepSlope(), IsTileType(), MakeDefaultWaypointName(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), MP_RAILWAY, RAIL_TILE_NORMAL, RedrawWaypointSign(), return_cmd_error, SLOPE_FLAT, STAT_CLASS_WAYP, TRACK_BIT_X, TRACK_BIT_Y, UpdateWaypointSign(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildTunnel | ( | TileIndex | start_tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price

Number of tiles from start of tunnel

Number of tiles at which the cost increase coefficient per tile is halved

Definition at line 455 of file tunnelbridge_cmd.cpp.

References CommandCost::AddCost(), AddSideToSignalBuffer(), AreValidRoadTypes(), AXIS_X, AxisToTrack(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CMD_TERRAFORM_LAND, CmdFailed(), ComplementSlope(), DC_AUTO, DC_EXEC, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), DoCommand(), GB(), CommandCost::GetCost(), GetInclinedSlopeDirection(), INVALID_DIAGDIR, IsTunnelInWayDir(), MakeRailTunnel(), MakeRoadTunnel(), MapMaxX(), OtherAxis(), return_cmd_error, ReverseDiagDir(), TileOffsByDiagDir(), TileX(), TileY(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuyCompany | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 players

Parameters:

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

Definition at line 1976 of file economy.cpp.

References _networking, CMD_ERROR, and DC_EXEC.

CommandCost CmdBuyShareInCompany | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Acquire shares in an opposing company.

Parameters:

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

Definition at line 1888 of file economy.cpp.

References CommandCost::AddCost(), CMD_ERROR, DC_EXEC, PLAYER_SPECTATOR, and return_cmd_error.

CommandCost CmdChangeCompanyName | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Change the name of the company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | unused

Definition at line 226 of file misc_cmd.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, MarkWholeScreenDirty(), MAX_LENGTH_COMPANY_NAME, and return_cmd_error.

CommandCost CmdChangeDifficultyLevel | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Change difficulty level/settings (server-only).

We cannot really check for valid values of p2 (too much work mostly); stored in file 'settings_gui.c' _game_setting_info[]; we'll just trust the server it knows what to do and does this correctly

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the difficulty setting being changed. If it is -1, the difficulty level itself is changed. The new value is inside p2
  | p2 | new value for a difficulty setting or difficulty level

Definition at line 393 of file misc_cmd.cpp.

References _networking, CMD_ERROR, and DC_EXEC.

CommandCost CmdChangePatchSetting | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Parameters:

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

See also:
  _patch_settings

Definition at line 1881 of file settings.cpp.

References _networking, _patches_newgame, CMD_ERROR, DC_EXEC, GetVariableAddress(), ReadValue(), SGF_NETWORK_ONLY, SGF_NO_NETWORK, SlIsObjectCurrentlyValid(), and Write_ValidateSetting().

CommandCost CmdChangePresidentName | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Change the name of the president.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | unused

Definition at line 263 of file misc_cmd.cpp.

References _cmd_text, CMD_CHANGE_COMPANY_NAME, CMD_ERROR, DC_EXEC, DoCommand(), MarkWholeScreenDirty(), MAX_LENGTH_PRESIDENT_NAME, and return_cmd_error.

CommandCost CmdChangeServiceInt | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 2423 of file vehicle.cpp.

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

CommandCost CmdChangeTimetable | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 54 of file timetable_cmd.cpp.

References CMD_ERROR, DC_EXEC, GB(), HasBit(), IsValidVehicleID(), OFB_NON_STOP, and return_cmd_error.

CommandCost CmdClearArea | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 557 of file landscape.cpp.

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

Referenced by CmdClearArea().

CommandCost CmdCloneOrder | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 746 of file order_cmd.cpp.

References AssignOrder(), CC_PASSENGERS, CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteVehicleOrders(), GB(), GetFirstVehicleFromSharedList(), INVALID_TILE, InvalidateVehicleOrder(), IsValidVehicleID(), and return_cmd_error.

CommandCost CmdCloneVehicle | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 1822 of file vehicle.cpp.

References CommandCost::AddCost(), CMD_ADD_VEHICLE_GROUP, CMD_CLONE_ORDER, CMD_ERROR, CMD_MOVE_RAIL_VEHICLE, CmdFailed(), CmdSucceeded(), DC_EXEC, DoCommand(), EngineHasArticPart(), GetEngineCargoType(), GetNextArticPart(), GetNextVehicle(), GetRefitCost(), HasBit(), IsFrontEngine(), IsRearDualheaded(), IsValidVehicleID(), return_cmd_error, and SetBit().

CommandCost CmdConvertRail | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 1178 of file rail_cmd.cpp.

References CommandCost::AddCost(), AxisToTrack(), CMD_ERROR, CountBits(), DC_EXEC, DiagDirToAxis(), FindVehicleOnPos(), CommandCost::GetCost(), GetOtherTunnelBridgeEnd(), GetRailDepotDirection(), GetRailTileType(), GetRailType(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), GetWaypointAxis(), HasVehicleOnTunnelBridge(), IsBridge(), IsCompatibleRail(), MapSize(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, RAIL_TILE_DEPOT, RAIL_TILE_WAYPOINT, RailConvertCost(), RAILTYPE_ELECTRIC, RAILTYPE_RAIL, RemoveFirstTrack(), SetRailType(), Swap(), TileOffsByDiagDir(), TileX(), TileXY(), TileY(), TRACK_BIT_NONE, UpdateTrainPowerProc(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdCreateGroup | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Create a new vehicle group.

Parameters:

  | tile | unused
  | p1 | vehicle type
  | p2 | unused

Definition at line 89 of file group_cmd.cpp.

References CMD_ERROR, and DC_EXEC.

CommandCost CmdDecreaseLoan | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Decrease the loan of your company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | when 0: pays back LOAN_INTERVAL when 1: pays back the maximum loan permitting money (press CTRL),

Definition at line 174 of file misc_cmd.cpp.

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

CommandCost CmdDeleteGroup | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Parameters:

  | tile | unused
  | p1 | index of array group p1 bit 0-15 : GroupID
  | p2 | unused

Definition at line 115 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, DEFAULT_GROUP, EngineRenew::from, EngineRenew::group_id, MAX_PLAYERS, and RemoveEngineReplacementForPlayer().

CommandCost CmdDeleteOrder | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Definition at line 455 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteOrderWarnings(), GetFirstVehicleFromSharedList(), HasBit(), InvalidateVehicleOrder(), IsValidVehicleID(), RemoveSharedOrderVehicleList(), and SwapOrders().

CommandCost CmdDepotMassAutoReplace | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Autoreplace all vehicles in the depot.

Parameters:

  | tile | Tile of the depot where the vehicles are
  | flags | type of operation
  | p1 | Type of vehicle
  | p2 | Unused

Definition at line 1757 of file vehicle.cpp.

References CommandCost::AddCost(), BuildDepotVehicleList(), CMD_ERROR, CmdSucceeded(), DC_EXEC, GB(), CommandCost::GetCost(), IsDepotTile(), and IsTileOwner().

CommandCost CmdDepotSellAllVehicles | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 1704 of file vehicle.cpp.

References CommandCost::AddCost(), BuildDepotVehicleList(), CMD_ERROR, CMD_SELL_AIRCRAFT, CMD_SELL_RAIL_WAGON, CMD_SELL_ROAD_VEH, CMD_SELL_SHIP, CmdSucceeded(), DoCommand(), GB(), and CommandCost::GetCost().

CommandCost CmdDoTownAction | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 2261 of file town_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetMaskOfTownActions(), HasBit(), and IsValidTownID().

CommandCost CmdForceTrainProceed | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Force a train through a red signal.

Parameters:

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

Definition at line 1987 of file train_cmd.cpp.

References CMD_ERROR, DC_EXEC, and IsValidVehicleID().

CommandCost CmdGiveMoney | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Transfer funds (money) from one player to another.

To prevent abuse in multiplayer games you can only send money to other players 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 player to transfer the money to

Definition at line 360 of file misc_cmd.cpp.

References _networking, CMD_ERROR, DC_EXEC, CommandCost::GetCost(), and min().

CommandCost CmdIncreaseLoan | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Increase the loan of your company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | when 0: loans LOAN_INTERVAL when 1: loans the maximum loan permitting money (press CTRL),

Definition at line 135 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, and return_cmd_error.

CommandCost CmdInsertOrder | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 only the first 8 bits used currently (bit 16 - 23) (max 255)
  | p2 | packed order to insert

Definition at line 165 of file order_cmd.cpp.

References AssignOrder(), CanAircraftUseStation(), CC_PASSENGERS, CMD_ERROR, DC_EXEC, DeleteOrderWarnings(), DistanceManhattan(), GB(), GetFirstVehicleFromSharedList(), GetLastVehicleOrder(), GetTileOwner(), InvalidateVehicleOrder(), IsTileDepotType(), IsValidVehicleID(), OFB_FULL_LOAD, OFB_HALT_IN_DEPOT, OFB_NON_STOP, OFB_PART_OF_ORDERS, OFB_TRANSFER, OFB_UNLOAD, OWNER_NONE, return_cmd_error, SwapOrders(), and VPF_NPF.

CommandCost CmdLandscapeClear | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Clear a piece of landscape.

Parameters:

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

Definition at line 546 of file landscape.cpp.

References CmdLandscapeClear(), and GetTileType().

Referenced by CmdLandscapeClear().

CommandCost CmdLevelLand | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Returns:
  error or cost of terraforming

Definition at line 351 of file terraform_cmd.cpp.

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

CommandCost CmdMassStartStopVehicle | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Definition at line 1640 of file vehicle.cpp.

References BuildDepotVehicleList(), CMD_ERROR, CMD_START_STOP_AIRCRAFT, CMD_START_STOP_ROADVEH, CMD_START_STOP_SHIP, CMD_START_STOP_TRAIN, CmdSucceeded(), DC_EXEC, DoCommand(), GB(), GenerateVehicleSortList(), and HasBit().

CommandCost CmdModifyOrder | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 | mode to change the order to (always set)

Definition at line 666 of file order_cmd.cpp.

References ClrBit(), CMD_ERROR, DC_EXEC, DeleteOrderWarnings(), GB(), GetFirstVehicleFromSharedList(), HasBit(), InvalidateVehicleOrder(), IsValidVehicleID(), and ToggleBit().

CommandCost CmdMoneyCheat | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 343 of file misc_cmd.cpp.

References _networking, and CMD_ERROR.

CommandCost CmdMoveOrder | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Move an order inside the orderlist.

Parameters:

  | tile | unused
  | 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

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 580 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, DeleteOrderWarnings(), GB(), GetFirstVehicleFromSharedList(), InvalidateVehicleOrder(), IsValidVehicleID(), and SwapOrders().

CommandCost CmdMoveRailVehicle | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Move a rail vehicle around inside the depot.

Parameters:

  | tile | unused
  | flags | type of operation
  | 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

Definition at line 1023 of file train_cmd.cpp.

References CALLBACK_FAILED, CBID_TRAIN_ALLOW_WAGON_ATTACH, ClearFreeWagon(), ClearFrontEngine(), CMD_ERROR, CmdMoveRailVehicle(), DC_AUTOREPLACE, DC_EXEC, DEFAULT_GROUP, DeleteVehicleOrders(), error, GB(), GetEngineGRFID(), GetGRFStringID(), GetLastEnginePart(), GetNextUnit(), GetNextVehicle(), GetVehicleCallbackParent(), HasBit(), HASBITS, IsArticulatedPart(), IsFreeWagon(), IsFrontEngine(), IsRearDualheaded(), IsTrainEngine(), IsValidVehicleID(), RemoveVehicleFromGroup(), return_cmd_error, SetFreeWagon(), SetFrontEngine(), SetTrainGroupID(), TrainConsistChanged(), UnlinkWagon(), and UpdateTrainGroupID().

Referenced by CmdMoveRailVehicle().

CommandCost CmdNameVehicle | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Give a custom name to your vehicle.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle ID to name
  | p2 | unused

Definition at line 2394 of file vehicle.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, IsValidVehicleID(), MarkWholeScreenDirty(), and return_cmd_error.

CommandCost CmdOrderRefit | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 880 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, GB(), GetFirstVehicleFromSharedList(), HasBit(), InvalidateVehicleOrder(), and IsValidVehicleID().

CommandCost CmdPause | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Pause/Unpause the game (server-only).

Increase or decrease the pause counter. If the counter is zero, the game is unpaused. A counter is used instead of a boolean value to have more control over the game when saving/loading, etc.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | 0 = decrease pause counter; 1 = increase pause counter
  | p2 | unused

Definition at line 307 of file misc_cmd.cpp.

References AskUnsafeUnpauseCallback(), DC_EXEC, and ShowQuery().

CommandCost CmdPlaceSign | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 100 of file signs.cpp.

References DC_EXEC, MarkSignDirty(), return_cmd_error, TILE_SIZE, TileX(), TileY(), and UpdateSignVirtCoords().

CommandCost CmdPlantTree | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 324 of file tree_cmd.cpp.

References CommandCost::AddCost(), AddTreeCount(), CLEAR_FIELDS, CLEAR_ROCKS, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), GB(), GetClearGround(), CommandCost::GetCost(), GetRandomTreeType(), GetTileType(), GetTreeCount(), IsBridgeAbove(), IsInsideMM(), IsSlopeWithOneCornerRaised(), IsTileType(), 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 CmdPlayerCtrl | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Control the players: add, delete, etc.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | various functionality p1 = 0 - create a new player, Which player (network) it will be is in p2 p1 = 1 - create a new AI player p1 = 2 - delete a player. Player is identified by p2 p1 = 3 - merge two companies together. Player to merge #1 with player #2. Identified by p2
  | p2 | various functionality, dictated by p1 p1 = 0 - ClientID of the newly created player p1 = 2 - PlayerID of the that is getting deleted p1 = 3 - #1 p2 = (bit 0-15) - player to merge (p2 & 0xFFFF) #2 p2 = (bit 16-31) - player to be merged into ((p2>>16)&0xFFFF)

Todo:
  In the case of p1=0, create new player, the clientID of the new player 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 788 of file players.cpp.

References _cmd_text, _networking, _patches_newgame, AddNewsItem(), CMD_CHANGE_PRESIDENT_NAME, CMD_ERROR, CMD_SET_AUTOREPLACE, DC_EXEC, DeletePlayerWindows(), DNC_BANKRUPCY, DoStartupNewPlayer(), GB(), MarkWholeScreenDirty(), NB_BBANKRUPT, NEWS_FLAGS, NM_CALLBACK, NT_COMPANY_INFO, OWNER_NONE, PLAYER_SPECTATOR, and SetLocalPlayer().

CommandCost CmdPurchaseLandArea | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Purchase a land area.

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

Parameters:

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

Returns:
  error of cost of operation

Definition at line 122 of file unmovable_cmd.cpp.

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

CommandCost CmdRefitAircraft | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Returns:
  cost of refit or error

Definition at line 639 of file aircraft_cmd.cpp.

References AircraftDefaultCargoCapacity(), CALLBACK_FAILED, CanRefitTo(), CBID_VEHICLE_REFIT_CAPACITY, CBM_VEHICLE_REFIT_CAPACITY, CC_PASSENGERS, CMD_ERROR, DC_EXEC, GB(), GetRefitCost(), GetVehicleCallback(), HasBit(), IsValidVehicleID(), and return_cmd_error.

CommandCost CmdRefitRailVehicle | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Refits a train to the specified cargo type.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | vehicle ID of the train to refit param 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

Returns:
  cost of refit or error

Definition at line 2010 of file train_cmd.cpp.

References CommandCost::AddCost(), CALLBACK_FAILED, CanRefitTo(), CBID_VEHICLE_REFIT_CAPACITY, CBM_VEHICLE_REFIT_CAPACITY, CMD_ERROR, DC_EXEC, GB(), GetRefitCost(), GetVehicleCallback(), HasBit(), IsValidVehicleID(), return_cmd_error, and TrainConsistChanged().

CommandCost CmdRefitRoadVeh | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Returns:
  cost of refit or error

Definition at line 2138 of file roadveh_cmd.cpp.

References CommandCost::AddCost(), CALLBACK_FAILED, CanRefitTo(), CBID_VEHICLE_REFIT_CAPACITY, CBM_VEHICLE_REFIT_CAPACITY, CMD_ERROR, DC_EXEC, GB(), GetRefitCost(), GetVehicleCallback(), HasBit(), IsValidVehicleID(), and return_cmd_error.

CommandCost CmdRefitShip | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Returns:
  cost of refit or error

Definition at line 1053 of file ship_cmd.cpp.

References CALLBACK_FAILED, CanRefitTo(), CBID_VEHICLE_REFIT_CAPACITY, CBM_VEHICLE_REFIT_CAPACITY, CMD_ERROR, DC_EXEC, GB(), GetRefitCost(), GetVehicleCallback(), HasBit(), IsValidVehicleID(), and return_cmd_error.

CommandCost CmdRemoveAllVehiclesGroup | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Remove all vehicles from a group.

Parameters:

  | tile | unused
  | p1 | index of group array p1 bit 0-15 : GroupID
  | p2 | type of vehicles

Definition at line 291 of file group_cmd.cpp.

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

CommandCost CmdRemoveFromRailroadStation | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Remove a single tile from a railroad station.

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

Parameters:

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

Definition at line 1147 of file station_cmd.cpp.

References AddTrackToSignalBuffer(), BEGIN_TILE_LOOP, CMD_ERROR, DC_EXEC, DeallocateSpecFromStation(), DeleteStationIfEmpty(), END_TILE_LOOP, GetTileOwner(), IsTileType(), MapSize(), OWNER_WATER, return_cmd_error, SVW_TRAINS, Swap(), TileX(), TileXY(), TileY(), UpdateStationVirtCoordDirty(), and YapfNotifyTrackLayoutChange().

CommandCost CmdRemoveLongRoad | ( | TileIndex | end_tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 735 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,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

See also:
  CmdRailTrackHelper

Definition at line 718 of file rail_cmd.cpp.

References CmdRailTrackHelper(), and SetBit().

CommandCost CmdRemoveRoad | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 271 of file road_cmd.cpp.

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

CommandCost CmdRemoveRoadStop | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 1525 of file station_cmd.cpp.

References CMD_ERROR, CmdSucceeded(), DIAGDIR_NE, DiagDirToRoadBits(), GetRoadStopDir(), IsTileType(), OWNER_TOWN, RemoveRoadStop(), ROAD_X, and ROAD_Y.

CommandCost CmdRemoveSignalTrack | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 24-31) - user defined signals_density

See also:
  CmdSignalTrackHelper

Definition at line 1153 of file rail_cmd.cpp.

References CmdSignalTrackHelper(), and SetBit().

CommandCost CmdRemoveSingleRail | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Remove a single piece of track.

Parameters:

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

Definition at line 439 of file rail_cmd.cpp.

References CommandCost::AddCost(), AddTrackToSignalBuffer(), CMD_ERROR, CMD_REMOVE_SIGNALS, DC_BANKRUPT, DC_EXEC, DoCommand(), EnsureNoTrainOnTrack(), GetTileOwner(), GetTileType(), GetTownIndex(), GetTrackBits(), HasSignalOnTrack(), INVALID_OWNER, IsPlainRailTile(), IsSlopeWithOneCornerRaised(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, OWNER_WATER, RAIL_GROUND_WATER, ROADTYPE_HWAY, ROADTYPE_ROAD, ROADTYPE_TRAM, SetTrackBits(), TRACK_BIT_X, TRACK_BIT_Y, TRACK_X, TRACK_Y, TrackToTrackBits(), and YapfNotifyTrackLayoutChange().

CommandCost CmdRemoveSingleSignal | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 1104 of file rail_cmd.cpp.

References AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, EnsureNoTrainOnTrack(), GB(), GetPresentSignals(), GetTileOwner(), HasSignalOnTrack(), HasTrack(), INVALID_TRACK, IsTileType(), MarkTileDirtyByTile(), MP_RAILWAY, OWNER_WATER, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SignalOnTrack(), and YapfNotifyTrackLayoutChange().

CommandCost CmdRemoveTrainWaypoint | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Delete a waypoint.

Parameters:

  | tile | tile where waypoint is to be deleted
  | flags | type of operation
  | p1 | unused
  | p2 | unused

Returns:
  cost of operation or error

Definition at line 338 of file waypoint.cpp.

References RemoveTrainWaypoint().

CommandCost CmdRenameEngine | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Rename an engine.

Parameters:

  | tile | unused
  | flags | operation to perfom
  | p1 | engine ID to rename
  | p2 | unused

Definition at line 395 of file engine.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, MarkWholeScreenDirty(), and return_cmd_error.

CommandCost CmdRenameGroup | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Rename a group.

Parameters:

  | tile | unused
  | p1 | index of array group p1 bit 0-15 : GroupID
  | p2 | unused

Definition at line 177 of file group_cmd.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, and return_cmd_error.

CommandCost CmdRenameSign | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Returns:
  0 if succesfull, otherwise CMD_ERROR

Definition at line 134 of file signs.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, MarkSignDirty(), and UpdateSignVirtCoords().

CommandCost CmdRenameStation | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Rename a station.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | station ID that is to be renamed
  | p2 | unused

Definition at line 2639 of file station_cmd.cpp.

References _cmd_text, CMD_ERROR, MarkWholeScreenDirty(), ResortStationLists(), return_cmd_error, and UpdateStationVirtCoord().

CommandCost CmdRenameTown | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Rename a town (server-only).

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | town ID to rename
  | p2 | unused

Definition at line 2061 of file town_cmd.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, IsValidTownID(), MarkWholeScreenDirty(), return_cmd_error, UpdateAllStationVirtCoord(), UpdateAllWaypointSigns(), and UpdateTownVirtCoord().

CommandCost CmdRenameWaypoint | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Rename a waypoint.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | id of waypoint
  | p2 | unused

Returns:
  cost of operation or error

Definition at line 365 of file waypoint.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, IsTileType(), MakeDefaultWaypointName(), MarkWholeScreenDirty(), MP_RAILWAY, return_cmd_error, and UpdateWaypointSign().

CommandCost CmdRestoreOrderIndex | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

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 1030 of file order_cmd.cpp.

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

CommandCost CmdReverseTrainDirection | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Definition at line 1937 of file train_cmd.cpp.

References CBM_VEHICLE_ARTIC_ENGINE, CMD_ERROR, DC_EXEC, HasBit(), IsMultiheaded(), IsValidVehicleID(), return_cmd_error, ReverseTrainDirection(), and ToggleBit().

CommandCost CmdSellAircraft | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Sell an aircraft.

Parameters:

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

Returns:
  result of operation. Error or sold value

Definition at line 488 of file aircraft_cmd.cpp.

References CMD_ERROR, DC_EXEC, HASBITS, IsValidVehicleID(), and return_cmd_error.

CommandCost CmdSellLandArea | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Sell a land area.

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

Parameters:

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

Returns:
  error or cost of operation

Definition at line 149 of file unmovable_cmd.cpp.

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

CommandCost CmdSellRailWagon | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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 p2 = 2: when selling attached locos, rearrange all vehicles after it to separate lines; all wagons of the same type will go on the same line. Used by the AI currently

Definition at line 1409 of file train_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, CMD_MOVE_RAIL_VEHICLE, DC_EXEC, DEFAULT_GROUP, DeleteDepotHighlightOfVehicle(), DoCommand(), GetNextVehicle(), HasBit(), HASBITS, IsArticulatedPart(), IsFrontEngine(), IsMultiheaded(), IsRearDualheaded(), IsTrainEngine(), IsValidVehicleID(), return_cmd_error, SetFrontEngine(), ShowVehicleViewWindow(), TrainConsistChanged(), TS_FRONT, UnlinkWagon(), and UpdateTrainGroupID().

CommandCost CmdSellRoadVeh | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Sell a road vehicle.

Parameters:

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

Definition at line 356 of file roadveh_cmd.cpp.

References CMD_ERROR, DC_EXEC, DeleteDepotHighlightOfVehicle(), HASBITS, IsValidVehicleID(), and return_cmd_error.

CommandCost CmdSellShareInCompany | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Sell shares in an opposing company.

Parameters:

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

Definition at line 1937 of file economy.cpp.

References CMD_ERROR, DC_EXEC, and PLAYER_SPECTATOR.

CommandCost CmdSellShip | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Sell a ship.

Parameters:

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

Definition at line 900 of file ship_cmd.cpp.

References CMD_ERROR, DC_EXEC, DeleteDepotHighlightOfVehicle(), HASBITS, IsValidVehicleID(), and return_cmd_error.

CommandCost CmdSendAircraftToHangar | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Returns:
  o if everything went well

Definition at line 561 of file aircraft_cmd.cpp.

References AircraftNextAirportPos_and_Order(), ClrBit(), CMD_ERROR, DC_EXEC, FindNearestHangar(), GetTargetAirportIfValid(), HasBit(), IsValidVehicleID(), OFB_NON_STOP, OFB_UNLOAD, SendAllVehiclesToDepot(), SetBit(), and ToggleBit().

CommandCost CmdSendRoadVehToDepot | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Definition at line 455 of file roadveh_cmd.cpp.

References ClrBit(), CMD_ERROR, DC_EXEC, HasBit(), IsValidVehicleID(), OFB_NON_STOP, return_cmd_error, SendAllVehiclesToDepot(), SetBit(), and ToggleBit().

CommandCost CmdSendShipToDepot | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Definition at line 975 of file ship_cmd.cpp.

References ClrBit(), CMD_ERROR, DC_EXEC, HasBit(), IsValidVehicleID(), OFB_NON_STOP, return_cmd_error, SendAllVehiclesToDepot(), SetBit(), and ToggleBit().

CommandCost CmdSendTrainToDepot | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Definition at line 2194 of file train_cmd.cpp.

References ClrBit(), CMD_ERROR, CMD_REVERSE_TRAIN_DIRECTION, DC_EXEC, DoCommand(), FindClosestTrainDepot(), GetDepotByTile(), HasBit(), IsTileDepotType(), IsValidVehicleID(), OFB_NON_STOP, return_cmd_error, SendAllVehiclesToDepot(), SetBit(), and ToggleBit().

CommandCost CmdSetAutoReplace | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Change engine renewal parameters.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | bits 0-3 command p1 = 0 - change auto renew bool p1 = 1 - change auto renew months p1 = 2 - change auto renew money p1 = 3 - change auto renew array p1 = 4 - change bool, months & money all together p1 = 5 - change renew_keep_length
  | p2 | value to set if p1 = 0, then: p2 = enable engine renewal if p1 = 1, then: p2 = months left before engine expires to replace it if p1 = 2, then p2 = minimum amount of money available if p1 = 3, then: p1 bits 8-15 = engine group p2 bits 0-15 = old engine type p2 bits 16-31 = new engine type if p1 = 4, then: p1 bit 15 = enable engine renewal p1 bits 16-31 = months left before engine expires to replace it p2 bits 0-31 = minimum amount of money available if p1 = 5, then p2 = enable renew_keep_length

Definition at line 655 of file players.cpp.

References AddEngineReplacementForPlayer(), AIR_CTOL, Clamp(), ClampU(), CMD_ERROR, DC_EXEC, GB(), HasBit(), InvalidateAutoreplaceWindow(), IsAllGroupID(), and RemoveEngineReplacementForPlayer().

CommandCost CmdSetGroupReplaceProtection | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

(Un)set global replace protection from a group

Parameters:

  | tile | unused
  | p1 | index of group array p1 bit 0-15 : GroupID
  | p2 | p2 bit 0 : 1 to set or 0 to clear protection.

Definition at line 328 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, and HasBit().

CommandCost CmdSetPlayerColor | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Change the player'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.

Definition at line 55 of file misc_cmd.cpp.

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

CommandCost CmdSetPlayerFace | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Change the player's face.

Parameters:

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

Definition at line 34 of file misc_cmd.cpp.

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

CommandCost CmdSetRoadDriveSide | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Change the side of the road vehicles drive on (server only).

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the side of the road; 0 = left side and 1 = right side
  | p2 | unused

Definition at line 334 of file settings_gui.cpp.

References CMD_ERROR, and DC_EXEC.

CommandCost CmdSetVehicleOnTime | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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.

Definition at line 90 of file timetable_cmd.cpp.

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

CommandCost CmdSkipToOrder | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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

Definition at line 535 of file order_cmd.cpp.

References CMD_ERROR, DC_EXEC, HasBit(), InvalidateVehicleOrder(), and IsValidVehicleID().

CommandCost CmdStartStopAircraft | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Start/Stop an aircraft.

Parameters:

  | tile | unused
  | flags | for command type
  | p1 | aircraft ID to start/stop
  | p2 | unused

Returns:
  result of operation. Nothing if everything went well

Definition at line 517 of file aircraft_cmd.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_START_STOP_CHECK, CMD_ERROR, DC_EXEC, DeleteVehicleNews(), error, GB(), GetEngineGRFID(), GetGRFStringID(), GetVehicleCallback(), IsValidVehicleID(), and return_cmd_error.

CommandCost CmdStartStopRoadVeh | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Start/Stop a road vehicle.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | road vehicle ID to start/stop
  | p2 | unused

Definition at line 293 of file roadveh_cmd.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_START_STOP_CHECK, CMD_ERROR, DC_EXEC, DeleteVehicleNews(), error, GB(), GetEngineGRFID(), GetGRFStringID(), GetVehicleCallback(), IsValidVehicleID(), and return_cmd_error.

CommandCost CmdStartStopShip | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Start/Stop a ship.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | ship ID to start/stop
  | p2 | unused

Definition at line 936 of file ship_cmd.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_START_STOP_CHECK, CMD_ERROR, DC_EXEC, DeleteVehicleNews(), error, GB(), GetEngineGRFID(), GetGRFStringID(), GetVehicleCallback(), IsValidVehicleID(), and return_cmd_error.

CommandCost CmdStartStopTrain | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Start/Stop a train.

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | train to start/stop
  | p2 | unused

Definition at line 1368 of file train_cmd.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_START_STOP_CHECK, CMD_ERROR, DC_EXEC, DeleteVehicleNews(), error, GB(), GetEngineGRFID(), GetGRFStringID(), GetVehicleCallback(), IsValidVehicleID(), return_cmd_error, and TRACK_BIT_DEPOT.

CommandCost CmdTerraformLand | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

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)

Returns:
  error or cost of terraforming

Definition at line 229 of file terraform_cmd.cpp.

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

CommandCost CmdTurnRoadVeh | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Turn a roadvehicle around.

Parameters:

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

Definition at line 529 of file roadveh_cmd.cpp.

References CMD_ERROR, DC_EXEC, DirToDiagDir(), DRD_NONE, GetDisallowedRoadDirections(), GetTunnelBridgeDirection(), IsTileType(), IsValidVehicleID(), MP_TUNNELBRIDGE, and RVSB_WORMHOLE.

CommandCost CmdWantEnginePreview | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Accept an engine prototype.

XXX - it is possible that the top-player 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

Definition at line 276 of file engine.cpp.

References CMD_ERROR, and DC_EXEC.

CommandCost DoCommand | ( | TileIndex | tile,
|  | uint32 | p1,
|  | uint32 | p2,
|  | uint32 | flags,
|  | uint32 | procc |
| ) |  |  |

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
  | procc | The command-id to execute (a value of the CMD_* enums)

See also:
  CommandProc

Definition at line 396 of file command.cpp.

References _cmd_text, CMD_ERROR, CmdFailed(), DC_BANKRUPT, DC_EXEC, DC_QUERY_COST, error, CommandCost::GetCost(), IsValidTile(), Command::proc, and CommandCost::SetGlobalErrorMessage().

Referenced by BuildRailToolbWndProc(), CanBuildHouseHere(), CanBuildTramTrackOnTile(), CheckFlatLandBelow(), CheckIfCanLevelIndustryPlatform(), CheckSendAircraftToHangarForReplacement(), ClearMakeHouseTile(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdChangePresidentName(), CmdClearArea(), CmdCloneVehicle(), CmdDepotSellAllVehicles(), CmdLevelLand(), CmdMassStartStopVehicle(), CmdPlantTree(), CmdPurchaseLandArea(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdRemoveSingleRail(), CmdSellRailWagon(), CmdSendTrainToDepot(), CmdSignalTrackHelper(), DoBuildShiplift(), DoDryUp(), DoFloodTile(), FloodHalftile(), GrowTown(), GrowTownWithBridge(), GrowTownWithRoad(), IsRoadAllowedHere(), NormalizeTrainVehInDepot(), RemoveRoad(), SearchLumberMillTrees(), and SendAllVehiclesToDepot().

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

Execute a network safe DoCommand function.

Toplevel network safe docommand function for the current player. 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 player 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)
  | callback | A callback function to call after the command is finished
  | cmd | The command to execute (a CMD_* value)
  | my_cmd | indicator if the command is from a player or server (to display error messages for a user)

Returns:
  true if the command succeeded, else false

Spectator has no rights except for the (dedicated) server which is/can be a spectator but as the server it can do anything

Definition at line 490 of file command.cpp.

References _cmd_text, _networking, _shift_pressed, ClearStorageChanges(), CMD_AUTO, CMD_CLEAR_AREA, CMD_CLONE_VEHICLE, CMD_LEVEL_LAND, CMD_NETWORK_COMMAND, CMD_NO_TEST_IF_IN_NETWORK, CMD_NO_WATER, CMD_PAUSE, CMD_REMOVE_LONG_ROAD, CMD_SHOW_NO_ERROR, CmdFailed(), DC_AUTO, DC_EXEC, DC_NO_WATER, GB(), GetCommandFlags(), CommandCost::GetCost(), IsGeneratingWorld(), IsValidTile(), PLAYER_FIRST, PLAYER_SPECTATOR, Command::proc, CommandCost::SetGlobalErrorMessage(), TILE_SIZE, TileX(), TileY(), and UpdateSignalsInBuffer().

Referenced by _GenerateWorld(), AskUnsafeUnpauseCallback(), BuildRailToolbWndProc(), CommonRaiseLowerBigLand(), EndGameWndProc(), GenerateDesertArea(), GenericPlaceSignals(), GroupWndProc(), GUIPlaceProcDragXY(), HandleAutoSignalPlacement(), HandleCloneVehClick(), OrderClick_Delete(), OrderClick_FullLoad(), OrderClick_Nonstop(), OrderClick_Refit(), OrderClick_Skip(), OrderClick_Transfer(), OrderClick_Unload(), PlaceProc_Sign(), PlayerCompanyWndProc(), RestoreVehicleOrders(), SelectPlayerFaceWndProc(), SetPatchValue(), ShowEndGameChart(), ShowHighscoreTable(), StartScenario(), StationViewWndProc(), TownAuthorityWndProc(), VehicleDetailsWndProc(), and VehicleViewWndProc().

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 player or INT64_MAX if there is no such a player "at the moment" like the server itself.

Returns:
  The available money of a player or INT64_MAX

Definition at line 469 of file command.cpp.

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

byte GetCommandFlags | ( | uint | cmd | ) |

Returns the flags from a given command.

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

Parameters:

  | cmd | The integer value of the command

Returns:
  The flags for this command

Bug:
  integervalues which are less equals 0xFF and greater than the size of _command_proc_table can result in an index out of bounce error (which doesn't happend anyway). Check function IsValidCommand(). (Progman)

Definition at line 378 of file command.cpp.

References Command::flags.

Referenced by DoCommandP().

bool IsValidCommand | ( | uint | 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 359 of file command.cpp.

References Command::proc.

## Variable Documentation

const char* _cmd_text = NULL

Text, which gets sent with a command.

This variable contains a string (be specific a pointer of the first char of this string) which will be send with a command. This is used for user input data like names or chat messages.

Definition at line 27 of file command.cpp.

Referenced by CmdChangeCompanyName(), CmdChangePresidentName(), CmdNameVehicle(), CmdPlayerCtrl(), CmdRenameEngine(), CmdRenameGroup(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameWaypoint(), DoCommand(), DoCommandP(), GroupWndProc(), PlayerCompanyWndProc(), RestoreVehicleOrders(), StationViewWndProc(), and VehicleDetailsWndProc().

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.