OpenTTD Source
20241121-master-g67a0fccfad
|
Handling of commands. More...
#include "stdafx.h"
#include "landscape.h"
#include "error.h"
#include "gui.h"
#include "command_func.h"
#include "network/network_type.h"
#include "network/network.h"
#include "genworld.h"
#include "strings_func.h"
#include "texteff.hpp"
#include "town.h"
#include "timer/timer_game_economy.h"
#include "company_func.h"
#include "company_base.h"
#include "signal_func.h"
#include "core/backup_type.hpp"
#include "object_base.h"
#include "autoreplace_cmd.h"
#include "company_cmd.h"
#include "depot_cmd.h"
#include "economy_cmd.h"
#include "engine_cmd.h"
#include "goal_cmd.h"
#include "group_cmd.h"
#include "industry_cmd.h"
#include "league_cmd.h"
#include "landscape_cmd.h"
#include "misc_cmd.h"
#include "news_cmd.h"
#include "object_cmd.h"
#include "order_cmd.h"
#include "rail_cmd.h"
#include "road_cmd.h"
#include "roadveh_cmd.h"
#include "settings_cmd.h"
#include "signs_cmd.h"
#include "station_cmd.h"
#include "story_cmd.h"
#include "subsidy_cmd.h"
#include "terraform_cmd.h"
#include "timetable_cmd.h"
#include "town_cmd.h"
#include "train_cmd.h"
#include "tree_cmd.h"
#include "tunnelbridge_cmd.h"
#include "vehicle_cmd.h"
#include "viewport_cmd.h"
#include "water_cmd.h"
#include "waypoint_cmd.h"
#include "misc/endian_buffer.hpp"
#include "string_func.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | CommandInfo |
Define a command with the flags which belongs to it. More... | |
Functions | |
template<typename T > | |
constexpr CommandInfo | CommandFromTrait () noexcept |
template<typename T , T... i> | |
constexpr auto | MakeCommandsFromTraits (std::integer_sequence< T, i... >) noexcept |
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... | |
Variables | |
static constexpr auto | _command_proc_table = MakeCommandsFromTraits(std::make_integer_sequence<std::underlying_type_t<Commands>, CMD_END>{}) |
The master command table. More... | |
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().
|
staticconstexpr |
The master command table.
This table contains all possible CommandProc functions with the flags which belongs to it. The indices are the same as the value from the CMD_* enums.
Definition at line 97 of file command.cpp.
Referenced by GetCommandFlags(), GetCommandName(), CommandHelperBase::InternalExecuteProcessResult(), and IsValidCommand().