OpenTTD Source 20241224-master-gf74b0cf984
CommandHelperBase Class Reference
Inheritance diagram for CommandHelperBase:
CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true > CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false >

Static Protected Member Functions

static void InternalDoBefore (bool top_level, bool test)
 Prepare for calling a command proc.
 
static void InternalDoAfter (CommandCost &res, DoCommandFlag 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 (const 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,
DoCommandFlag  flags,
bool  top_level,
bool  test 
)
staticprotected

Process result after calling a command proc.

Parameters
[in,out]resCommand result, may be modified.
flagsCommand flags.
top_levelTop level of command execution, i.e. command from a command.
testTest run of command?

Definition at line 182 of file command.cpp.

References CheckCompanyHasMoney(), DC_BANKRUPT, DC_QUERY_COST, SetTownRatingTestMode(), SubtractMoneyFromCompany(), and CommandCost::Succeeded().

◆ InternalDoBefore()

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

Prepare for calling a command proc.

Parameters
top_levelTop level of command execution, i.e. command from a command.
testTest 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_flagsCommand flags.
[in,out]cur_companyBackup of current company at start of command execution.
Returns
True if test run can go ahead, false on error.

Definition at line 271 of file command.cpp.

References _current_company, Backup< T >::Change(), CMD_DEITY, CMD_SERVER, CMD_SPECTATOR, COMPANY_SPECTATOR, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), OWNER_DEITY, PSM_ENTER_TESTMODE, SetTownRatingTestMode(), and BasePersistentStorageArray::SwitchMode().

◆ 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
cmdCommand that was executed.
cmd_flagsCommand flags.
res_testCommand result of test run.
tes_execCommand result of real run.
extra_cashAdditional cash required for successful command execution.
tileTile of command execution.
[in,out]cur_companyBackup of current company at start of command execution.
Returns
Final command result.

Definition at line 341 of file command.cpp.

References _command_proc_table, _current_company, _local_company, _pause_mode, CMD_COMPANY_CTRL, CMD_NO_TEST, CMD_SERVER, CMD_SPECTATOR, CMDT_SERVER_SETTING, COMPANY_SPECTATOR, CommandCost::Failed(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), CompanyProperties::last_build_coordinate, PM_COMMAND_DURING_PAUSE, PM_UNPAUSED, PSM_LEAVE_COMMAND, Backup< T >::Restore(), SetDParam(), SubtractMoneyFromCompany(), BasePersistentStorageArray::SwitchMode(), 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_flagsCommand flags.
[in,out]resCommand result of test run, may be modified.
estimate_onlyIs this just cost estimation?
network_commandDoes this command come from the network?
[in,out]cur_companyBackup of current company at start of command execution.
Returns
True if test run can go ahead, false on error.

Definition at line 301 of file command.cpp.

References _current_company, _generating_world, _networking, CheckCompanyHasMoney(), CMD_NO_TEST, CMD_SERVER, CMD_SPECTATOR, COMPANY_SPECTATOR, CommandCost::Failed(), PSM_ENTER_COMMAND, PSM_LEAVE_TESTMODE, SetTownRatingTestMode(), and BasePersistentStorageArray::SwitchMode().

◆ 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
cmdCommand to execute.
flagsCommand flags.
tileTile of command execution.
err_messageMessage prefix to show on error.
network_commandDoes 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, CMD_NO_EST, IsCommandAllowedWhilePaused(), IsLocalCompany(), PM_UNPAUSED, ShowErrorMessage(), TILE_SIZE, TileX(), TileY(), and WL_INFO.

◆ InternalPostResult()

void CommandHelperBase::InternalPostResult ( const 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
resCommand result.
tileTile of command execution.
estimate_onlyIs this just cost estimation?
only_sendingWas the command only sent to network?
err_messageMessage prefix to show on error.
my_cmdIs the command from this client?

Definition at line 237 of file command.cpp.

References CommandCost::Failed(), CommandCost::GetCost(), 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 260 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: