OpenTTD Source
20241120-master-g6d3adc6169
|
Functions related to commands. More...
#include "command_type.h"
#include "network/network_type.h"
#include "company_type.h"
#include "company_func.h"
#include "core/backup_type.hpp"
#include "misc/endian_buffer.hpp"
#include "tile_map.h"
Go to the source code of this file.
Data Structures | |
struct | RecursiveCommandCounter |
Helper class to keep track of command nesting level. More... | |
class | CommandHelperBase |
struct | CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true > |
Templated wrapper that exposes the command parameter arguments for the various Command::Do/Post calls. More... | |
struct | CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false > |
Overload for CommandHelper that exposes additional Post variants for commands that don't take a TileIndex themselves. More... | |
Macros | |
#define | return_cmd_error(errcode) return CommandCost(errcode); |
Returns from a function with a specific StringID as error. More... | |
Typedefs | |
template<Commands Tcmd> | |
using | Command = CommandHelper< Tcmd, typename CommandTraits< Tcmd >::ProcType,(GetCommandFlags< Tcmd >() &CMD_LOCATION)==0 > |
Functions | |
void | NetworkSendCommand (Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, const CommandDataBuffer &cmd_data) |
Prepare a DoCommand to be send over the network. More... | |
bool | IsValidCommand (Commands cmd) |
This function range-checks a cmd. More... | |
CommandFlags | GetCommandFlags (Commands cmd) |
This function mask the parameter with CMD_ID_MASK and returns the flags which belongs to the given command. More... | |
const char * | GetCommandName (Commands cmd) |
This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given command. More... | |
bool | IsCommandAllowedWhilePaused (Commands cmd) |
Returns whether the command is allowed while the game is paused. More... | |
template<Commands Tcmd> | |
constexpr CommandFlags | GetCommandFlags () |
static constexpr DoCommandFlag | CommandFlagsToDCFlags (CommandFlags cmd_flags) |
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags. More... | |
Variables | |
static const CommandCost | CMD_ERROR = CommandCost(INVALID_STRING_ID) |
Define a default return value for a failed command. More... | |
Functions related to commands.
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 38 of file command_func.h.
|
inlinestaticconstexpr |
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
cmd_flags | Flags from GetCommandFlags |
Definition at line 58 of file command_func.h.
References CMD_ALL_TILES, CMD_AUTO, CMD_NO_WATER, DC_ALL_TILES, DC_AUTO, DC_NO_WATER, and DC_NONE.
Referenced by GrowTownWithBridge(), GrowTownWithTunnel(), PlaceAirport(), and ShowBuildBridgeWindow().
CommandFlags GetCommandFlags | ( | Commands | cmd | ) |
This function mask the parameter with CMD_ID_MASK and returns the flags which belongs to the given command.
cmd | The integer value of the command |
Definition at line 118 of file command.cpp.
References _command_proc_table, and IsValidCommand().
const char* GetCommandName | ( | Commands | cmd | ) |
This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given command.
cmd | The integer value of the command |
Definition at line 132 of file command.cpp.
References _command_proc_table, and IsValidCommand().
Referenced by CommandHelperBase::LogCommandExecution().
bool IsCommandAllowedWhilePaused | ( | Commands | cmd | ) |
Returns whether the command is allowed while the game is paused.
cmd | The command to check. |
< CMDT_LANDSCAPE_CONSTRUCTION
< CMDT_VEHICLE_CONSTRUCTION
< CMDT_MONEY_MANAGEMENT
< CMDT_VEHICLE_MANAGEMENT
< CMDT_ROUTE_MANAGEMENT
< CMDT_OTHER_MANAGEMENT
< CMDT_COMPANY_SETTING
< CMDT_SERVER_SETTING
< CMDT_CHEAT
Definition at line 144 of file command.cpp.
References CMDPL_ALL_ACTIONS, CMDPL_NO_ACTIONS, CMDPL_NO_CONSTRUCTION, CMDPL_NO_LANDSCAPING, CMDT_END, IsValidCommand(), and lengthof.
Referenced by DistributeQueue(), and CommandHelperBase::InternalPostBefore().
bool IsValidCommand | ( | Commands | cmd | ) |
This function range-checks a cmd.
cmd | The integer value of a command |
Definition at line 106 of file command.cpp.
References _command_proc_table.
Referenced by GetCommandFlags(), GetCommandName(), and IsCommandAllowedWhilePaused().
void NetworkSendCommand | ( | Commands | cmd, |
StringID | err_message, | ||
CommandCallback * | callback, | ||
CompanyID | company, | ||
const CommandDataBuffer & | cmd_data | ||
) |
Prepare a DoCommand to be send over the network.
cmd | The command to execute (a CMD_* value) |
err_message | Message prefix to show on error |
callback | A callback function to call after the command is finished |
company | The company that wants to send the command |
cmd_data | The command proc arguments. |
Definition at line 196 of file network_command.cpp.
References _frame_counter_max, _local_wait_queue, _network_server, CommandPacket::callback, CommandPacket::cmd, CommandPacket::company, CommandPacket::data, CommandPacket::err_msg, CommandPacket::frame, CommandPacket::my_cmd, and ClientNetworkGameSocketHandler::SendCommand().
Referenced by CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true >::SendNet().
|
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 28 of file command_func.h.
Referenced by AddEngineReplacement(), BuildStationPart(), CheckBridgeAvailability(), CheckRoadSlope(), CmdAddSharedVehicleGroup(), CmdAlterGroup(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildIndustry(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildObjectArea(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdBuildVehicle(), CmdBuyCompany(), CmdChangeBankBalance(), CmdChangeCompanySetting(), CmdChangeSetting(), CmdClearArea(), CmdCloneOrder(), CmdCloneVehicle(), CmdCompanyAllowListCtrl(), CmdCompanyCtrl(), CmdConvertRail(), CmdConvertRoad(), CmdCreateGoal(), CmdCreateGroup(), CmdCreateLeagueTable(), CmdCreateLeagueTableElement(), CmdCreateStoryPage(), CmdCreateStoryPageElement(), CmdCreateSubsidy(), CmdCustomNewsItem(), CmdDecreaseLoan(), CmdDeleteGroup(), CmdDeleteOrder(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdEngineCtrl(), CmdForceTrainProceed(), CmdFoundTown(), CmdGiveMoney(), CmdIncreaseLoan(), CmdIndustrySetExclusivity(), CmdIndustrySetFlags(), CmdIndustrySetProduction(), CmdIndustrySetText(), CmdInsertOrder(), CmdLevelLand(), CmdMassStartStopVehicle(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdPause(), CmdPlaceSign(), CmdPlantTree(), CmdRefitVehicle(), CmdRemoveAllVehiclesGroup(), CmdRemoveFromRailStation(), CmdRemoveFromRailWaypoint(), CmdRemoveFromRoadWaypoint(), CmdRemoveGoal(), CmdRemoveLeagueTableElement(), CmdRemoveLongRoad(), CmdRemoveRoadStop(), CmdRemoveStoryPage(), CmdRemoveStoryPageElement(), CmdRenameCompany(), CmdRenameDepot(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdScrollViewport(), CmdSellVehicle(), CmdSendVehicleToDepot(), CmdSetAutoReplace(), CmdSetCompanyManagerFace(), CmdSetCompanyMaxLoan(), CmdSetGoalCompleted(), CmdSetGoalDestination(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetGroupFlag(), CmdSetGroupLivery(), CmdSetStoryPageDate(), CmdSetStoryPageTitle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSetVehicleVisibility(), CmdShowStoryPage(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdStoryPageButton(), CmdTownCargoGoal(), CmdTownRating(), CmdTownSetText(), CmdTurnRoadVeh(), CmdUpdateLeagueTableElementData(), CmdUpdateLeagueTableElementScore(), CmdUpdateStoryPageElement(), CmdWantEnginePreview(), CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true >::Do(), IsRoadAllowedHere(), RemoveDock(), RemoveEngineReplacement(), SendAllVehiclesToDepot(), Vehicle::SendToDepot(), TerraformTileHeight(), TownActionBuyRights(), TownActionFundBuildings(), and TownActionRoadRebuild().