OpenTTD Source  12.0-beta2
console_func.h File Reference
#include "console_type.h"
#include "3rdparty/fmt/format.h"

Go to the source code of this file.

Functions

void IConsoleInit ()
 
void IConsoleFree ()
 
void IConsoleClose ()
 Close the in-game console.
 
void IConsolePrint (TextColour colour_code, const std::string &string)
 Handle the printing of text entered into the console or redirected there by any other means. More...
 
template<typename T , typename A , typename ... Args>
static void IConsolePrint (TextColour colour_code, const T &format, A first_arg, Args &&... other_args)
 Handle the printing of text entered into the console or redirected there by any other means. More...
 
void IConsoleCmdExec (const char *cmdstr, const uint recurse_count=0)
 Execute a given command passed to us. More...
 
bool IsValidConsoleColour (TextColour c)
 Check whether the given TextColour is valid for console usage. More...
 

Variables

IConsoleModes _iconsole_mode
 

Detailed Description

Console functions used outside of the console code.

Definition in file console_func.h.

Function Documentation

◆ IConsoleCmdExec()

void IConsoleCmdExec ( const char *  cmdstr,
const uint  recurse_count 
)

Execute a given command passed to us.

First chop it up into individual tokens (separated by spaces), then execute it if possible

Parameters
cmdstrstring to be parsed and executed

Definition at line 302 of file console.cpp.

References IConsole::AliasGet(), CC_ERROR, CHR_ALLOW, CHR_DISALLOW, CHR_HIDE, IConsole::CmdGet(), CS_ALPHANUMERAL, Debug, IConsoleCmd::hook, ICON_MAX_STREAMSIZE, ICON_TOKEN_COUNT, IConsoleAliasExec(), IConsolePrint(), IsValidChar(), lengthof, IConsoleCmd::proc, and StrEmpty().

Referenced by IConsoleAliasExec(), TCPClientConnecter::OnConnect(), and OnStartGame().

◆ IConsolePrint() [1/2]

void IConsolePrint ( TextColour  colour_code,
const std::string &  string 
)

Handle the printing of text entered into the console or redirected there by any other means.

Text can be redirected to other clients in a network game as well as to a logfile. If the network server is a dedicated server, all activities are also logged. All lines to print are added to a temporary buffer which can be used as a history to print them onscreen

Parameters
colour_codeThe colour of the command.
stringThe message to output on the console (notice, error, etc.)

Definition at line 94 of file console.cpp.

References _redirect_console_to_admin, _redirect_console_to_client, INVALID_ADMIN_ID, INVALID_CLIENT_ID, IsValidConsoleColour(), NetworkServerSendAdminRcon(), NetworkServerSendRcon(), str_strip_colours(), and stredup().

Referenced by IConsole::AliasRegister(), ConPrintFramerate(), DEF_CONSOLE_CMD(), DEF_CONSOLE_HOOK(), IConsoleAliasExec(), IConsoleCmdExec(), IConsoleGetSetting(), IConsoleListSettings(), NetworkAutoCleanCompanies(), NetworkAvailable(), NetworkPrintClients(), ConsoleContentCallback::OnConnect(), ConsoleContentCallback::OnDisconnect(), ConsoleContentCallback::OnDownloadComplete(), OutputContentState(), PrintLineByLine(), ClientNetworkGameSocketHandler::Receive_SERVER_COMMAND(), and ClientNetworkGameSocketHandler::Receive_SERVER_RCON().

◆ IConsolePrint() [2/2]

template<typename T , typename A , typename ... Args>
static void IConsolePrint ( TextColour  colour_code,
const T &  format,
first_arg,
Args &&...  other_args 
)
inlinestatic

Handle the printing of text entered into the console or redirected there by any other means.

Text can be redirected to other clients in a network game as well as to a logfile. If the network server is a dedicated server, all activities are also logged. All lines to print are added to a temporary buffer which can be used as a history to print them onscreen

Parameters
colour_codeThe colour of the command.
format_stringThe formatting string to tell what to do with the remaining arguments.
first_argThe first argument to the format.
other_argsThe other arguments to the format.
Template Parameters
TThe type of formatting parameter.
AThe type of the first argument.
ArgsThe types of the other arguments.

Definition at line 42 of file console_func.h.

◆ IsValidConsoleColour()

bool IsValidConsoleColour ( TextColour  c)

Check whether the given TextColour is valid for console usage.

Parameters
cThe text colour to compare to.
Returns
true iff the TextColour is valid for console usage.

Definition at line 524 of file console_gui.cpp.

References TC_IS_PALETTE_COLOUR.

Referenced by IConsolePrint(), and ClientNetworkGameSocketHandler::Receive_SERVER_RCON().