OpenTTD Source: CommandHelperBase Class Reference

OpenTTD Source 15.0-RC2

Static Protected Member Functions
CommandHelperBase Class Reference
Inheritance diagram for CommandHelperBase:

## Static Protected Member Functions
static void | InternalDoBefore (bool top_level, bool test)
| Prepare for calling a command proc.
static void | InternalDoAfter (CommandCost &res, DoCommandFlags flags, bool top_level, bool test)
| Process result after calling a command proc.
static std::tuple< bool, bool, bool > | InternalPostBefore (Commands cmd, CommandFlags flags, TileIndex tile, StringID err_message, bool network_command)
| Decide what to do with the command depending on current game state.
static void | InternalPostResult (CommandCost &res, TileIndex tile, bool estimate_only, bool only_sending, StringID err_message, bool my_cmd)
| Process result of executing a command, possibly displaying any error to the player.
static bool | InternalExecutePrepTest (CommandFlags cmd_flags, TileIndex tile, Backup< CompanyID > &cur_company)
| Prepare for the test run of a command proc call.
static std::tuple< bool, bool, bool > | InternalExecuteValidateTestAndPrepExec (CommandCost &res, CommandFlags cmd_flags, bool estimate_only, bool network_command, Backup< CompanyID > &cur_company)
| Validate result of test run and prepare for real execution.
static CommandCost | InternalExecuteProcessResult (Commands cmd, CommandFlags cmd_flags, const CommandCost &res_test, const CommandCost &res_exec, Money extra_cash, TileIndex tile, Backup< CompanyID > &cur_company)
| Process the result of a command test run and execution run.
static void | LogCommandExecution (Commands cmd, StringID err_message, const CommandDataBuffer &args, bool failed)
| Helper to make a desync log for a command.

## Detailed Description

Definition at line 85 of file command_func.h.

## Member Function Documentation

## ◆ InternalDoAfter()

void CommandHelperBase::InternalDoAfter | ( | CommandCost & | res,
|  | DoCommandFlags | flags,
|  | bool | top_level,
|  | bool | test
| ) |  |
| staticprotected

Process result after calling a command proc.

Parameters

  [in,out] | res | Command result, may be modified.
  | flags | Command flags.
  | top_level | Top level of command execution, i.e. command from a command.
  | test | Test run of command?

Definition at line 182 of file command.cpp.

References Bankrupt, CheckCompanyHasMoney(), QueryCost, SetTownRatingTestMode(), SubtractMoneyFromCompany(), CommandCost::Succeeded(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ InternalDoBefore()

void CommandHelperBase::InternalDoBefore | ( | bool | top_level,
|  | bool | test
| ) |  |
| staticprotected

Prepare for calling a command proc.

Parameters

  top_level | Top level of command execution, i.e. command from a command.
  test | Test run of command?

Definition at line 169 of file command.cpp.

References SetTownRatingTestMode().

## ◆ InternalExecutePrepTest()

bool CommandHelperBase::InternalExecutePrepTest | ( | CommandFlags | cmd_flags,
|  | TileIndex | tile,
|  | Backup< CompanyID > & | cur_company
| ) |  |
| staticprotected

Prepare for the test run of a command proc call.

Parameters

  | cmd_flags | Command flags.
  [in,out] | cur_company | Backup of current company at start of command execution.

Returns
  True if test run can go ahead, false on error.

Definition at line 272 of file command.cpp.

References _current_company, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Backup< T >::Change(), COMPANY_SPECTATOR, Deity, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), OWNER_DEITY, PSM_ENTER_TESTMODE, Server, SetTownRatingTestMode(), Spectator, BasePersistentStorageArray::SwitchMode(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ InternalExecuteProcessResult()

CommandCost CommandHelperBase::InternalExecuteProcessResult | ( | Commands | cmd,
|  | CommandFlags | cmd_flags,
|  | const CommandCost & | res_test,
|  | const CommandCost & | res_exec,
|  | Money | extra_cash,
|  | TileIndex | tile,
|  | Backup< CompanyID > & | cur_company
| ) |  |
| staticprotected

Process the result of a command test run and execution run.

Parameters

  | cmd | Command that was executed.
  | cmd_flags | Command flags.
  | res_test | Command result of test run.
  | tes_exec | Command result of real run.
  | extra_cash | Additional cash required for successful command execution.
  | tile | Tile of command execution.
  [in,out] | cur_company | Backup of current company at start of command execution.

Returns
  Final command result.

Definition at line 342 of file command.cpp.

References _command_proc_table, _current_company, _local_company, _pause_mode, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), CMD_COMPANY_CTRL, CommandCostWithParam(), CommandDuringPause, COMPANY_SPECTATOR, CommandCost::Failed(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), CompanyProperties::last_build_coordinate, NoTest, PSM_LEAVE_COMMAND, Backup< T >::Restore(), ServerSetting, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SubtractMoneyFromCompany(), BasePersistentStorageArray::SwitchMode(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Backup< T >::Trash(), UpdateSignalsInBuffer(), and Backup< T >::Verify().

## ◆ InternalExecuteValidateTestAndPrepExec()

std::tuple< bool, bool, bool > CommandHelperBase::InternalExecuteValidateTestAndPrepExec | ( | CommandCost & | res,
|  | CommandFlags | cmd_flags,
|  | bool | estimate_only,
|  | bool | network_command,
|  | Backup< CompanyID > & | cur_company
| ) |  |
| staticprotected

Validate result of test run and prepare for real execution.

Parameters

  | cmd_flags | Command flags.
  [in,out] | res | Command result of test run, may be modified.
  | estimate_only | Is this just cost estimation?
  | network_command | Does this command come from the network?
  [in,out] | cur_company | Backup of current company at start of command execution.

Returns
  True if test run can go ahead, false on error.

Definition at line 302 of file command.cpp.

References _current_company, _generating_world, _networking, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), CheckCompanyHasMoney(), COMPANY_SPECTATOR, CommandCost::Failed(), NoTest, PSM_ENTER_COMMAND, PSM_LEAVE_TESTMODE, SetTownRatingTestMode(), BasePersistentStorageArray::SwitchMode(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ InternalPostBefore()

std::tuple< bool, bool, bool > CommandHelperBase::InternalPostBefore | ( | Commands | cmd,
|  | CommandFlags | flags,
|  | TileIndex | tile,
|  | StringID | err_message,
|  | bool | network_command
| ) |  |
| staticprotected

Decide what to do with the command depending on current game state.

Parameters

  cmd | Command to execute.
  flags | Command flags.
  tile | Tile of command execution.
  err_message | Message prefix to show on error.
  network_command | Does this command come from the network?

Returns
  error state + do only cost estimation? + send to network only?

Definition at line 207 of file command.cpp.

References _generating_world, _networking, _pause_mode, _shift_pressed, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), GetEncodedString(), IsCommandAllowedWhilePaused(), IsLocalCompany(), NoEst, ShowErrorMessage(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TILE_SIZE, TileX(), TileY(), and WL_INFO.

## ◆ InternalPostResult()

void CommandHelperBase::InternalPostResult | ( | CommandCost & | res,
|  | TileIndex | tile,
|  | bool | estimate_only,
|  | bool | only_sending,
|  | StringID | err_message,
|  | bool | my_cmd
| ) |  |
| staticprotected

Process result of executing a command, possibly displaying any error to the player.

Parameters

  res | Command result.
  tile | Tile of command execution.
  estimate_only | Is this just cost estimation?
  only_sending | Was the command only sent to network?
  err_message | Message prefix to show on error.
  my_cmd | Is the command from this client?

Definition at line 238 of file command.cpp.

References CommandCost::Failed(), CommandCost::GetCost(), GetEncodedString(), GetSlopePixelZ(), IsLocalCompany(), ShowCostOrIncomeAnimation(), ShowErrorMessage(), ShowEstimatedCostOrIncome(), TILE_SIZE, TileX(), and TileY().

## ◆ LogCommandExecution()

void CommandHelperBase::LogCommandExecution | ( | Commands | cmd,
|  | StringID | err_message,
|  | const CommandDataBuffer & | args,
|  | bool | failed
| ) |  |
| staticprotected

Helper to make a desync log for a command.

Definition at line 261 of file command.cpp.

References _current_company, TimerGameEconomy::date, TimerGameEconomy::date_fract, Debug, FormatArrayAsHex(), and GetCommandName().

The documentation for this class was generated from the following files:

- src/command_func.h
- src/command.cpp