# HG changeset patch # User rubidium # Date 1211624106 0 # Node ID 7cc2278c2ac0ee2addc13f7041b82377f2742e23 # Parent d9c3f54fe72f2589e1f40f52b02aa4537e052222 (svn r13228) -Codechange: split console.h. diff -r d9c3f54fe72f -r 7cc2278c2ac0 projects/openttd_vs80.vcproj --- a/projects/openttd_vs80.vcproj Sat May 24 10:02:49 2008 +0000 +++ b/projects/openttd_vs80.vcproj Sat May 24 10:15:06 2008 +0000 @@ -876,7 +876,19 @@ > + + + + + + + + + + + + #include -#include "console.h" +#include "console_internal.h" #include "network/network.h" #include "network/network_data.h" #include "network/network_server.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/console.h --- a/src/console.h Sat May 24 10:02:49 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* $Id$ */ - -/** @file console.h In-game console. */ - -#ifndef CONSOLE_H -#define CONSOLE_H - -#include "window_type.h" - -/* maximum length of a typed in command */ -#define ICON_CMDLN_SIZE 255 -/* maximum length of a totally expanded command */ -#define ICON_MAX_STREAMSIZE 1024 - -enum IConsoleVarTypes { - ICONSOLE_VAR_BOOLEAN, - ICONSOLE_VAR_BYTE, - ICONSOLE_VAR_UINT16, - ICONSOLE_VAR_UINT32, - ICONSOLE_VAR_INT16, - ICONSOLE_VAR_INT32, - ICONSOLE_VAR_STRING -}; - -enum IConsoleModes { - ICONSOLE_FULL, - ICONSOLE_OPENED, - ICONSOLE_CLOSED -}; - -enum IConsoleHookTypes { - ICONSOLE_HOOK_ACCESS, - ICONSOLE_HOOK_PRE_ACTION, - ICONSOLE_HOOK_POST_ACTION -}; - -/** --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 - */ -typedef bool IConsoleHook(); -struct IConsoleHooks{ - IConsoleHook *access; ///< trigger when accessing the variable/command - IConsoleHook *pre; ///< trigger before the variable/command is changed/executed - IConsoleHook *post; ///< trigger after the variable/command is changed/executed -}; - -/** --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"' - */ -typedef bool (IConsoleCmdProc)(byte argc, char *argv[]); - -struct IConsoleCmd { - char *name; ///< name of command - IConsoleCmd *next; ///< next command in list - - IConsoleCmdProc *proc; ///< process executed when command is typed - IConsoleHooks hook; ///< any special trigger action that needs executing -}; - -/** --Variables-- - * Variables are pointers to real ingame variables which allow for - * changing while ingame. After changing they keep their new value - * and can be used for debugging, gameplay, etc. It accepts: - * - no arguments; just print out current value - * - '= ' to assign a new value to the variable - * - '++' to increase value by one - * - '--' to decrease value by one - */ -struct IConsoleVar { - char *name; ///< name of the variable - IConsoleVar *next; ///< next variable in list - - void *addr; ///< the address where the variable is pointing at - uint32 size; ///< size of the variable, used for strings - char *help; ///< the optional help string shown when requesting information - IConsoleVarTypes type; ///< type of variable (for correct assignment/output) - IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that - IConsoleHooks hook; ///< any special trigger action that needs executing -}; - -/** --Aliases-- - * Aliases are like shortcuts for complex functions, variable assignments, - * etc. You can use a simple alias to rename a longer command (eg 'lv' for - * 'list_vars' for example), or concatenate more commands into one - * (eg. 'ng' for 'load %A; unpause; debug_level 5'). Aliases can parse the arguments - * given to them in the command line. - * - "%A - %Z" substitute arguments 1 t/m 26 - * - "%+" lists all parameters keeping them seperated - * - "%!" also lists all parameters but presenting them to the aliased command as one argument - * - ";" allows for combining commands (see example 'ng') - */ -struct IConsoleAlias { - char *name; ///< name of the alias - IConsoleAlias *next; ///< next alias in list - - char *cmdline; ///< command(s) that is/are being aliased -}; - -/* console parser */ -extern IConsoleCmd *_iconsole_cmds; ///< list of registred commands -extern IConsoleVar *_iconsole_vars; ///< list of registred vars -extern IConsoleAlias *_iconsole_aliases; ///< list of registred aliases - -/* console colors/modes */ -extern byte _icolour_def; -extern byte _icolour_err; -extern byte _icolour_warn; -extern byte _icolour_dbg; -extern byte _icolour_cmd; -extern IConsoleModes _iconsole_mode; - -/* console functions */ -void IConsoleInit(); -void IConsoleFree(); -void IConsoleClearBuffer(); -void IConsoleResize(Window *w); -void IConsoleSwitch(); -void IConsoleClose(); -void IConsoleOpen(); - -/* console output */ -void IConsolePrint(uint16 color_code, const char *string); -void CDECL IConsolePrintF(uint16 color_code, const char *s, ...); -void IConsoleDebug(const char *dbg, const char *string); -void IConsoleWarning(const char *string); -void IConsoleError(const char *string); - -/* Commands */ -void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc); -void IConsoleAliasRegister(const char *name, const char *cmd); -IConsoleCmd *IConsoleCmdGet(const char *name); -IConsoleAlias *IConsoleAliasGet(const char *name); - -/* Variables */ -void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help); -void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help); -IConsoleVar* IConsoleVarGet(const char *name); -void IConsoleVarPrintGetValue(const IConsoleVar *var); -void IConsoleVarPrintSetValue(const IConsoleVar *var); - -/* Parser */ -void IConsoleCmdExec(const char *cmdstr); -void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[]); - -/* console std lib (register ingame commands/aliases/variables) */ -void IConsoleStdLibRegister(); - -/* Hooking code */ -void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc); -void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc); -void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc); - -/* Supporting functions */ -bool GetArgumentInteger(uint32 *value, const char *arg); -#endif /* CONSOLE_H */ diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/console_cmds.cpp --- a/src/console_cmds.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/console_cmds.cpp Sat May 24 10:15:06 2008 +0000 @@ -4,7 +4,7 @@ #include "stdafx.h" #include "openttd.h" -#include "console.h" +#include "console_internal.h" #include "debug.h" #include "engine_func.h" #include "landscape.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/console_func.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/console_func.h Sat May 24 10:15:06 2008 +0000 @@ -0,0 +1,31 @@ +/* $Id$ */ + +/** @file console_func.h Console functions used outside of the console code. */ + +#ifndef CONSOLE_FUNC_H +#define CONSOLE_FUNC_H + +#include "console_type.h" + +/* console colors/modes */ +extern byte _icolour_def; +extern byte _icolour_err; +extern byte _icolour_warn; +extern byte _icolour_dbg; +extern byte _icolour_cmd; +extern IConsoleModes _iconsole_mode; + +/* console functions */ +void IConsoleInit(); +void IConsoleFree(); +void IConsoleClose(); + +/* console output */ +void IConsolePrint(uint16 color_code, const char *string); +void CDECL IConsolePrintF(uint16 color_code, const char *s, ...); +void IConsoleDebug(const char *dbg, const char *string); + +/* Parser */ +void IConsoleCmdExec(const char *cmdstr); + +#endif /* CONSOLE_FUNC_H */ diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/console_gui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/console_gui.h Sat May 24 10:15:06 2008 +0000 @@ -0,0 +1,13 @@ +/* $Id$ */ + +/** @file console_gui.h GUI related functions in the console. */ + +#ifndef CONSOLE_GUI_H +#define CONSOLE_GUI_H + +#include "window_type.h" + +void IConsoleResize(Window *w); +void IConsoleSwitch(); + +#endif /* CONSOLE_GUI_H */ diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/console_internal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/console_internal.h Sat May 24 10:15:06 2008 +0000 @@ -0,0 +1,138 @@ +/* $Id$ */ + +/** @file console_internal.h Internally used functions for the console. */ + +#ifndef CONSOLE_INTERNAL_H +#define CONSOLE_INTERNAL_H + +#include "console_func.h" + +/* maximum length of a typed in command */ +#define ICON_CMDLN_SIZE 255 +/* maximum length of a totally expanded command */ +#define ICON_MAX_STREAMSIZE 1024 + +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 +}; + +/** --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 + */ +typedef bool IConsoleHook(); +struct IConsoleHooks{ + IConsoleHook *access; ///< trigger when accessing the variable/command + IConsoleHook *pre; ///< trigger before the variable/command is changed/executed + IConsoleHook *post; ///< trigger after the variable/command is changed/executed +}; + +/** --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"' + */ +typedef bool (IConsoleCmdProc)(byte argc, char *argv[]); + +struct IConsoleCmd { + char *name; ///< name of command + IConsoleCmd *next; ///< next command in list + + IConsoleCmdProc *proc; ///< process executed when command is typed + IConsoleHooks hook; ///< any special trigger action that needs executing +}; + +/** --Variables-- + * Variables are pointers to real ingame variables which allow for + * changing while ingame. After changing they keep their new value + * and can be used for debugging, gameplay, etc. It accepts: + * - no arguments; just print out current value + * - '= ' to assign a new value to the variable + * - '++' to increase value by one + * - '--' to decrease value by one + */ +struct IConsoleVar { + char *name; ///< name of the variable + IConsoleVar *next; ///< next variable in list + + void *addr; ///< the address where the variable is pointing at + uint32 size; ///< size of the variable, used for strings + char *help; ///< the optional help string shown when requesting information + IConsoleVarTypes type; ///< type of variable (for correct assignment/output) + IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that + IConsoleHooks hook; ///< any special trigger action that needs executing +}; + +/** --Aliases-- + * Aliases are like shortcuts for complex functions, variable assignments, + * etc. You can use a simple alias to rename a longer command (eg 'lv' for + * 'list_vars' for example), or concatenate more commands into one + * (eg. 'ng' for 'load %A; unpause; debug_level 5'). Aliases can parse the arguments + * given to them in the command line. + * - "%A - %Z" substitute arguments 1 t/m 26 + * - "%+" lists all parameters keeping them seperated + * - "%!" also lists all parameters but presenting them to the aliased command as one argument + * - ";" allows for combining commands (see example 'ng') + */ +struct IConsoleAlias { + char *name; ///< name of the alias + IConsoleAlias *next; ///< next alias in list + + char *cmdline; ///< command(s) that is/are being aliased +}; + +/* console parser */ +extern IConsoleCmd *_iconsole_cmds; ///< list of registred commands +extern IConsoleVar *_iconsole_vars; ///< list of registred vars +extern IConsoleAlias *_iconsole_aliases; ///< list of registred aliases + +/* console functions */ +void IConsoleClearBuffer(); +void IConsoleOpen(); + +/* console output */ +void IConsoleWarning(const char *string); +void IConsoleError(const char *string); + +/* Commands */ +void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc); +void IConsoleAliasRegister(const char *name, const char *cmd); +IConsoleCmd *IConsoleCmdGet(const char *name); +IConsoleAlias *IConsoleAliasGet(const char *name); + +/* Variables */ +void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help); +void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help); +IConsoleVar* IConsoleVarGet(const char *name); +void IConsoleVarPrintGetValue(const IConsoleVar *var); +void IConsoleVarPrintSetValue(const IConsoleVar *var); + +/* Parser */ +void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[]); + +/* console std lib (register ingame commands/aliases/variables) */ +void IConsoleStdLibRegister(); + +/* Hooking code */ +void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc); +void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc); +void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc); + +/* Supporting functions */ +bool GetArgumentInteger(uint32 *value, const char *arg); +#endif /* CONSOLE_H */ diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/console_type.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/console_type.h Sat May 24 10:15:06 2008 +0000 @@ -0,0 +1,14 @@ +/* $Id$ */ + +/** @file console_type.h Globally used console related types. */ + +#ifndef CONSOLE_TYPE_H +#define CONSOLE_TYPE_H + +enum IConsoleModes { + ICONSOLE_FULL, + ICONSOLE_OPENED, + ICONSOLE_CLOSED +}; + +#endif /* CONSOLE_TYPE_H */ diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/debug.cpp --- a/src/debug.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/debug.cpp Sat May 24 10:15:06 2008 +0000 @@ -6,7 +6,7 @@ #include #include #include "openttd.h" -#include "console.h" +#include "console_func.h" #include "debug.h" #include "string_func.h" #include "network/core/core.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/main_gui.cpp --- a/src/main_gui.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/main_gui.cpp Sat May 24 10:15:06 2008 +0000 @@ -13,7 +13,7 @@ #include "viewport_func.h" #include "command_func.h" #include "news_gui.h" -#include "console.h" +#include "console_gui.h" #include "waypoint.h" #include "genworld.h" #include "transparency_gui.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/network/network.cpp --- a/src/network/network.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/network/network.cpp Sat May 24 10:15:06 2008 +0000 @@ -23,7 +23,7 @@ #include "core/tcp.h" #include "core/core.h" #include "network_gui.h" -#include "../console.h" /* IConsoleCmdExec */ +#include "../console_func.h" #include /* va_list */ #include "../md5.h" #include "../fileio.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/network/network_client.cpp --- a/src/network/network_client.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/network/network_client.cpp Sat May 24 10:15:06 2008 +0000 @@ -14,7 +14,7 @@ #include "network_gui.h" #include "../saveload.h" #include "../command_func.h" -#include "../console.h" +#include "../console_func.h" #include "../variables.h" #include "../ai/ai.h" #include "../core/alloc_func.hpp" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/network/network_server.cpp --- a/src/network/network_server.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/network/network_server.cpp Sat May 24 10:15:06 2008 +0000 @@ -15,7 +15,7 @@ #include "../date_func.h" #include "network_server.h" #include "network_udp.h" -#include "../console.h" +#include "../console_func.h" #include "../command_func.h" #include "../saveload.h" #include "../station_base.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/openttd.cpp --- a/src/openttd.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/openttd.cpp Sat May 24 10:15:06 2008 +0000 @@ -41,7 +41,7 @@ #include "fios.h" #include "airport.h" #include "aircraft.h" -#include "console.h" +#include "console_func.h" #include "screenshot.h" #include "network/network.h" #include "signs_base.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/settings.cpp --- a/src/settings.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/settings.cpp Sat May 24 10:15:06 2008 +0000 @@ -28,7 +28,7 @@ #include "network/network_internal.h" #include "settings_internal.h" #include "command_func.h" -#include "console.h" +#include "console_func.h" #include "saveload.h" #include "npf.h" #include "yapf/yapf.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/texteff.cpp --- a/src/texteff.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/texteff.cpp Sat May 24 10:15:06 2008 +0000 @@ -6,7 +6,7 @@ #include "openttd.h" #include "landscape.h" #include "gfx_func.h" -#include "console.h" +#include "console_func.h" #include "variables.h" #include "blitter/factory.hpp" #include "texteff.hpp" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/tgp.cpp --- a/src/tgp.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/tgp.cpp Sat May 24 10:15:06 2008 +0000 @@ -10,7 +10,6 @@ #include "variables.h" #include "void_map.h" #include "tgp.h" -#include "console.h" #include "genworld.h" #include "core/alloc_func.hpp" #include "core/random_func.hpp" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/toolbar_gui.cpp Sat May 24 10:15:06 2008 +0000 @@ -35,7 +35,7 @@ #include "signs_func.h" #include "fios.h" #include "functions.h" -#include "console.h" +#include "console_gui.h" #include "news_gui.h" #include "tilehighlight_func.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/video/dedicated_v.cpp --- a/src/video/dedicated_v.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/video/dedicated_v.cpp Sat May 24 10:15:06 2008 +0000 @@ -11,7 +11,7 @@ #include "../gfx_func.h" #include "../network/network.h" #include "../network/network_internal.h" -#include "../console.h" +#include "../console_func.h" #include "../variables.h" #include "../genworld.h" #include "../fileio.h" diff -r d9c3f54fe72f -r 7cc2278c2ac0 src/window.cpp --- a/src/window.cpp Sat May 24 10:02:49 2008 +0000 +++ b/src/window.cpp Sat May 24 10:15:06 2008 +0000 @@ -8,7 +8,8 @@ #include "debug.h" #include "player_func.h" #include "gfx_func.h" -#include "console.h" +#include "console_func.h" +#include "console_gui.h" #include "viewport_func.h" #include "variables.h" #include "genworld.h"