OpenTTD Source: src/console_internal.h File Reference

OpenTTD Source 1.11.0-RC1

Data Structures | Typedefs | Enumerations | Functions | Variables
console_internal.h File Reference
`#include "gfx_type.h"`

Go to the source code of this file.

## Data Structures
struct | IConsoleCmd
struct | IConsoleAlias
| –Aliases– Aliases are like shortcuts for complex functions, variable assignments, etc. More...

## Typedefs
typedef bool | IConsoleCmdProc(byte argc, char *argv[])
| –Commands– Commands are commands, or functions. More...
typedef ConsoleHookResult | IConsoleHook(bool echo)

## Enumerations
enum | ConsoleHookResult { CHR_ALLOW, CHR_DISALLOW, CHR_HIDE }
| Return values of console hooks (#IConsoleHook). More...

## Functions
void | IConsoleClearBuffer ()
void | IConsoleCmdRegister (const char *name, IConsoleCmdProc *proc, IConsoleHook *hook=nullptr)
| Register a new command to be used in the console. More...
void | IConsoleAliasRegister (const char *name, const char *cmd)
| Register a an alias for an already existing command in the console. More...
IConsoleCmd * | IConsoleCmdGet (const char *name)
| Find the command pointed to by its string. More...
IConsoleAlias * | IConsoleAliasGet (const char *name)
| Find the alias pointed to by its string. More...
void | IConsoleStdLibRegister ()
bool | GetArgumentInteger (uint32 *value, const char *arg)
| Change a string into its number representation. More...
void | IConsoleGUIInit ()
void | IConsoleGUIFree ()
void | IConsoleGUIPrint (TextColour colour_code, char *string)
| Handle the printing of text entered into the console or redirected there by any other means. More...
char * | RemoveUnderscores (char *name)
| Remove underscores from a string; the string will be modified! More...

## Variables
static const uint | ICON_CMDLN_SIZE = 1024
| maximum length of a typed in command
static const uint | ICON_MAX_STREAMSIZE = 2048
| maximum length of a totally expanded command
IConsoleCmd * | _iconsole_cmds
| List of registered commands. More...
IConsoleAlias * | _iconsole_aliases
| List of registered aliases. More...

## Detailed Description

Internally used functions for the console.

Definition in file console_internal.h.

## Typedef Documentation

## ◆ IConsoleCmdProc

typedef bool IConsoleCmdProc(byte argc, char *argv[])

–Commands– Commands are commands, or functions.

They get executed once and any effect they produce are carried out. The arguments to the commands are given to them, each input word separated by a double-quote (") is an argument If you want to handle multiple words as one, enclose them in double-quotes eg. 'say "hello sexy boy"'

Definition at line 33 of file console_internal.h.

## Enumeration Type Documentation

## ◆ ConsoleHookResult

enum ConsoleHookResult

Return values of console hooks (#IConsoleHook).

Enumerator
CHR_ALLOW | Allow command execution.
CHR_DISALLOW | Disallow command execution.
CHR_HIDE | Hide the existence of the command.

Definition at line 19 of file console_internal.h.

## 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 180 of file console.cpp.

Referenced by DEF_CONSOLE_CMD().

## ◆ IConsoleAliasGet()

IConsoleAlias* IConsoleAliasGet | ( | const char * | name | ) |

Find the alias pointed to by its string.

Parameters

  name | alias to be found

Returns
  return Aliasstruct of the found alias, or nullptr on failure

Definition at line 303 of file console.cpp.

References _iconsole_aliases, IConsoleAlias::name, CompanyProperties::name, and IConsoleAlias::next.

Referenced by IConsoleAliasRegister(), and IConsoleCmdExec().

## ◆ IConsoleAliasRegister()

void IConsoleAliasRegister | ( | const char * | name,
|  | const char * | cmd
| ) |  |

Register a an alias for an already existing command in the console.

Parameters

  name | name of the alias that will be used
  cmd | name of the command that 'name' will be alias of

Definition at line 280 of file console.cpp.

References _iconsole_aliases, IConsoleAlias::cmdline, IConsoleAddSorted(), IConsoleAliasGet(), IConsoleError(), IConsoleAlias::name, CompanyProperties::name, IConsoleAlias::next, RemoveUnderscores(), and stredup().

## ◆ IConsoleCmdGet()

IConsoleCmd* IConsoleCmdGet | ( | const char * | name | ) |

Find the command pointed to by its string.

Parameters

  name | command to be found

Returns
  return Cmdstruct of the found command, or nullptr on failure

Definition at line 265 of file console.cpp.

References _iconsole_cmds, IConsoleCmd::name, CompanyProperties::name, and IConsoleCmd::next.

Referenced by IConsoleCmdExec().

## ◆ IConsoleCmdRegister()

void IConsoleCmdRegister | ( | const char * | name,
|  | IConsoleCmdProc * | proc,
|  | IConsoleHook * | hook
| ) |  |

Register a new command to be used in the console.

Parameters

  name | name of the command that will be used
  proc | function that will be called upon execution of command

Definition at line 249 of file console.cpp.

## ◆ IConsoleGUIPrint()

void IConsoleGUIPrint | ( | TextColour | colour_code,
|  | char * | str
| ) |  |

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. Red in case of errors, etc.
  str | the message entered or output on the console (notice, error, etc.)

Definition at line 511 of file console_gui.cpp.

References SetWindowDirty(), and WC_CONSOLE.

## ◆ RemoveUnderscores()

char* RemoveUnderscores | ( | char * | name | ) |

Remove underscores from a string; the string will be modified!

Parameters

  [in,out] | name | String to remove the underscores from.

Returns
  name, with its contents modified.

Definition at line 234 of file console.cpp.

References CompanyProperties::name.

Referenced by IConsoleAliasRegister(), and IConsoleCmdExec().

## Variable Documentation

## ◆ _iconsole_aliases

IConsoleAlias* _iconsole_aliases

List of registered aliases.

List of registered aliases.

Definition at line 28 of file console.cpp.

Referenced by IConsoleAliasGet(), and IConsoleAliasRegister().

## ◆ _iconsole_cmds

IConsoleCmd* _iconsole_cmds

List of registered commands.

List of registered commands.

Definition at line 27 of file console.cpp.

Referenced by IConsoleCmdGet().