#include "command_type.h"
Go to the source code of this file.
Defines | |
#define | return_cmd_error(errcode) return CommandCost(errcode); |
Returns from a function with a specific StringID as error. | |
Functions | |
static bool | CmdFailed (CommandCost cost) |
Checks if a command failes. | |
static bool | CmdSucceeded (CommandCost cost) |
Checks if a command succeeded. | |
CommandCost | DoCommand (TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc) |
Execute a command. | |
bool | DoCommandP (TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd=true) |
Execute a network safe DoCommand function. | |
bool | IsValidCommand (uint32 cmd) |
Checks if a integer value belongs to a command. | |
byte | GetCommandFlags (uint32 cmd) |
Returns the flags from a given command. | |
Money | GetAvailableMoneyForCommand () |
Returns the current money available which can be used for a command. | |
Variables | |
static const CommandCost | CMD_ERROR = CommandCost(INVALID_STRING_ID) |
Define a default return value for a failed command. | |
const char * | _cmd_text |
Text, which gets sent with a command. | |
Money | _additional_cash_required |
StringID | _error_message |
Definition in file command_func.h.
#define return_cmd_error | ( | errcode | ) | return CommandCost(errcode); |
Returns from a function with a specific StringID as error.
This macro is used to return from a function. The parameter contains the StringID which will be returned.
errcode | The StringID to return |
Definition at line 51 of file command_func.h.
Referenced by CheckFlatLandBelow(), CheckRailSlope(), CmdBuildAircraft(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLock(), CmdBuildRailroadStation(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildRoadVeh(), CmdBuildShip(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTown(), CmdBuildTrainDepot(), CmdBuildTrainWaypoint(), CmdBuildTunnel(), CmdBuyShareInCompany(), CmdChangeCompanyName(), CmdChangePresidentName(), CmdChangeTimetable(), CmdCloneOrder(), CmdCloneVehicle(), CmdDecreaseLoan(), CmdIncreaseLoan(), CmdInsertOrder(), CmdLevelLand(), CmdMoveRailVehicle(), CmdNameVehicle(), CmdPlaceSign(), CmdPlantTree(), CmdPurchaseLandArea(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), CmdRefitShip(), CmdRemoveFromRailroadStation(), CmdRenameEngine(), CmdRenameGroup(), CmdRenameStation(), CmdRenameTown(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellAircraft(), CmdSellRailWagon(), CmdSellRoadVeh(), CmdSellShip(), CmdSendRoadVehToDepot(), CmdSendShipToDepot(), CmdSendTrainToDepot(), CmdStartStopAircraft(), CmdStartStopRoadVeh(), CmdStartStopShip(), CmdStartStopTrain(), CmdTerraformLand(), DoBuildShiplift(), RemoveRoad(), and TerraformTileHeight().
static bool CmdFailed | ( | CommandCost | cost | ) | [inline, static] |
Checks if a command failes.
As you see the parameter is not a command but the return value of a command, the CommandCost class. This function checks if the command executed by the CommandProc function failed and returns true if it does.
cost | The return value of a CommandProc call |
Definition at line 21 of file command_func.h.
References CommandCost::Failed().
Referenced by CheckFlatLandBelow(), CheckIfCanLevelIndustryPlatform(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildCompanyHQ(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildRailroadStation(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdClearArea(), CmdCloneVehicle(), CmdLevelLand(), CmdPlantTree(), CmdPurchaseLandArea(), CmdRailTrackHelper(), CmdSignalTrackHelper(), CmdTerraformLand(), DoBuildShiplift(), DoCommand(), DoCommandP(), FloodHalftile(), IsRoadAllowedHere(), NormalizeTrainVehInDepot(), TerraformTileHeight(), and TestAutoslopeOnRailTile().
static bool CmdSucceeded | ( | CommandCost | cost | ) | [inline, static] |
Checks if a command succeeded.
As CmdFailed this function checks if a command succeeded
cost | The return value of a CommandProc call |
Definition at line 32 of file command_func.h.
References CommandCost::Succeeded().
Referenced by CanBuildHouseHere(), CanBuildTramTrackOnTile(), ClearMakeHouseTile(), CmdCloneVehicle(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdMassStartStopVehicle(), CmdRemoveLongRoad(), CmdRemoveRoadStop(), CmdSignalTrackHelper(), DoDryUp(), DoFloodTile(), GrowTown(), GrowTownWithBridge(), GrowTownWithRoad(), and SendAllVehiclesToDepot().
CommandCost DoCommand | ( | TileIndex | tile, | |
uint32 | p1, | |||
uint32 | p2, | |||
uint32 | flags, | |||
uint32 | procc | |||
) |
Execute a command.
This function executes a given command with the parameters from the CommandProc parameter list. Depending on the flags parameter it execute or test a command.
tile | The tile to apply the command on (for the CommandProc) | |
p1 | Additional data for the command (for the CommandProc) | |
p2 | Additional data for the command (for the CommandProc) | |
flags | Flags for the command and how to execute the command | |
procc | The command-id to execute (a value of the CMD_* enums) |
Definition at line 396 of file command.cpp.
References _cmd_text, CMD_ERROR, CmdFailed(), DC_BANKRUPT, DC_EXEC, DC_QUERY_COST, error, CommandCost::GetCost(), IsValidTile(), Command::proc, and CommandCost::SetGlobalErrorMessage().
Referenced by BuildRailToolbWndProc(), CanBuildHouseHere(), CanBuildTramTrackOnTile(), CheckFlatLandBelow(), CheckIfCanLevelIndustryPlatform(), CheckSendAircraftToHangarForReplacement(), ClearMakeHouseTile(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdChangePresidentName(), CmdClearArea(), CmdCloneVehicle(), CmdDepotSellAllVehicles(), CmdLevelLand(), CmdMassStartStopVehicle(), CmdPlantTree(), CmdPurchaseLandArea(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdRemoveSingleRail(), CmdSellRailWagon(), CmdSendTrainToDepot(), CmdSignalTrackHelper(), DoBuildShiplift(), DoDryUp(), DoFloodTile(), FloodHalftile(), GrowTown(), GrowTownWithBridge(), GrowTownWithRoad(), IsRoadAllowedHere(), NormalizeTrainVehInDepot(), RemoveRoad(), SearchLumberMillTrees(), and SendAllVehiclesToDepot().
bool DoCommandP | ( | TileIndex | tile, | |
uint32 | p1, | |||
uint32 | p2, | |||
CommandCallback * | callback, | |||
uint32 | cmd, | |||
bool | my_cmd | |||
) |
Execute a network safe DoCommand function.
Toplevel network safe docommand function for the current player. Must not be called recursively. The callback is called when the command succeeded or failed. The parameters tile, p1 and p2 are from the CommandProc function. The paramater cmd is the command to execute. The parameter my_cmd is used to indicate if the command is from a player or the server.
tile | The tile to perform a command on (see CommandProc) | |
p1 | Additional data for the command (see CommandProc) | |
p2 | Additional data for the command (see CommandProc) | |
callback | A callback function to call after the command is finished | |
cmd | The command to execute (a CMD_* value) | |
my_cmd | indicator if the command is from a player or server (to display error messages for a user) |
Spectator has no rights except for the (dedicated) server which is/can be a spectator but as the server it can do anything
Definition at line 490 of file command.cpp.
References _cmd_text, _networking, _shift_pressed, ClearStorageChanges(), CMD_AUTO, CMD_CLEAR_AREA, CMD_CLONE_VEHICLE, CMD_LEVEL_LAND, CMD_NETWORK_COMMAND, CMD_NO_TEST_IF_IN_NETWORK, CMD_NO_WATER, CMD_PAUSE, CMD_REMOVE_LONG_ROAD, CMD_SHOW_NO_ERROR, CmdFailed(), DC_AUTO, DC_EXEC, DC_NO_WATER, GB(), GetCommandFlags(), CommandCost::GetCost(), IsGeneratingWorld(), IsValidTile(), PLAYER_FIRST, PLAYER_SPECTATOR, Command::proc, CommandCost::SetGlobalErrorMessage(), TILE_SIZE, TileX(), TileY(), and UpdateSignalsInBuffer().
Referenced by _GenerateWorld(), AskUnsafeUnpauseCallback(), BuildRailToolbWndProc(), CommonRaiseLowerBigLand(), EndGameWndProc(), GenerateDesertArea(), GenericPlaceSignals(), GroupWndProc(), GUIPlaceProcDragXY(), HandleAutoSignalPlacement(), HandleCloneVehClick(), OrderClick_Delete(), OrderClick_FullLoad(), OrderClick_Nonstop(), OrderClick_Refit(), OrderClick_Skip(), OrderClick_Transfer(), OrderClick_Unload(), PlaceProc_Sign(), PlayerCompanyWndProc(), RestoreVehicleOrders(), SelectPlayerFaceWndProc(), SetPatchValue(), ShowEndGameChart(), ShowHighscoreTable(), StartScenario(), StationViewWndProc(), TownAuthorityWndProc(), VehicleDetailsWndProc(), and VehicleViewWndProc().
Money GetAvailableMoneyForCommand | ( | ) |
Returns the current money available which can be used for a command.
This functions returns the money which can be used to execute a command. This is either the money of the current player or INT64_MAX if there is no such a player "at the moment" like the server itself.
Definition at line 469 of file command.cpp.
Referenced by CmdClearArea(), CmdLevelLand(), and CmdRemoveLongRoad().
byte GetCommandFlags | ( | uint | cmd | ) |
Returns the flags from a given command.
This function mask the parameter with 0xFF and returns the flags which belongs to the given command.
cmd | The integer value of the command |
Definition at line 378 of file command.cpp.
References Command::flags.
Referenced by DoCommandP().
bool IsValidCommand | ( | uint | cmd | ) |
Checks if a integer value belongs to a command.
This function range-checks a cmd, and checks if the cmd is not NULL
cmd | The integervalue of a command |
Definition at line 359 of file command.cpp.
References Command::proc.
const char* _cmd_text |
Text, which gets sent with a command.
This variable contains a string (be specific a pointer of the first char of this string) which will be send with a command. This is used for user input data like names or chat messages.
Definition at line 27 of file command.cpp.
Referenced by CmdChangeCompanyName(), CmdChangePresidentName(), CmdNameVehicle(), CmdPlayerCtrl(), CmdRenameEngine(), CmdRenameGroup(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameWaypoint(), DoCommand(), DoCommandP(), GroupWndProc(), PlayerCompanyWndProc(), RestoreVehicleOrders(), StationViewWndProc(), and VehicleDetailsWndProc().
const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID) [static] |
Define a default return value for a failed command.
This variable contains a CommandCost object with is declared as "failed". Other functions just need to return this error if there is an error, which doesn't need to specific by a StringID.
Definition at line 41 of file command_func.h.
Referenced by AddEngineReplacement(), CheckBridgeSlopeNorth(), CheckBridgeSlopeSouth(), CheckFlatLandBelow(), CheckRoadSlope(), CmdAddSharedVehicleGroup(), CmdAddVehicleGroup(), CmdAutofillTimetable(), CmdBuildAircraft(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildDock(), CmdBuildIndustry(), CmdBuildLongRoad(), CmdBuildRailroadStation(), CmdBuildRailVehicle(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildRoadVeh(), CmdBuildShip(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTown(), CmdBuildTrainDepot(), CmdBuildTrainWaypoint(), CmdBuildTunnel(), CmdBuyCompany(), CmdBuyShareInCompany(), CmdChangeCompanyName(), CmdChangeDifficultyLevel(), CmdChangePatchSetting(), CmdChangePresidentName(), CmdChangeServiceInt(), CmdChangeTimetable(), CmdClearArea(), CmdCloneOrder(), CmdCloneVehicle(), CmdConvertRail(), CmdCreateGroup(), CmdDecreaseLoan(), CmdDeleteGroup(), CmdDeleteOrder(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdDoTownAction(), CmdForceTrainProceed(), CmdGiveMoney(), CmdIncreaseLoan(), CmdInsertOrder(), CmdLevelLand(), CmdMassStartStopVehicle(), CmdModifyOrder(), CmdMoneyCheat(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdNameVehicle(), CmdOrderRefit(), CmdPlantTree(), CmdPlayerCtrl(), CmdPurchaseLandArea(), CmdRailTrackHelper(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), CmdRefitShip(), CmdRemoveAllVehiclesGroup(), CmdRemoveFromRailroadStation(), CmdRemoveLongRoad(), CmdRemoveRoad(), CmdRemoveRoadStop(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdRenameEngine(), CmdRenameGroup(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameWaypoint(), CmdRestoreOrderIndex(), CmdReverseTrainDirection(), CmdSellAircraft(), CmdSellLandArea(), CmdSellRailWagon(), CmdSellRoadVeh(), CmdSellShareInCompany(), CmdSellShip(), CmdSendAircraftToHangar(), CmdSendRoadVehToDepot(), CmdSendShipToDepot(), CmdSendTrainToDepot(), CmdSetAutoReplace(), CmdSetGroupReplaceProtection(), CmdSetPlayerColor(), CmdSetPlayerFace(), CmdSetRoadDriveSide(), CmdSetVehicleOnTime(), CmdSignalTrackHelper(), CmdSkipToOrder(), CmdStartStopAircraft(), CmdStartStopRoadVeh(), CmdStartStopShip(), CmdStartStopTrain(), CmdTerraformLand(), CmdTurnRoadVeh(), CmdWantEnginePreview(), DoBuildShiplift(), DoCommand(), IsRoadAllowedHere(), RemoveEngineReplacement(), RemoveRoad(), RemoveRoadStop(), RemoveTrainWaypoint(), SendAllVehiclesToDepot(), TerraformTileHeight(), and TestAutoslopeOnRailTile().