OpenTTD Source: src/command.cpp File Reference

OpenTTD Source 14.0-RC3

Data Structures | Functions | Variables
command.cpp File Reference
`#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...

## Detailed Description

Handling of commands.

Handling of NewGRF road stops.

Definition in file command.cpp.

## Function Documentation

## ◆ GetCommandFlags()

CommandFlags GetCommandFlags | ( | Commands | cmd | ) |

This function mask the parameter with CMD_ID_MASK and returns the flags which belongs to the given command.

Parameters

  cmd | The integer value of the command

Returns
  The flags for this command

Definition at line 118 of file command.cpp.

References _command_proc_table, and IsValidCommand().

## ◆ GetCommandName()

const char* GetCommandName | ( | Commands | cmd | ) |

This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given command.

Parameters

  cmd | The integer value of the command

Returns
  The name for this command

Definition at line 132 of file command.cpp.

References _command_proc_table, and IsValidCommand().

Referenced by CommandHelperBase::LogCommandExecution().

## ◆ IsCommandAllowedWhilePaused()

bool IsCommandAllowedWhilePaused | ( | Commands | cmd | ) |

Returns whether the command is allowed while the game is paused.

Parameters

  cmd | The command to check.

Returns
  True if the command is allowed while paused, false otherwise.

< 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().

## ◆ IsValidCommand()

bool IsValidCommand | ( | Commands | cmd | ) |

This function range-checks a cmd.

Parameters

  cmd | The integer value of a command

Returns
  true if the command is valid (and got a CommandProc function)

Definition at line 106 of file command.cpp.

References _command_proc_table.

Referenced by GetCommandFlags(), GetCommandName(), and IsCommandAllowedWhilePaused().

## Variable Documentation

## ◆ _command_proc_table

constexpr auto _command_proc_table = MakeCommandsFromTraits(std::make_integer_sequence<std::underlying_type_t<Commands>, CMD_END>{})
| 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().