OpenTTD Source  20240917-master-g9ab0a47812
console_func.h File Reference
#include "console_type.h"
#include "core/format.hpp"

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 A , typename ... Args>
void IConsolePrint (TextColour colour_code, fmt::format_string< A, Args... > 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 std::string &command_string, 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 std::string &  command_string,
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
command_stringstring to be parsed and executed

Definition at line 291 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(), 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 89 of file console.cpp.

References _network_dedicated, _redirect_console_to_admin, _redirect_console_to_client, GetLogPrefix(), INVALID_ADMIN_ID, INVALID_CLIENT_ID, IsValidConsoleColour(), NetworkAdminConsole(), NetworkServerSendAdminRcon(), NetworkServerSendRcon(), StrMakeValid(), and SVS_NONE.

Referenced by ConPrintFramerate(), DebugSendRemoteMessages(), DEF_CONSOLE_CMD(), DEF_CONSOLE_HOOK(), IConsoleAliasExec(), IConsoleCmdExec(), IConsoleGetSetting(), IConsoleListSettings(), NetworkAutoCleanCompanies(), NetworkAvailable(), NetworkPrintClients(), ConsoleContentCallback::OnDisconnect(), OutputContentState(), Gamelog::PrintConsole(), PrintLineByLine(), ClientNetworkGameSocketHandler::Receive_SERVER_COMMAND(), and ClientNetworkGameSocketHandler::Receive_SERVER_RCON().

◆ IConsolePrint() [2/2]

template<typename A , typename ... Args>
void IConsolePrint ( TextColour  colour_code,
fmt::format_string< A, Args... >  format,
first_arg,
Args &&...  other_args 
)
inline

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
AThe type of the first argument.
ArgsThe types of the other arguments.

Definition at line 41 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 541 of file console_gui.cpp.

References TC_IS_PALETTE_COLOUR.

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