OpenTTD Source 20241224-master-gf74b0cf984
|
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... | |
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. | |
bool | IsValidCommand (Commands cmd) |
This function range-checks a cmd. | |
CommandFlags | GetCommandFlags (Commands cmd) |
This function mask the parameter with CMD_ID_MASK and returns the flags which belongs to the given command. | |
const char * | GetCommandName (Commands cmd) |
This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given command. | |
bool | IsCommandAllowedWhilePaused (Commands cmd) |
Returns whether the command is allowed while the game is paused. | |
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. | |
Variables | |
static const CommandCost | CMD_ERROR = CommandCost(INVALID_STRING_ID) |
Define a default return value for a failed command. | |
Functions related to commands.
Definition in file command_func.h.
using Command = CommandHelper<Tcmd, typename CommandTraits<Tcmd>::ProcType, (GetCommandFlags<Tcmd>() & CMD_LOCATION) == 0> |
Definition at line 476 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 48 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(), BuildRailToolbarWindow::OnPlaceMouseUp(), BuildRoadToolbarWindow::OnPlaceMouseUp(), BuildDocksToolbarWindow::OnPlaceObject(), PlaceAirport(), PlaceRail_Station(), PlaceRoadStop(), and ShowBuildBridgeWindow().
|
constexpr |
Definition at line 38 of file command_func.h.
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, GetCommandFlags(), and IsValidCommand().
Referenced by GetCommandFlags(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(), and NetworkGameSocketHandler::ReceiveCommand().
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(), 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 144 of file command.cpp.
References _command_proc_table, _settings_game, CMDPL_ALL_ACTIONS, CMDPL_NO_ACTIONS, CMDPL_NO_CONSTRUCTION, CMDPL_NO_LANDSCAPING, CMDT_END, ConstructionSettings::command_pause_level, GameSettings::construction, 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(), IsCommandAllowedWhilePaused(), and NetworkGameSocketHandler::ReceiveCommand().
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(), CheckBridgeSlope(), CheckRoadSlope(), ClearTile_Station(), ClearTile_Town(), CmdAddSharedVehicleGroup(), CmdAddVehicleGroup(), CmdAlterGroup(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdBuildAircraft(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildDock(), CmdBuildIndustry(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildObjectArea(), CmdBuildRailStation(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdBuildVehicle(), CmdBulkChangeTimetable(), CmdBuyCompany(), CmdChangeBankBalance(), CmdChangeCompanySetting(), CmdChangeServiceInt(), CmdChangeSetting(), CmdChangeTimetable(), CmdClearArea(), CmdCloneOrder(), CmdCloneVehicle(), CmdCompanyAllowListCtrl(), CmdCompanyCtrl(), CmdConvertRail(), CmdConvertRoad(), CmdCreateGoal(), CmdCreateGroup(), CmdCreateLeagueTable(), CmdCreateLeagueTableElement(), CmdCreateStoryPage(), CmdCreateStoryPageElement(), CmdCreateSubsidy(), CmdCustomNewsItem(), CmdDecreaseLoan(), CmdDeleteGroup(), CmdDeleteOrder(), CmdDeleteTown(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdDoTownAction(), CmdEngineCtrl(), CmdExpandTown(), CmdForceTrainProceed(), CmdFoundTown(), CmdGiveMoney(), CmdGoalQuestion(), CmdGoalQuestionAnswer(), CmdIncreaseLoan(), CmdIndustrySetExclusivity(), CmdIndustrySetFlags(), CmdIndustrySetProduction(), CmdIndustrySetText(), CmdInsertOrder(), CmdLevelLand(), CmdMassStartStopVehicle(), CmdModifyOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdPause(), CmdPlaceSign(), CmdPlantTree(), CmdRailTrackHelper(), CmdRefitVehicle(), CmdRemoveAllVehiclesGroup(), CmdRemoveFromRailStation(), CmdRemoveFromRailWaypoint(), CmdRemoveFromRoadWaypoint(), CmdRemoveGoal(), CmdRemoveLeagueTableElement(), CmdRemoveLongRoad(), CmdRemoveRoadStop(), CmdRemoveSingleRail(), CmdRemoveStoryPage(), CmdRemoveStoryPageElement(), CmdRenameCompany(), CmdRenameDepot(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdScrollViewport(), CmdSellVehicle(), CmdSendVehicleToDepot(), CmdSetAutoReplace(), CmdSetCompanyColour(), CmdSetCompanyManagerFace(), CmdSetCompanyMaxLoan(), CmdSetGoalCompleted(), CmdSetGoalDestination(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetGroupFlag(), CmdSetGroupLivery(), CmdSetStoryPageDate(), CmdSetStoryPageTitle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSetVehicleVisibility(), CmdShowStoryPage(), CmdSignalTrackHelper(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdStoryPageButton(), CmdTownCargoGoal(), CmdTownGrowthRate(), CmdTownRating(), CmdTownSetText(), CmdTurnRoadVeh(), CmdUpdateLeagueTableElementData(), CmdUpdateLeagueTableElementScore(), CmdUpdateStoryPageElement(), CmdWantEnginePreview(), CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true >::Do(), IsRoadAllowedHere(), RemoveDock(), RemoveEngineReplacement(), RemoveRoad(), SendAllVehiclesToDepot(), Vehicle::SendToDepot(), TerraformTileHeight(), TownActionBuyRights(), TownActionFundBuildings(), and TownActionRoadRebuild().