OpenTTD Source  20240917-master-g9ab0a47812
CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false > Struct Template Reference

Overload for CommandHelper that exposes additional Post variants for commands that don't take a TileIndex themselves. More...

#include <command_func.h>

Inheritance diagram for CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false >:
CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true > CommandHelperBase

Static Public Member Functions

static bool Post (StringID err_message, Targs... args)=delete
 
template<typename Tcallback >
static bool Post (Tcallback *callback, Targs... args)=delete
 
static bool Post (Targs... args)=delete
 
template<typename Tcallback >
static bool Post (StringID err_message, Tcallback *callback, Targs... args)=delete
 
static bool Post (StringID err_message, TileIndex location, Targs... args)
 Shortcut for Post when not using a callback. More...
 
template<typename Tcallback >
static bool Post (Tcallback *callback, TileIndex location, Targs... args)
 Shortcut for Post when not using an error message. More...
 
static bool Post (TileIndex location, Targs... args)
 Shortcut for Post when not using a callback or an error message. More...
 
template<typename Tcallback >
static bool Post (StringID err_message, Tcallback *callback, TileIndex location, Targs... args)
 Post variant that takes a TileIndex (for error window location and text effects) for commands that don't take a TileIndex by themselves. More...
 
- Static Public Member Functions inherited from CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true >
static Tret Do (DoCommandFlag flags, Targs... args)
 This function executes a given command with the parameters from the #CommandProc parameter list. More...
 
static bool Post (StringID err_message, Targs... args)
 Shortcut for the long Post when not using a callback. More...
 
template<typename Tcallback >
static bool Post (Tcallback *callback, Targs... args)
 Shortcut for the long Post when not using an error message. More...
 
static bool Post (Targs... args)
 Shortcut for the long Post when not using a callback or an error message. More...
 
template<typename Tcallback >
static bool Post (StringID err_message, Tcallback *callback, Targs... args)
 Top-level network safe command execution for the current company. More...
 
template<typename Tcallback >
static bool PostFromNet (StringID err_message, Tcallback *callback, bool my_cmd, std::tuple< Targs... > args)
 Execute a command coming from the network. More...
 
static void SendNet (StringID err_message, CompanyID company, Targs... args)
 Prepare a command to be send over the network. More...
 
template<typename Tcallback >
static Tret Unsafe (StringID err_message, Tcallback *callback, bool my_cmd, bool estimate_only, TileIndex location, std::tuple< Targs... > args)
 Top-level network safe command execution without safety checks. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true >
template<class T >
static void SetClientIdHelper ([[maybe_unused]] T &data)
 Helper to process a single ClientID argument.
 
template<class Ttuple , size_t... Tindices>
static void SetClientIds (Ttuple &values, std::index_sequence< Tindices... >)
 Set all invalid ClientID's to the proper value.
 
template<template< typename... > typename Tt, typename T1 , typename... Ts>
static Tt< Ts... > RemoveFirstTupleElement (const Tt< T1, Ts... > &tuple)
 Remove the first element of a tuple.
 
template<typename Tcallback >
static bool InternalPost (StringID err_message, Tcallback *callback, bool my_cmd, bool network_command, std::tuple< Targs... > args)
 
template<typename Tcallback >
static bool InternalPost (StringID err_message, Tcallback *callback, bool my_cmd, bool network_command, TileIndex tile, std::tuple< Targs... > args)
 
template<class T >
static bool ClientIdIsSet ([[maybe_unused]] T &data)
 Helper to process a single ClientID argument.
 
template<class Ttuple , size_t... Tindices>
static bool AllClientIdsSet (Ttuple &values, std::index_sequence< Tindices... >)
 Check if all ClientID arguments are set to valid values.
 
template<class Ttuple >
static Money ExtractAdditionalMoney ([[maybe_unused]] Ttuple &values)
 
static Tret Execute (StringID err_message, CommandCallback *callback, bool, bool estimate_only, bool network_command, TileIndex tile, std::tuple< Targs... > args)
 
- Static Protected Member Functions inherited from CommandHelperBase
static void InternalDoBefore (bool top_level, bool test)
 Prepare for calling a command proc. More...
 
static void InternalDoAfter (CommandCost &res, DoCommandFlag flags, bool top_level, bool test)
 Process result after calling a command proc. More...
 
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. More...
 
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. More...
 
static bool InternalExecutePrepTest (CommandFlags cmd_flags, TileIndex tile, Backup< CompanyID > &cur_company)
 Prepare for the test run of a command proc call. More...
 
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. More...
 
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. More...
 
static void LogCommandExecution (Commands cmd, StringID err_message, const CommandDataBuffer &args, bool failed)
 Helper to make a desync log for a command.
 

Detailed Description

template<Commands Tcmd, typename Tret, typename... Targs>
struct CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false >

Overload for CommandHelper that exposes additional Post variants for commands that don't take a TileIndex themselves.

Template Parameters
TcmdThe command-id to execute.
TretReturn type of the command.
TargsThe command parameter types.

Definition at line 434 of file command_func.h.

Member Function Documentation

◆ Post() [1/4]

template<Commands Tcmd, typename Tret , typename... Targs>
template<typename Tcallback >
static bool CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false >::Post ( StringID  err_message,
Tcallback *  callback,
TileIndex  location,
Targs...  args 
)
inlinestatic

Post variant that takes a TileIndex (for error window location and text effects) for commands that don't take a TileIndex by themselves.

Parameters
err_messageMessage prefix to show on error
callbackA callback function to call after the command is finished
argsParameters for the command
Returns
true if the command succeeded, else false.

Definition at line 475 of file command_func.h.

◆ Post() [2/4]

template<Commands Tcmd, typename Tret , typename... Targs>
static bool CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false >::Post ( StringID  err_message,
TileIndex  location,
Targs...  args 
)
inlinestatic

Shortcut for Post when not using a callback.

Parameters
err_messageMessage prefix to show on error
locationTile location for user feedback.
argsParameters for the command

Definition at line 450 of file command_func.h.

◆ Post() [3/4]

template<Commands Tcmd, typename Tret , typename... Targs>
template<typename Tcallback >
static bool CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false >::Post ( Tcallback *  callback,
TileIndex  location,
Targs...  args 
)
inlinestatic

Shortcut for Post when not using an error message.

Parameters
callbackA callback function to call after the command is finished
locationTile location for user feedback.
argsParameters for the command

Definition at line 458 of file command_func.h.

References Post().

Referenced by Post().

◆ Post() [4/4]

template<Commands Tcmd, typename Tret , typename... Targs>
static bool CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), false >::Post ( TileIndex  location,
Targs...  args 
)
inlinestatic

Shortcut for Post when not using a callback or an error message.

Parameters
locationTile location for user feedback.
argsParameters for the command*

Definition at line 464 of file command_func.h.


The documentation for this struct was generated from the following file: