OpenTTD Source 20250521-master-g82876c25e0
|
Handling of the in-game console. More...
#include "stdafx.h"
#include "core/string_builder.hpp"
#include "core/string_consumer.hpp"
#include "console_internal.h"
#include "network/network.h"
#include "network/network_func.h"
#include "network/network_admin.h"
#include "debug.h"
#include "console_func.h"
#include "settings_type.h"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
void | IConsoleInit () |
static void | IConsoleWriteToLogFile (const std::string &string) |
bool | CloseConsoleLogIfActive () |
void | IConsoleFree () |
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. | |
static std::string | RemoveUnderscores (std::string name) |
Creates a copy of a string with underscores removed from it. | |
static void | IConsoleAliasExec (const IConsoleAlias *alias, std::span< std::string > tokens, uint recurse_count) |
An alias is just another name for a command, or for more commands Execute it as well. | |
void | IConsoleCmdExec (std::string_view command_string, const uint recurse_count) |
Execute a given command passed to us. | |
Variables | |
static const uint | ICON_MAX_RECURSE = 10 |
Maximum number of recursion. | |
std::optional< FileHandle > | _iconsole_output_file |
Handling of the in-game console.
Definition in file console.cpp.
bool CloseConsoleLogIfActive | ( | ) |
Definition at line 64 of file console.cpp.
|
static |
An alias is just another name for a command, or for more commands Execute it as well.
alias | is the alias of the command |
tokens | are the parameters given to the original command (0 is the first param) |
recurse_count | the number of re-entrant calls to this function |
Definition at line 184 of file console.cpp.
References CC_ERROR, CC_HELP, IConsoleAlias::cmdline, Debug, ICON_MAX_RECURSE, IConsoleCmdExec(), IConsolePrint(), and IConsoleAlias::name.
Referenced by IConsoleCmdExec().
void IConsoleCmdExec | ( | std::string_view | 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
command_string | string to be parsed and executed |
Definition at line 269 of file console.cpp.
References IConsole::AliasGet(), CC_ERROR, CHR_ALLOW, CHR_DISALLOW, CHR_HIDE, IConsole::CmdGet(), Debug, IConsoleCmd::hook, IConsoleAliasExec(), IConsolePrint(), IConsoleCmd::proc, and StringConsumer::TryReadUtf8().
Referenced by IConsoleAliasExec(), TCPClientConnecter::OnConnect(), IConsoleWindow::OnKeyPress(), AfterNewGRFScan::OnNewGRFsScanned(), OnStartGame(), ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(), ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(), and ServerNetworkGameSocketHandler::Receive_CLIENT_RCON().
void IConsoleFree | ( | ) |
Definition at line 75 of file console.cpp.
void IConsoleInit | ( | ) |
Definition at line 40 of file console.cpp.
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
colour_code | The colour of the command. |
string | The message to output on the console (notice, error, etc.) |
Definition at line 90 of file console.cpp.
References _network_dedicated, _redirect_console_to_admin, _redirect_console_to_client, GetLogPrefix(), IConsoleGUIPrint(), INVALID_CLIENT_ID, IsValidConsoleColour(), NetworkAdminConsole(), NetworkServerSendAdminRcon(), NetworkServerSendRcon(), and StrMakeValid().
Referenced by IConsole::AliasRegister(), ConHookClientOnly(), ConHookNeedNetwork(), ConHookNeedNonDedicatedNetwork(), ConHookNoNetwork(), ConHookServerOnly(), ConHookServerOrNoNetwork(), ConListDirs(), ConPrintFramerate(), ConResetEnginePool(), ConResetEngines(), ConSave(), ConSaveConfig(), ConScrollToTile(), ConZoomToLevel(), DebugSendRemoteMessages(), IConsoleAliasExec(), IConsoleCmdExec(), IConsoleGetSetting(), IConsoleListSettings(), IConsolePrint(), NetworkAutoCleanCompanies(), NetworkAvailable(), NetworkPrintClients(), NetworkServer_Tick(), NetworkServerShowStatusToConsole(), ConsoleContentCallback::OnConnect(), ConsoleContentCallback::OnDisconnect(), ConsoleContentCallback::OnDownloadComplete(), IConsoleWindow::OnKeyPress(), OutputContentState(), Gamelog::PrintConsole(), PrintLineByLine(), ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(), ClientNetworkGameSocketHandler::Receive_SERVER_COMMAND(), ClientNetworkGameSocketHandler::Receive_SERVER_RCON(), and ShowErrorMessage().
|
static |
Definition at line 51 of file console.cpp.
|
static |
Creates a copy of a string with underscores removed from it.
name | String to remove the underscores from. |
Definition at line 126 of file console.cpp.
Referenced by IConsole::AliasGet(), IConsole::AliasRegister(), IConsole::CmdGet(), and IConsole::CmdRegister().
std::optional<FileHandle> _iconsole_output_file |
Definition at line 38 of file console.cpp.
|
static |
Maximum number of recursion.
Definition at line 23 of file console.cpp.
Referenced by IConsoleAliasExec().