# console_internal.h File Reference

Internally used functions for the console. More...

`#include "console_func.h"`

Go to the source code of this file.

## Data Structures

struct | IConsoleHooks
struct | IConsoleCmd
struct | IConsoleVar
| --Variables-- Variables are pointers to real ingame variables which allow for changing while ingame. More...
struct | IConsoleAlias
| --Aliases-- Aliases are like shortcuts for complex functions, variable assignments, etc. More...

## Typedefs

typedef bool | IConsoleHook ()
| --Hooks-- Hooks are certain triggers get get accessed/executed on either access, before execution/change or after execution/change.
typedef bool( | IConsoleCmdProc )(byte argc, char *argv[])
| --Commands-- Commands are commands, or functions.

## Enumerations

enum | { ICON_CMDLN_SIZE = 1024, ICON_MAX_STREAMSIZE = 2048 }
enum | IConsoleVarTypes { ICONSOLE_VAR_BOOLEAN, ICONSOLE_VAR_BYTE, ICONSOLE_VAR_UINT16, ICONSOLE_VAR_UINT32, ICONSOLE_VAR_INT16, ICONSOLE_VAR_INT32, ICONSOLE_VAR_STRING }
enum | IConsoleHookTypes { ICONSOLE_HOOK_ACCESS, ICONSOLE_HOOK_PRE_ACTION, ICONSOLE_HOOK_POST_ACTION }

## Functions

void | IConsoleClearBuffer ()
void | IConsoleOpen ()
void | IConsoleCmdRegister (const char *name, IConsoleCmdProc *proc)
| Register a new command to be used in the console.
void | IConsoleAliasRegister (const char *name, const char *cmd)
| Register a an alias for an already existing command in the console.
IConsoleCmd * | IConsoleCmdGet (const char *name)
| Find the command pointed to by its string.
IConsoleAlias * | IConsoleAliasGet (const char *name)
| Find the alias pointed to by its string.
void | IConsoleVarRegister (const char *name, void *addr, IConsoleVarTypes type, const char *help)
| Register a new variable to be used in the console.
void | IConsoleVarStringRegister (const char *name, void *addr, uint32 size, const char *help)
| Special function for adding string-type variables.
IConsoleVar * | IConsoleVarGet (const char *name)
| Find the variable pointed to by its string.
void | IConsoleVarPrintGetValue (const IConsoleVar *var)
| Print out the value of the variable when asked.
void | IConsoleVarPrintSetValue (const IConsoleVar *var)
| Print out the value of the variable after it has been assigned a new value, thus giving us feedback on the action.
void | IConsoleVarExec (const IConsoleVar *var, byte tokencount, char *token[])
void | IConsoleStdLibRegister ()
void | IConsoleCmdHookAdd (const char *name, IConsoleHookTypes type, IConsoleHook *proc)
| Add a hook to a command that will be triggered at certain points.
void | IConsoleVarHookAdd (const char *name, IConsoleHookTypes type, IConsoleHook *proc)
| Add a hook to a variable that will be triggered at certain points.
void | IConsoleVarProcAdd (const char *name, IConsoleCmdProc *proc)
| Add a callback function to the variable.
bool | GetArgumentInteger (uint32 *value, const char *arg)
| Change a string into its number representation.
void | IConsoleGUIInit ()
void | IConsoleGUIFree ()
void | IConsoleGUIPrint (ConsoleColour colour_code, char *string)
| Handle the printing of text entered into the console or redirected there by any other means.

## Variables

IConsoleCmd * | _iconsole_cmds
| list of registred commands
IConsoleVar * | _iconsole_vars
| list of registred vars
IConsoleAlias * | _iconsole_aliases
| list of registred aliases

## Detailed Description

Internally used functions for the console.

Definition in file console_internal.h.

## Typedef Documentation

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 seperated 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 50 of file console_internal.h.

typedef bool IConsoleHook()

--Hooks-- Hooks are certain triggers get get accessed/executed on either access, before execution/change or after execution/change.

This allows for general flow of permissions or special action needed in some cases

Definition at line 36 of file console_internal.h.

## Enumeration Type Documentation

anonymous enum

Enumerator:

  ICON_CMDLN_SIZE | maximum length of a typed in command
  ICON_MAX_STREAMSIZE | maximum length of a totally expanded command

Definition at line 10 of file console_internal.h.

## Function Documentation

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

Referenced by IConsoleVarExec().

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 NULL on failure

Definition at line 373 of file console.cpp.

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

Referenced by IConsoleCmdExec().

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

References IConsoleAlias::cmdline, IConsoleAddSorted, IConsoleAlias::name, and IConsoleAlias::next.

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 NULL on failure

Definition at line 340 of file console.cpp.

References _iconsole_cmds.

Referenced by IConsoleCmdExec(), and IConsoleCmdHookAdd().

void IConsoleCmdHookAdd | ( | const char * | name,
|  | IConsoleHookTypes | type,
|  | IConsoleHook * | proc |
| ) |  |  |

Add a hook to a command that will be triggered at certain points.

Parameters:

  | name | name of the command that the hook is added to
  | type | type of hook that is added (ACCESS, BEFORE and AFTER change)
  | proc | function called when the hook criteria is met

Definition at line 252 of file console.cpp.

References IConsoleCmdGet(), and IConsoleHookAdd().

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

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

References _iconsole_cmds, and IConsoleAddSorted.

void IConsoleGUIPrint | ( | ConsoleColour | 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.
  | string | the message entered or output on the console (notice, error, etc.)

Definition at line 443 of file console_gui.cpp.

References FindWindowById(), and SetWindowDirty().

Referenced by IConsolePrint().

IConsoleVar* IConsoleVarGet | ( | const char * | name | ) |

Find the variable pointed to by its string.

Parameters:

  | name | variable to be found

Returns:
  return Varstruct of the found variable, or NULL on failure

Definition at line 520 of file console.cpp.

References IConsoleVar::name, and IConsoleVar::next.

Referenced by IConsoleCmdExec(), IConsoleVarHookAdd(), IConsoleVarProcAdd(), and IConsoleVarStringRegister().

void IConsoleVarHookAdd | ( | const char * | name,
|  | IConsoleHookTypes | type,
|  | IConsoleHook * | proc |
| ) |  |  |

Add a hook to a variable that will be triggered at certain points.

Parameters:

  | name | name of the variable that the hook is added to
  | type | type of hook that is added (ACCESS, BEFORE and AFTER change)
  | proc | function called when the hook criteria is met

Definition at line 265 of file console.cpp.

References IConsoleVar::hook, IConsoleHookAdd(), and IConsoleVarGet().

void IConsoleVarProcAdd | ( | const char * | name,
|  | IConsoleCmdProc * | proc |
| ) |  |  |

Add a callback function to the variable.

Some variables need very special processing, which can only be done with custom code

Parameters:

  | name | name of the variable the callback function is added to
  | proc | the function called

Definition at line 739 of file console.cpp.

References IConsoleVarGet(), and IConsoleVar::proc.

void IConsoleVarRegister | ( | const char * | name,
|  | void * | addr,
|  | IConsoleVarTypes | type,
|  | const char * | help |
| ) |  |  |

Register a new variable to be used in the console.

Parameters:

  | name | name of the variable that will be used
  | addr | memory location the variable will point to
  | help | the help string shown for the variable
  | type | the type of the variable (simple atomic) so we know which values it can get

Definition at line 495 of file console.cpp.

References IConsoleVar::addr, IConsoleVar::help, IConsoleVar::hook, IConsoleAddSorted, IConsoleVar::name, IConsoleVar::next, IConsoleVar::proc, and IConsoleVar::type.

Referenced by IConsoleVarStringRegister().

void IConsoleVarStringRegister | ( | const char * | name,
|  | void * | addr,
|  | uint32 | size,
|  | const char * | help |
| ) |  |  |

Special function for adding string-type variables.

They in addition also need a 'size' value saying how long their string buffer is.

Parameters:

  | name | name of the variable that will be used
  | addr | memory location the variable will point to
  | size | the length of the string buffer
  | help | the help string shown for the variable For more information see IConsoleVarRegister()

Definition at line 480 of file console.cpp.

References IConsoleVarGet(), IConsoleVarRegister(), and IConsoleVar::size.