|
OpenTTD Source
13.2.1
|
#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... | |
| struct | CommandHelper< TCmd, T, THasTile > |
| 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) |
| CommandFlags | GetCommandFlags (Commands cmd) |
| const char * | GetCommandName (Commands cmd) |
| Money | GetAvailableMoneyForCommand () |
| 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 59 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 PlaceAirport(), and ShowBuildBridgeWindow().
| Money GetAvailableMoneyForCommand | ( | ) |
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.
Definition at line 173 of file command.cpp.
References _current_company, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID().
Referenced by CmdBuildObjectArea(), CmdClearArea(), CmdLevelLand(), and CmdRemoveLongRoad().
| 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 120 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 134 of file command.cpp.
References _command_proc_table, and IsValidCommand().
Referenced by CommandHelperBase::LogCommandExecution(), and ServerNetworkAdminSocketHandler::SendCmdNames().
| 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 146 of file command.cpp.
References CMDPL_ALL_ACTIONS, CMDPL_NO_ACTIONS, CMDPL_NO_CONSTRUCTION, CMDPL_NO_LANDSCAPING, CMDT_END, IsValidCommand(), and lengthof.
Referenced by CommandHelperBase::InternalPostBefore(), CommandQueue::Peek(), and CommandQueue::Pop().
| bool IsValidCommand | ( | Commands | cmd | ) |
This function range-checks a cmd.
| cmd | The integer value of a command |
Definition at line 108 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 266 of file network_command.cpp.
References _frame_counter_max, _local_wait_queue, _network_server, CommandQueue::Append(), 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(), CmdBuildRailStation(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildShipDepot(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdBuildVehicle(), CmdBulkChangeTimetable(), CmdBuyCompany(), CmdBuyShareInCompany(), CmdChangeBankBalance(), CmdChangeCompanySetting(), CmdChangeServiceInt(), CmdChangeSetting(), CmdChangeTimetable(), CmdClearArea(), CmdCloneOrder(), CmdCloneVehicle(), CmdCompanyCtrl(), CmdConvertRail(), CmdConvertRoad(), CmdCreateGoal(), CmdCreateGroup(), CmdCreateLeagueTable(), CmdCreateLeagueTableElement(), CmdCreateStoryPage(), CmdCreateStoryPageElement(), CmdCreateSubsidy(), CmdCustomNewsItem(), CmdDecreaseLoan(), CmdDeleteGroup(), CmdDeleteOrder(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdEngineCtrl(), CmdForceTrainProceed(), CmdFoundTown(), CmdGiveMoney(), CmdGoalQuestionAnswer(), CmdIndustryCtrl(), CmdInsertOrder(), CmdLevelLand(), CmdMassStartStopVehicle(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdPause(), CmdPlaceSign(), CmdPlantTree(), CmdRefitVehicle(), CmdRemoveAllVehiclesGroup(), CmdRemoveFromRailStation(), CmdRemoveFromRailWaypoint(), CmdRemoveGoal(), CmdRemoveLeagueTableElement(), CmdRemoveLongRoad(), CmdRemoveRoadStop(), CmdRemoveStoryPage(), CmdRemoveStoryPageElement(), CmdRenameCompany(), CmdRenameDepot(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdScrollViewport(), CmdSellShareInCompany(), CmdSellVehicle(), CmdSendVehicleToDepot(), CmdSetAutoReplace(), CmdSetCompanyManagerFace(), CmdSetGoalCompleted(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetGroupFlag(), CmdSetGroupLivery(), CmdSetStoryPageDate(), CmdSetStoryPageTitle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSetVehicleVisibility(), CmdShowStoryPage(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdStoryPageButton(), CmdTownCargoGoal(), CmdTownGrowthRate(), CmdTownRating(), CmdTownSetText(), CmdTurnRoadVeh(), CmdUpdateLeagueTableElementData(), CmdUpdateLeagueTableElementScore(), CmdUpdateStoryPageElement(), CmdWantEnginePreview(), CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true >::Do(), RemoveDock(), RemoveEngineReplacement(), SendAllVehiclesToDepot(), Vehicle::SendToDepot(), and TerraformTileHeight().