OpenTTD Source: src/console.cpp File Reference

OpenTTD Source 12.0-beta1

Functions | Variables
console.cpp File Reference
`#include "stdafx.h"`
`#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 <stdarg.h>`
`#include "safeguards.h"`

Go to the source code of this file.

## Functions
void | IConsoleInit ()
static void | IConsoleWriteToLogFile (const char *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. More...
bool | GetArgumentInteger (uint32 *value, const char *arg)
| Change a string into its number representation. More...
static std::string | RemoveUnderscores (std::string name)
| Creates a copy of a string with underscores removed from it. More...
static void | IConsoleAliasExec (const IConsoleAlias *alias, byte tokencount, char *tokens[ICON_TOKEN_COUNT], const uint recurse_count)
| An alias is just another name for a command, or for more commands Execute it as well. More...
void | IConsoleCmdExec (const char *cmdstr, const uint recurse_count)
| Execute a given command passed to us. More...

## Variables
static const uint | ICON_TOKEN_COUNT = 20
| Maximum number of tokens in one command.
static const uint | ICON_MAX_RECURSE = 10
| Maximum number of recursion.
FILE * | _iconsole_output_file

## Detailed Description

Handling of the in-game console.

Definition in file console.cpp.

## Function Documentation

## ◆ GetArgumentInteger()

bool GetArgumentInteger | ( | uint32 * | value,
|  | const char * | arg
| ) |  |

Change a string into its number representation.

Supports decimal and hexadecimal numbers as well as 'on'/'off' 'true'/'false'

Parameters

  *value | the variable a successful conversion will be put in
  *arg | the string to be converted

Returns
  Return true on success or false on failure

Definition at line 135 of file console.cpp.

Referenced by DEF_CONSOLE_CMD().

## ◆ IConsoleAliasExec()

static void IConsoleAliasExec | ( | const IConsoleAlias * | alias,
|  | byte | tokencount,
|  | char * | tokens[ICON_TOKEN_COUNT],
|  | const uint | recurse_count
| ) |  |
| static

An alias is just another name for a command, or for more commands Execute it as well.

Parameters

  *alias | is the alias of the command
  tokencount | the number of parameters passed
  *tokens | are the parameters given to the original command (0 is the first param)

Definition at line 215 of file console.cpp.

References CC_ERROR, CC_HELP, IConsoleAlias::cmdline, Debug, ICON_MAX_RECURSE, ICON_MAX_STREAMSIZE, IConsoleCmdExec(), IConsolePrint(), lastof, IConsoleAlias::name, and strecpy().

Referenced by IConsoleCmdExec().

## ◆ 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

  cmdstr | string 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()

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_code | The colour of the command.
  string | The 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().

## ◆ RemoveUnderscores()

static std::string RemoveUnderscores | ( | std::string | name | ) |
| static

Creates a copy of a string with underscores removed from it.

Parameters

  name | String to remove the underscores from.

Returns
  A copy of name, without underscores.

Definition at line 157 of file console.cpp.

References CompanyProperties::name.

Referenced by IConsole::AliasGet(), IConsole::AliasRegister(), and IConsole::CmdGet().