command.cpp File Reference

Handling of commands. More...

#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 "genworld.h"
#include "newgrf_storage.h"
#include "strings_func.h"
#include "gfx_func.h"
#include "functions.h"
#include "town.h"
#include "date_func.h"
#include "debug.h"
#include "company_func.h"
#include "company_base.h"
#include "signal_func.h"
#include "table/strings.h"

Go to the source code of this file.

Defines

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

Functions

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

Variables

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


Detailed Description

Handling of commands.

Definition in file command.cpp.


Define Documentation

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

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

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

Parameters:
yyyy The desired function name of the new command handler function.

Definition at line 37 of file command.cpp.


Function Documentation

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

Add all shared vehicles of all vehicles from a group.

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

Definition at line 247 of file group_cmd.cpp.

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

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

Add a vehicle to a group.

Parameters:
tile unused
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 200 of file group_cmd.cpp.

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

Referenced by CmdAddSharedVehicleGroup(), and CmdRemoveAllVehiclesGroup().

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

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

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

Parameters:
tile Not used.
flags Operation to perform.
p1 Vehicle index.
p2 Various bitstuffed elements
  • p2 = (bit 0) - Set to 1 to enable, 0 to disable autofill.
  • p2 = (bit 1) - Set to 1 to preserve waiting times in non-destructive mode

Definition at line 141 of file timetable_cmd.cpp.

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

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

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

Parameters:
tile not used
flags type of operation
p1 Index of vehicle
p2 not used

Definition at line 606 of file autoreplace_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), CommandCost::GetCost(), GetNewEngineType(), GetNextUnit(), HASBITS, IsArticulatedPart(), IsFrontEngine(), IsRearDualheaded(), IsValidVehicleID(), ReplaceChain(), ReplaceFreeUnit(), RestoreRandomSeeds(), SaveRandomSeeds(), StartStopVehicle(), and CommandCost::Succeeded().

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

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

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

Build a Bridge.

Parameters:
end_tile end tile
flags type of operation
p1 packed start tile coords (~ dx)
p2 various bitstuffed elements
  • p2 = (bit 0- 7) - bridge type (hi bh)
  • p2 = (bit 8-14) - rail type or road types.
  • p2 = (bit 15-16) - transport type.

Definition at line 178 of file tunnelbridge_cmd.cpp.

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

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

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

Build a piece of canal.

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

Definition at line 283 of file water_cmd.cpp.

References CommandCost::AddCost(), BEGIN_TILE_LOOP, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DoCommand(), END_TILE_LOOP, CommandCost::GetCost(), GetTileSlope(), 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,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Build or relocate the HQ.

This depends if the HQ is already built or not

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

Definition at line 100 of file unmovable_cmd.cpp.

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

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

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

Build/Fund an industry.

Parameters:
tile tile where industry is built
flags of operations to conduct
p1 various bitstuffed elements
p2 seed to use for variable 8F
Returns:
index of the newly create industry, or CMD_ERROR if it failed

Definition at line 1644 of file industry_cmd.cpp.

References _settings_game, AddNewsItem(), CMD_ERROR, GameSettings::construction, CreateNewIndustryHelper(), IndustrySpec::enabled, GB(), IndustrySpec::GetConstructionCost(), GetIndustrySpec(), PoolItem< T, Tid, Tpool >::index, IndustrySpec::IsRawIndustry(), IndustrySpec::name, IndustrySpec::new_industry_text, NS_INDUSTRY_OPEN, NUM_INDUSTRYTYPES, IndustrySpec::num_table, OWNER_TOWN, IndustrySpec::prospecting_chance, RandomTile, ConstructionSettings::raw_industry_construction, IndustrySpec::table, Industry::town, and Industry::xy.

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

Builds a lock (ship-lift).

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

Definition at line 266 of file water_cmd.cpp.

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

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

Build a long piece of road.

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

Definition at line 698 of file road_cmd.cpp.

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

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

Build railroad station.

Parameters:
tile_org starting position of station dragging/placement
flags operation to perform
p1 various bitstuffed elements
  • p1 = (bit 0- 3) - railtype (p1 & 0xF)
  • p1 = (bit 4) - orientation (Axis)
  • p1 = (bit 8-15) - number of tracks
  • p1 = (bit 16-23) - platform length
  • p1 = (bit 24) - allow stations directly adjacent to other stations.
p2 various bitstuffed elements
  • p2 = (bit 0- 7) - custom station class
  • p2 = (bit 8-15) - custom station id
  • p2 = (bit 16-31) - station ID to join (INVALID_STATION if build new one)

Definition at line 858 of file station_cmd.cpp.

References _settings_game, Station::AddFacility(), AddTrackToSignalBuffer(), StationSettings::adjacent_stations, AllocaM, AllocateSpecToStation(), SmallVector< T, S >::Append(), AXIS_X, AxisToTrack(), StationRect::BeforeAddRect(), Station::cached_anim_triggers, CALLBACK_FAILED, PoolItem< T, Tid, Tpool >::CanAllocateItem(), CBID_STATION_AVAILABILITY, CBID_STATION_TILE_LAYOUT, CBM_STATION_AVAIL, CheckFlatLandBelow(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CmdFailed(), DC_EXEC, DeallocateSpecFromStation(), DeleteAnimatedTile(), StationSettings::distant_join_stations, FreeTrainTrackReservation(), GB(), GetClosestDeletedStation(), CommandCost::GetCost(), GetCustomStationSpec(), GetNumStationClasses(), GetRailwayStationReservation(), GetTrainForReservation(), GetVehicleTrackdir(), HasBit(), PoolItem< T, Tid, Tpool >::index, INVALID_TILE, InvalidateWindowData(), InvalidateWindowWidget(), IsTileType(), StationSettings::join_stations, SmallVector< T, S >::Length(), Station::MarkTilesDirty(), StationSettings::nonuniform_stations, Station::owner, Station::rect, return_cmd_error, ReverseTrackdir(), SetBit(), SetRailwayStationPlatformReservation(), GameSettings::station, StationSettings::station_spread, Station::string_id, SVW_TRAINS, TileDiffXY(), Station::town, TrackdirToExitdir(), Station::train_tile, Station::trainst_h, Station::trainst_w, TryPathReserve(), UpdateStationAcceptance(), UpdateStationVirtCoordDirty(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

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

Build rail on a stretch of track.

Stub for the unified rail builder/remover

Parameters:
tile start tile of drag
flags operation to perform
p1 end tile of drag
p2 various bitstuffed elements
  • p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
  • p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
  • p2 = (bit 7) - 0 = build, 1 = remove tracks
See also:
CmdRailTrackHelper

Definition at line 719 of file rail_cmd.cpp.

References ClrBit(), and CmdRailTrackHelper().

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

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

Build a piece of road.

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

Definition at line 449 of file road_cmd.cpp.

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

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

Build a road depot.

Parameters:
tile tile where to build the depot
flags operation to perform
p1 bit 0..1 entrance direction (DiagDirection) bit 2..3 road type
p2 unused
Todo:
When checking for the tile slope, distingush between "Flat land required" and "land sloped in wrong direction"

Definition at line 849 of file road_cmd.cpp.

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

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

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

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

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

Build a ship depot.

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

Definition at line 102 of file water_cmd.cpp.

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

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

Build signals on a stretch of track.

Stub for the unified signal builder/remover

Parameters:
tile start tile of drag
flags operation to perform
p1 end tile of drag
p2 various bitstuffed elements
  • p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
  • p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
  • p2 = (bit 4) - 0 = signals, 1 = semaphores
  • p2 = (bit 5) - 0 = build, 1 = remove signals
  • p2 = (bit 6) - 0 = selected stretch, 1 = auto fill
  • p2 = (bit 7- 9) - default signal type
  • p2 = (bit 24-31) - user defined signals_density
See also:
CmdSignalTrackHelper

Definition at line 1156 of file rail_cmd.cpp.

References CmdSignalTrackHelper().

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

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

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

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

Parameters:
tile tile where to build the signals
flags operation to perform
p1 various bitstuffed elements
  • p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
  • p1 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal or (for bit 7) toggle variant (CTRL-toggle)
  • p1 = (bit 4) - 0 = signals, 1 = semaphores
  • p1 = (bit 5-7) - type of the signal, for valid values see enum SignalType in rail_map.h
  • p1 = (bit 8) - convert the present signal type and variant
  • p1 = (bit 9-11)- start cycle from this signal type
  • p1 = (bit 12-14)-wrap around after this signal type
  • p1 = (bit 15-16)-cycle the signal direction this many times
  • p1 = (bit 17) - 1 = don't modify an existing signal but don't fail either, 0 = always set new signal type
p2 used for CmdBuildManySignals() to copy direction of first signal TODO: p2 should be replaced by two bits for "along" and "against" the track.

Definition at line 814 of file rail_cmd.cpp.

References AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, EnsureNoTrainOnTrack(), FreeTrainTrackReservation(), GB(), GetPresentSignals(), GetSignalStates(), GetTrackBits(), GetTrackReservation(), GetTrainForReservation(), HasBit(), HasReservedTracks(), HasSignalOnTrack(), HasSignals(), HasTrack(), IsPlainRailTile(), KillFirstBit(), MarkTileDirtyByTile(), return_cmd_error, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SIG_SEMAPHORE, SignalOnTrack(), TRACK_BIT_HORZ, TRACK_BIT_NONE, TRACK_BIT_VERT, TrackToTrackBits(), TryPathReserve(), and YapfNotifyTrackLayoutChange().

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

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 0..1 size of the town (
See also:
TownSize) 2 true iff it should be a city 3..5 town road layout (

TownLayout)

Parameters:
p2 town name parts

Definition at line 1541 of file town_cmd.cpp.

References _settings_game, CMD_ERROR, DC_EXEC, DistanceFromEdge(), DoCreateTown(), GameSettings::game_creation, GB(), GetTileSlope(), HasBit(), IsCloseToTown(), IsTileType(), MP_CLEAR, MP_TREES, return_cmd_error, SLOPE_FLAT, TL_RANDOM, GameCreationSettings::town_name, TS_RANDOM, UpdateNearestTownForRoadTiles(), and VerifyTownName().

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

Build a train depot.

Parameters:
tile position of the train depot
flags operation to perform
p1 rail type
p2 bit 0..1 entrance direction (DiagDirection)
Todo:
When checking for the tile slope, distingush between "Flat land required" and "land sloped in wrong direction"

Definition at line 749 of file rail_cmd.cpp.

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

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

Convert existing rail to waypoint.

Eg build a waypoint station over piece of rail

Parameters:
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 142 of file waypoint_cmd.cpp.

References _date, _settings_game, AXIS_X, AXIS_Y, AxisToTrack(), ConstructionSettings::build_on_slopes, CMD_ERROR, CmdBuildTrainWaypoint(), GameSettings::construction, DC_EXEC, GetCustomStationSpec(), GetNumCustomStations(), GetRailTileType(), GetRailType(), GetTileOwner(), GetTileSlope(), GetTrackBits(), GetTrackReservation(), HasBit(), InvalidateWindowData(), IsBridgeAbove(), IsSteepSlope(), IsTileType(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), MP_RAILWAY, RAIL_TILE_NORMAL, RedrawWaypointSign(), return_cmd_error, SetDepotWaypointReservation(), SLOPE_FLAT, STAT_CLASS_WAYP, TRACK_BIT_X, TRACK_BIT_Y, UpdateWaypointSign(), and YapfNotifyTrackLayoutChange().

Referenced by CmdBuildTrainWaypoint().

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

Build Tunnel.

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

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 465 of file tunnelbridge_cmd.cpp.

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

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

Buy up another company.

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

Todo:
currently this only works for AI companies
Parameters:
tile unused
flags type of operation
p1 company to buy up
p2 unused

Definition at line 2008 of file economy.cpp.

References CMD_ERROR, and DC_EXEC.

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

Acquire shares in an opposing company.

Parameters:
tile unused
flags type of operation
p1 company to buy the shares from
p2 unused

Definition at line 1930 of file economy.cpp.

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

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

Change the service interval of a vehicle.

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

Definition at line 578 of file vehicle_cmd.cpp.

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

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

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

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

Definition at line 2029 of file settings.cpp.

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

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

Add or remove waiting times from an order.

Parameters:
tile Not used.
flags Operation to perform.
p1 Various bitstuffed elements
  • p1 = (bit 0-15) - Vehicle with the orders to change.
  • p1 = (bit 16-23) - Order index to modify.
  • p1 = (bit 24) - Whether to change the waiting time or the travelling time.
  • p1 = (bit 25) - Whether p2 contains waiting and travelling time.
p2 The amount of time to wait.
  • p2 = (bit 0-15) - Waiting or travelling time as specified by p1 bit 24 if p1 bit 25 is not set, Travelling time if p1 bit 25 is set.
  • p2 = (bit 16-31) - Waiting time if p1 bit 25 is set

Definition at line 55 of file timetable_cmd.cpp.

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

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

Clear a big piece of landscape.

Parameters:
tile end tile of area dragging
p1 start tile of area dragging
flags of operation to conduct
p2 unused

Definition at line 608 of file landscape.cpp.

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

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

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

Parameters:
tile unused
flags operation to perform
p1 various bitstuffed elements
  • p1 = (bit 0-15) - destination vehicle to clone orders to (p1 & 0xFFFF)
  • p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)
p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE

Definition at line 1072 of file order_cmd.cpp.

References PoolItem< T, Tid, Tpool >::CanAllocateItem(), CanVehicleUseStation(), CC_PASSENGERS, CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteVehicleOrders(), OrderList::first, GB(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), InvalidateWindowClassesData(), IsValidVehicleID(), OrderGoesToStation(), OrderList::OrderList(), and return_cmd_error.

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

Clone a vehicle.

If it is a train, it will clone all the cars too

Parameters:
tile tile of the depot where the cloned vehicle is build
flags type of operation
p1 the original vehicle's index
p2 1 = shared orders, else copied orders

Definition at line 333 of file vehicle_cmd.cpp.

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

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

Control the companies: add, delete, etc.

Parameters:
tile unused
flags operation to perform
p1 various functionality
  • p1 = 0 - create a new company, Which company (network) it will be is in p2
  • p1 = 1 - create a new AI company
  • p1 = 2 - delete a company. Company is identified by p2
  • p1 = 3 - merge two companies together. merge #1 with #2. Identified by p2
p2 various functionality, dictated by p1
  • p1 = 0 - ClientID of the newly created client
  • p1 = 1 - CompanyID to start AI (INVALID_COMPANY for first available)
  • p1 = 2 - CompanyID of the that is getting deleted
  • p1 = 3 - #1 p2 = (bit 0-15) - company to merge (p2 & 0xFFFF)
    • #2 p2 = (bit 16-31) - company to be merged into ((p2>>16)&0xFFFF)
Todo:
In the case of p1=0, create new company, the clientID of the new client is in parameter p2. This parameter is passed in at function DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) on the server itself. First of all this is unbelievably ugly; second of all, well, it IS ugly! Someone fix this up :) So where to fix?
  • - network_server.c:838 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
  • - network_client.c:536 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) from where the map has been received

Definition at line 733 of file company_cmd.cpp.

References _network_playas, _settings_client, AddNewsItem(), GUISettings::autorenew, GUISettings::autorenew_money, GUISettings::autorenew_months, CMD_ERROR, CMD_RENAME_PRESIDENT, CMD_SET_AUTOREPLACE, CompanyNewsInformation::company_name, COMPANY_SPECTATOR, DC_EXEC, DeleteCompanyWindows(), DeleteWindowById(), DoStartupNewCompany(), CompanyNewsInformation::FillData(), GB(), ClientSettings::gui, INVALID_COMPANY, INVALID_OWNER, InvalidateWindowData(), MarkWholeScreenDirty(), MAX_COMPANIES, ClientSettings::network, NS_COMPANY_BANKRUPT, OWNER_NONE, SetDParamStr(), SetLocalCompany(), and StrEmpty().

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

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

Create a new vehicle group.

Parameters:
tile unused
p1 vehicle type
p2 unused

Definition at line 78 of file group_cmd.cpp.

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

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

Decrease the loan of your company.

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

Definition at line 183 of file misc_cmd.cpp.

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

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

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

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

Definition at line 106 of file group_cmd.cpp.

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

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

Delete an order from the orderlist of a vehicle.

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

Definition at line 669 of file order_cmd.cpp.

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

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

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

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

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

Definition at line 220 of file vehicle_cmd.cpp.

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

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

Sells all vehicles in a depot.

Parameters:
tile Tile of the depot where the depot is
flags type of operation
p1 Vehicle type
p2 unused

Definition at line 183 of file vehicle_cmd.cpp.

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

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

Do a town action.

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

Parameters:
tile unused
flags type of operation
p1 town to do the action at
p2 action to perform,
See also:
_town_action_proc for the list of available actions

Definition at line 2429 of file town_cmd.cpp.

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

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

Force a train through a red signal.

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

Definition at line 1975 of file train_cmd.cpp.

References CMD_ERROR, DC_EXEC, and IsValidVehicleID().

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

Transfer funds (money) from one company to another.

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

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

Definition at line 376 of file misc_cmd.cpp.

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

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

Increase the loan of your company.

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

Definition at line 139 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, and return_cmd_error.

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

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

Clear a piece of landscape.

Parameters:
tile tile to clear
flags of operation to conduct
p1 unused
p2 unused

Definition at line 597 of file landscape.cpp.

References TileTypeProcs::clear_tile_proc, and GetTileType().

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

Levels a selected (rectangle) area of land.

Parameters:
tile end tile of area-drag
flags for this command type
p1 start tile of area drag
p2 height difference; eg raise (+1), lower (-1) or level (0)
Returns:
error or cost of terraforming

Definition at line 357 of file terraform_cmd.cpp.

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

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

Starts or stops a lot of vehicles.

Parameters:
tile Tile of the depot where the vehicles are started/stopped (only used for depots)
flags type of operation
p1 Station/Order/Depot ID (only used for vehicle list windows)
p2 bitmask
  • bit 0-4 Vehicle type
  • bit 5 false = start vehicles, true = stop vehicles
  • bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
  • bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)

Definition at line 133 of file vehicle_cmd.cpp.

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

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

Modify an order in the orderlist of a vehicle.

Parameters:
tile unused
flags operation to perform
p1 various bitstuffed elements
  • p1 = (bit 0 - 15) - ID of the vehicle
  • p1 = (bit 16 - 31) - the selected order (if any). If the last order is given, the order will be inserted before that one only the first 8 bits used currently (bit 16 - 23) (max 255)
p2 various bitstuffed elements
  • p2 = (bit 0 - 3) - what data to modify (
See also:
ModifyOrderFlags)
  • p2 = (bit 4 - 15) - the data to modify

Definition at line 855 of file order_cmd.cpp.

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

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

Change the financial flow of your company.

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

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

Definition at line 359 of file misc_cmd.cpp.

References CMD_ERROR.

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

Move an order inside the orderlist.

Parameters:
tile unused
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 777 of file order_cmd.cpp.

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

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

Move a rail vehicle around inside the depot.

Parameters:
tile unused
flags type of operation Note: DC_AUTOREPLACE is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot.
p1 various bitstuffed elements
  • p1 (bit 0 - 15) source vehicle index
  • p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
p2 (bit 0) move all vehicles following the source vehicle

Definition at line 993 of file train_cmd.cpp.

References _settings_game, CALLBACK_FAILED, CBID_TRAIN_ALLOW_WAGON_ATTACH, ClearFreeWagon(), ClearFrontEngine(), CMD_ERROR, CmdMoveRailVehicle(), DC_AUTOREPLACE, DC_EXEC, DEFAULT_GROUP, DeleteVehicleOrders(), DeleteWindowById(), error, GB(), GetEngineGRFID(), GetGRFStringID(), GetLastEnginePart(), GetNextUnit(), GetNextVehicle(), GetVehicleCallbackParent(), HasBit(), HASBITS, InvalidateWindow(), InvalidateWindowClassesData(), InvalidateWindowData(), InvalidateWindowWidget(), IsArticulatedPart(), IsFreeWagon(), IsFrontEngine(), IsRearDualheaded(), IsTrainEngine(), IsValidVehicleID(), VehicleSettings::mammoth_trains, VehicleSettings::max_trains, RemoveVehicleFromGroup(), return_cmd_error, SetFreeWagon(), SetFrontEngine(), SetTrainGroupID(), TrainConsistChanged(), UnlinkWagon(), UpdateTrainGroupID(), and GameSettings::vehicle.

Referenced by CmdMoveRailVehicle().

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

Add/remove refit orders from an order.

Parameters:
tile Not used
flags operation to perform
p1 VehicleIndex of the vehicle having the order
p2 bitmask
  • bit 0-7 CargoID
  • bit 8-15 Cargo subtype
  • bit 16-23 number of order to modify

Definition at line 1201 of file order_cmd.cpp.

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

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

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 323 of file misc_cmd.cpp.

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

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

Place a sign at the given coordinates.

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

Parameters:
tile tile to place sign at
flags type of operation
p1 unused
p2 unused

Definition at line 29 of file signs_cmd.cpp.

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

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

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

Purchase a land area.

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

Parameters:
tile the tile the company is purchasing
flags for this command type
p1 unused
p2 unused
Returns:
error of cost of operation

Definition at line 134 of file unmovable_cmd.cpp.

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

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

Refits an aircraft to the specified cargo type.

Parameters:
tile unused
flags for command type
p1 vehicle ID of the aircraft to refit
p2 various bitstuffed elements
  • p2 = (bit 0-7) - the new cargo type to refit to
  • p2 = (bit 8-15) - the new cargo subtype to refit to
  • p2 = (bit 16) - refit only this vehicle (ignored)
Returns:
cost of refit or error

Definition at line 527 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(), InvalidateWindow(), InvalidateWindowClassesData(), IsValidVehicleID(), and return_cmd_error.

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

Refits a train to the specified cargo type.

Parameters:
tile unused
flags type of operation
p1 vehicle ID of the train to refit 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 1998 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(), InvalidateWindow(), InvalidateWindowClassesData(), IsValidVehicleID(), return_cmd_error, and TrainConsistChanged().

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

Refit a road vehicle to the specified cargo type.

Parameters:
tile unused
flags operation to perform
p1 Vehicle ID of the vehicle to refit
p2 Bitstuffed elements
  • p2 = (bit 0-7) - the new cargo type to refit to
  • p2 = (bit 8-15) - the new cargo subtype to refit to
  • p2 = (bit 16) - refit only this vehicle
Returns:
cost of refit or error

Definition at line 1961 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(), InvalidateWindow(), InvalidateWindowClassesData(), IsValidVehicleID(), and return_cmd_error.

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

Refits a ship to the specified cargo type.

Parameters:
tile unused
flags type of operation
p1 vehicle ID of the ship to refit
p2 various bitstuffed elements
  • p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
  • p2 = (bit 8-15) - the new cargo subtype to refit to
  • p2 = (bit 16) - refit only this vehicle (ignored)
Returns:
cost of refit or error

Definition at line 896 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(), InvalidateWindow(), InvalidateWindowClassesData(), IsValidVehicleID(), and return_cmd_error.

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

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 284 of file group_cmd.cpp.

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

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

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

Remove a long piece of road.

Parameters:
end_tile end tile of drag
flags operation to perform
p1 start tile of drag
p2 various bitstuffed elements
  • p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
  • p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
  • p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
  • p2 = (bit 3 + 4) - road type

Definition at line 784 of file road_cmd.cpp.

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

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

Build rail on a stretch of track.

Stub for the unified rail builder/remover

Parameters:
tile start tile of drag
flags operation to perform
p1 end tile of drag
p2 various bitstuffed elements
  • p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
  • p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
  • p2 = (bit 7) - 0 = build, 1 = remove tracks
See also:
CmdRailTrackHelper

Definition at line 735 of file rail_cmd.cpp.

References CmdRailTrackHelper(), and SetBit().

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

Delete a piece of road.

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

Definition at line 355 of file road_cmd.cpp.

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

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

Remove a bus or truck stop.

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

Definition at line 1591 of file station_cmd.cpp.

References CMD_ERROR, CmdSucceeded(), DIAGDIR_NE, DiagDirToRoadBits(), GB(), GetRoadStopDir(), IsRoadStop(), IsTileType(), RemoveRoadStop(), ROAD_X, ROAD_Y, ROADTYPE_ROAD, and ROADTYPE_TRAM.

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

Remove signals on a stretch of track.

Stub for the unified signal builder/remover

Parameters:
tile start tile of drag
flags operation to perform
p1 end tile of drag
p2 various bitstuffed elements
  • p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
  • p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
  • p2 = (bit 4) - 0 = signals, 1 = semaphores
  • p2 = (bit 5) - 0 = build, 1 = remove signals
  • p2 = (bit 6) - 0 = selected stretch, 1 = auto fill
  • p2 = (bit 7- 9) - default signal type
  • p2 = (bit 24-31) - user defined signals_density
See also:
CmdSignalTrackHelper

Definition at line 1225 of file rail_cmd.cpp.

References CmdSignalTrackHelper(), and SetBit().

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

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

Remove signals.

Parameters:
tile coordinates where signal is being deleted from
flags operation to perform
p1 various bitstuffed elements, only track information is used
  • (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
  • (bit 3) - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
  • (bit 4) - 0 = signals, 1 = semaphores
p2 unused

Definition at line 1170 of file rail_cmd.cpp.

References AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, EnsureNoTrainOnTrack(), GB(), GetPresentSignals(), GetTileOwner(), GetTrainForReservation(), HasReservedTracks(), HasSignalOnTrack(), HasTrack(), INVALID_TRACK, IsPlainRailTile(), MarkTileDirtyByTile(), OWNER_WATER, SetHasSignals(), SetPresentSignals(), SetSignalStates(), SIG_ELECTRIC, SignalOnTrack(), TrackToTrackBits(), TryPathReserve(), and YapfNotifyTrackLayoutChange().

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

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 291 of file waypoint_cmd.cpp.

References CmdRemoveTrainWaypoint(), and RemoveTrainWaypoint().

Referenced by CmdRemoveTrainWaypoint().

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

Change the name of the company.

Parameters:
tile unused
flags operation to perform
p1 unused
p2 unused

Definition at line 235 of file misc_cmd.cpp.

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

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

Rename an engine.

Parameters:
tile unused
flags operation to perfom
p1 engine ID to rename
p2 unused

Definition at line 737 of file engine.cpp.

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

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

Rename a group.

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

Definition at line 165 of file group_cmd.cpp.

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

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

Change the name of the president.

Parameters:
tile unused
flags operation to perform
p1 unused
p2 unused

Definition at line 271 of file misc_cmd.cpp.

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

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

Rename a sign.

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

Parameters:
tile unused
flags type of operation
p1 index of the sign to be renamed/removed
p2 unused
Returns:
0 if succesfull, otherwise CMD_ERROR

Definition at line 67 of file signs_cmd.cpp.

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

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

Rename a station.

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

Definition at line 2912 of file station_cmd.cpp.

References CMD_ERROR, InvalidateWindowData(), MarkWholeScreenDirty(), MAX_LENGTH_STATION_NAME_BYTES, Station::name, Station::owner, return_cmd_error, StrEmpty(), and UpdateStationVirtCoord().

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

Rename a town (server-only).

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

Definition at line 2154 of file town_cmd.cpp.

References CMD_ERROR, DC_EXEC, InvalidateWindowData(), IsValidTownID(), MarkWholeScreenDirty(), MAX_LENGTH_TOWN_NAME_BYTES, return_cmd_error, StrEmpty(), UpdateAllStationVirtCoord(), UpdateAllWaypointSigns(), and UpdateTownVirtCoord().

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

Give a custom name to your vehicle.

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

Definition at line 547 of file vehicle_cmd.cpp.

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

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

Rename a waypoint.

Parameters:
tile unused
flags type of operation
p1 id of waypoint
p2 unused
Returns:
cost of operation or error

Definition at line 315 of file waypoint_cmd.cpp.

References CMD_ERROR, CmdRenameWaypoint(), DC_EXEC, MarkWholeScreenDirty(), MAX_LENGTH_WAYPOINT_NAME_BYTES, return_cmd_error, StrEmpty(), and UpdateWaypointSign().

Referenced by CmdRenameWaypoint().

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

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

Parameters:
tile unused
flags operation to perform
p1 the ID of the vehicle
p2 various bistuffed elements
  • p2 = (bit 0-15) - current order-index (p2 & 0xFFFF)
  • p2 = (bit 16-31) - service interval (p2 >> 16)
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 1357 of file order_cmd.cpp.

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

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

Reverse train.

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

Definition at line 1914 of file train_cmd.cpp.

References _settings_game, CBM_VEHICLE_ARTIC_ENGINE, CMD_ERROR, DC_EXEC, GetStationIndex(), HasBit(), InvalidateWindow(), IsMultiheaded(), IsTileType(), IsValidVehicleID(), MP_STATION, return_cmd_error, ToggleBit(), VehicleSettings::train_acceleration_model, and GameSettings::vehicle.

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

Sell an aircraft.

Parameters:
tile unused
flags for command type
p1 vehicle ID to be sold
p2 unused
Returns:
result of operation. Error or sold value

Definition at line 451 of file aircraft_cmd.cpp.

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

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

Sell a land area.

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

Parameters:
tile the tile the company is selling
flags for this command type
p1 unused
p2 unused
Returns:
error or cost of operation

Definition at line 161 of file unmovable_cmd.cpp.

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

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

Sell a (single) train wagon/engine.

Parameters:
tile unused
flags type of operation
p1 the wagon/engine index
p2 the selling mode
  • p2 = 0: only sell the single dragged wagon/engine (and any belonging rear-engines)
  • p2 = 1: sell the vehicle and all vehicles following it in the chain if the wagon is dragged, don't delete the possibly belonging rear-engine to some front

Definition at line 1357 of file train_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, CMD_MOVE_RAIL_VEHICLE, DC_EXEC, DEFAULT_GROUP, DeleteVehicleOrders(), DeleteWindowById(), DoCommand(), CommandCost::Failed(), GetNextVehicle(), HASBITS, InvalidateWindow(), InvalidateWindowClassesData(), IsArticulatedPart(), IsFrontEngine(), IsMultiheaded(), IsRearDualheaded(), IsTrainEngine(), IsValidVehicleID(), return_cmd_error, SetFrontEngine(), ShowVehicleViewWindow(), TrainConsistChanged(), UnlinkWagon(), and UpdateTrainGroupID().

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

Sell a road vehicle.

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

Definition at line 328 of file roadveh_cmd.cpp.

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

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

Sell shares in an opposing company.

Parameters:
tile unused
flags type of operation
p1 company to sell the shares from
p2 unused

Definition at line 1975 of file economy.cpp.

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

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

Sell a ship.

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

Definition at line 823 of file ship_cmd.cpp.

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

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

Send an aircraft to the hangar.

Parameters:
tile unused
flags for command type
p1 vehicle ID to send to the hangar
p2 various bitmasked elements
  • p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  • p2 bit 8-10 - VLW flag (for mass goto depot)
Returns:
o if everything went well

Definition at line 499 of file aircraft_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, IsValidVehicleID(), and SendAllVehiclesToDepot().

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

Send a road vehicle to the depot.

Parameters:
tile unused
flags operation to perform
p1 vehicle ID to send to the depot
p2 various bitmasked elements
  • p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  • p2 bit 8-10 - VLW flag (for mass goto depot)

Definition at line 433 of file roadveh_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, IsValidVehicleID(), and SendAllVehiclesToDepot().

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

Send a ship to the depot.

Parameters:
tile unused
flags type of operation
p1 vehicle ID to send to the depot
p2 various bitmasked elements
  • p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  • p2 bit 8-10 - VLW flag (for mass goto depot)

Definition at line 868 of file ship_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, IsValidVehicleID(), and SendAllVehiclesToDepot().

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

Send a train to a depot.

Parameters:
tile unused
flags type of operation
p1 train to send to the depot
p2 various bitmasked elements
  • p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  • p2 bit 8-10 - VLW flag (for mass goto depot)

Definition at line 2202 of file train_cmd.cpp.

References CMD_ERROR, DEPOT_MASS_SEND, DEPOT_SERVICE, IsValidVehicleID(), and SendAllVehiclesToDepot().

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

Change engine renewal parameters.

Parameters:
tile unused
flags operation to perform
p1 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 16-31 = 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 589 of file company_cmd.cpp.

References _settings_client, AddEngineReplacementForCompany(), GUISettings::autorenew, GUISettings::autorenew_money, GUISettings::autorenew_months, CheckAutoreplaceValidity(), Clamp(), ClampU(), CMD_ERROR, DC_EXEC, GB(), ClientSettings::gui, HasBit(), InvalidateAutoreplaceWindow(), InvalidateWindow(), IsAllGroupID(), and RemoveEngineReplacementForCompany().

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

Change the company's company-colour.

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

Definition at line 52 of file misc_cmd.cpp.

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

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

Change the company manager's face.

Parameters:
tile unused
flags operation to perform
p1 unused
p2 face bitmasked

Definition at line 31 of file misc_cmd.cpp.

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

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

(Un)set global replace protection from a group

Parameters:
tile unused
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 321 of file group_cmd.cpp.

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

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

Clear the lateness counter to make the vehicle on time.

Parameters:
tile Not used.
flags Operation to perform.
p1 Various bitstuffed elements
  • p1 = (bit 0-15) - Vehicle with the orders to change.

Definition at line 113 of file timetable_cmd.cpp.

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

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

Goto order of order-list.

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

Definition at line 737 of file order_cmd.cpp.

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

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

Start/Stop a vehicle.

Parameters:
tile unused
flags type of operation
p1 vehicle to start/stop
p2 bit 0: Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety)
Returns:
result of operation. Nothing if everything went well

Definition at line 59 of file vehicle_cmd.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_START_STOP_CHECK, CMD_ERROR, DC_AUTOREPLACE, DC_EXEC, DeleteVehicleNews(), error, GB(), GetEngineGRFID(), GetGRFStringID(), GetVehicleCallback(), HasBit(), InvalidateWindow(), InvalidateWindowClasses(), InvalidateWindowWidget(), IsValidVehicleID(), return_cmd_error, and SetBit().

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

Terraform land.

Parameters:
tile tile to terraform
flags for this command type
p1 corners to terraform (SLOPE_xxx)
p2 direction; eg up (non-zero) or down (zero)
Returns:
error or cost of terraforming

Definition at line 231 of file terraform_cmd.cpp.

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

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

Turn a roadvehicle around.

Parameters:
tile unused
flags operation to perform
p1 vehicle ID to turn
p2 unused

Definition at line 456 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,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Accept an engine prototype.

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

Parameters:
tile unused
flags operation to perfom
p1 engine-prototype offered
p2 unused

Definition at line 623 of file engine.cpp.

References CMD_ERROR, and DC_EXEC.

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

Execute a command.

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

Parameters:
tile The tile to apply the command on (for the CommandProc)
p1 Additional data for the command (for the CommandProc)
p2 Additional data for the command (for the CommandProc)
flags Flags for the command and how to execute the command
cmd The command-id to execute (a value of the CMD_* enums)
See also:
CommandProc
Returns:
the cost

Definition at line 396 of file command.cpp.

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

CommandCost DoCommand ( const CommandContainer container,
DoCommandFlag  flags 
)

Shorthand for calling the long DoCommand with a container.

Parameters:
container Container with (almost) all information
flags Flags for the command and how to execute the command
See also:
CommandProc
Returns:
the cost

Definition at line 379 of file command.cpp.

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

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

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

Execute a network safe DoCommand function.

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

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

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

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

bool DoCommandP ( const CommandContainer container,
bool  my_cmd 
)

Money GetAvailableMoneyForCommand (  ) 

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

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

Returns:
The available money of a company or INT64_MAX

Definition at line 458 of file command.cpp.

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

byte GetCommandFlags ( uint32  cmd  ) 

Returns the flags from a given command.

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

Parameters:
cmd The integer value of the command
Returns:
The flags for this command

Definition at line 362 of file command.cpp.

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

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

bool IsValidCommand ( uint32  cmd  ) 

Checks if a integer value belongs to a command.

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

Parameters:
cmd The integervalue of a command
Returns:
true if the command is valid (and got a CommandProc function)

Definition at line 346 of file command.cpp.

References CMD_ID_MASK, lengthof, and Command::proc.

Referenced by GetCommandFlags().


Variable Documentation

const Command _command_proc_table[] [static]

The master command table.

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

Definition at line 203 of file command.cpp.


Generated on Tue Dec 1 00:06:22 2009 for OpenTTD by  doxygen 1.5.6