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 "variables.h"
#include "genworld.h"
#include "newgrf_storage.h"
#include "strings_func.h"
#include "gfx_func.h"
#include "functions.h"
#include "town.h"
#include "date_func.h"
#include "debug.h"
#include "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, uint32 flags, uint32 p1, uint32 p2)
 Helper macro to define the header of all command handler macros.

Functions

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

Variables

const char * _cmd_text = NULL
 Text, which gets sent with a command.
StringID _error_message
static const Command _command_proc_table []
 The master command table.
static int _docommand_recursive = 0


Detailed Description

Handling of commands.

Definition in file command.cpp.


Define Documentation

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

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

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

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

Definition at line 39 of file command.cpp.


Function Documentation

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

Add all shared vehicles of all vehicles from a group.

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

Definition at line 253 of file group_cmd.cpp.

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

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

Add a vehicle to a group.

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

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

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

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

Parameters:
tile Not used.
flags Operation to perform.
p1 Vehicle index.
p2 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 140 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,
uint32  flags,
uint32  p1,
uint32  p2 
)

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 610 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,
uint32  flags,
uint32  p1,
uint32  p2 
)

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

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

Build a Bridge.

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

Definition at line 189 of file tunnelbridge_cmd.cpp.

References _settings_game, CommandCost::AddCost(), AddSideToSignalBuffer(), AreValidRoadTypes(), AXIS_X, AXIS_Y, AxisToDiagDir(), AxisToTrack(), ConstructionSettings::build_on_slopes, CalcBridgeLenCostFactor(), CheckBridgeSlopeNorth(), CheckBridgeSlopeSouth(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), GameSettings::construction, DC_EXEC, DiagDirToAxis(), DoCommand(), GB(), GetBridgeAxis(), GetBridgeHeight(), GetBridgeType(), CommandCost::GetCost(), GetNorthernBridgeEnd(), GetOtherBridgeEnd(), GetRailType(), GetTileMaxZ(), GetTileSlope(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), HasRoadTypesAvail(), INVALID_DIAGDIR, INVALID_RAILTYPE, IsBridgeAbove(), IsBridgeTile(), IsOwnedLand(), IsPlainRailTile(), 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,
uint32  flags,
uint32  p1,
uint32  p2 
)

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

Build a piece of canal.

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

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

Build or relocate the HQ.

This depends if the HQ is already built or not

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

Definition at line 91 of file unmovable_cmd.cpp.

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

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

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

Build/Fund an industry.

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

Definition at line 1636 of file industry_cmd.cpp.

References _settings_game, AddNewsItem(), Clamp(), CMD_ERROR, GameSettings::construction, CreateNewIndustryHelper(), IndustrySpec::enabled, GB(), IndustrySpec::GetConstructionCost(), GetIndustrySpec(), IndustrySpec::IsRawIndustry(), IndustrySpec::name, IndustrySpec::new_industry_text, NS_INDUSTRY_OPEN, IndustrySpec::num_table, IndustrySpec::prospecting_chance, RandomTile, ConstructionSettings::raw_industry_construction, IndustrySpec::table, Industry::town, and Industry::xy.

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

Builds a lock (ship-lift).

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

Definition at line 357 of file water_cmd.cpp.

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

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

Build a long piece of road.

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

Definition at line 722 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_