# HG changeset patch # User signde # Date 1095058590 0 # Node ID b94bfdf02bae8dca5403c25ee1082f0a3956b467 # Parent f65dec6727d9cfbd7e0546b48a436a0bb54171c9 (svn r230) -Feature: IConsoleWarning for warning messages -Feature: added info_cmd command -Codechange: renamed "varinfo" to "info_var" -Fix: some const fixes in console.h -Fix: fixed return value of IConsoleCmdGet diff -r f65dec6727d9 -r b94bfdf02bae console.c --- a/console.c Sun Sep 12 23:35:01 2004 +0000 +++ b/console.c Mon Sep 13 06:56:30 2004 +0000 @@ -187,7 +187,8 @@ extern char _openttd_revision[]; #endif _iconsole_color_default = 1; - _iconsole_color_error = 3; + _iconsole_color_error = 3; + _iconsole_color_warning = 13; _iconsole_color_debug = 5; _iconsole_color_commands = 2; _iconsole_scroll=79; @@ -358,6 +359,11 @@ { if (_stdlib_developer>0) IConsolePrintF(_iconsole_color_error, "ERROR: %s", string); } + +void IConsoleWarning(const byte* string) +{ + if (_stdlib_developer>0) IConsolePrintF(_iconsole_color_warning, "WARNING: %s", string); +} void IConsoleCmdRegister(const byte * name, void * addr) { @@ -390,7 +396,7 @@ } } -void* IConsoleCmdGet(const byte * name) +_iconsole_cmd * IConsoleCmdGet(const byte * name) { _iconsole_cmd * item; diff -r f65dec6727d9 -r b94bfdf02bae console.h --- a/console.h Sun Sep 12 23:35:01 2004 +0000 +++ b/console.h Mon Sep 13 06:56:30 2004 +0000 @@ -66,6 +66,7 @@ // ** console colors ** // VARDEF byte _iconsole_color_default; VARDEF byte _iconsole_color_error; +VARDEF byte _iconsole_color_warning; VARDEF byte _iconsole_color_debug; VARDEF byte _iconsole_color_commands; @@ -92,12 +93,13 @@ void IConsolePrint(byte color_code, const byte* string); void CDECL IConsolePrintF(byte color_code, const char *s, ...); void IConsoleDebug(byte* string); -void IConsoleError(const byte* string); +void IConsoleError(const byte* string); +void IConsoleWarning(const byte* string); // *** Commands *** // void IConsoleCmdRegister(const byte * name, void * addr); -void* IConsoleCmdGetAddr(byte * name); +_iconsole_cmd * IConsoleCmdGet(const byte * name); // *** Variables *** // diff -r f65dec6727d9 -r b94bfdf02bae console_cmds.c --- a/console_cmds.c Sun Sep 12 23:35:01 2004 +0000 +++ b/console_cmds.c Mon Sep 13 06:56:30 2004 +0000 @@ -173,20 +173,45 @@ return NULL; } -DEF_CONSOLE_CMD(ConVarInfo) +DEF_CONSOLE_CMD(ConInfoVar) { if (argc<2) return NULL; if (argt[1]!=ICONSOLE_VAR_REFERENCE) { - IConsoleError("variable must be an variable reference"); + IConsoleError("first argument must be an variable reference"); } else { _iconsole_var * item; item = (_iconsole_var *) argv[1]; - IConsolePrintF(_iconsole_color_default,"variable_name: %s",item->name); - IConsolePrintF(_iconsole_color_default,"variable_type: %i",item->type); - IConsolePrintF(_iconsole_color_default,"variable_addr: %i",item->addr); - if (item->_malloc) IConsolePrintF(_iconsole_color_default,"variable_malloc: internal allocated"); else IConsolePrintF(_iconsole_color_default, "variable_malloc: external allocated"); + IConsolePrintF(_iconsole_color_default,"var_name: %s",item->name); + IConsolePrintF(_iconsole_color_default,"var_type: %i",item->type); + IConsolePrintF(_iconsole_color_default,"var_addr: %i",item->addr); + if (item->_malloc) IConsolePrintF(_iconsole_color_default,"var_malloc: internal"); else IConsolePrintF(_iconsole_color_default, "var_malloc: external"); + if (item->hook_access) IConsoleWarning("var_access hooked"); + if (item->hook_before_change) IConsoleWarning("var_before_change hooked"); + if (item->hook_after_change) IConsoleWarning("var_after_change hooked"); } return NULL; +} + + +DEF_CONSOLE_CMD(ConInfoCmd) +{ + if (argc<2) return NULL; + if (argt[1]!=ICONSOLE_VAR_UNKNOWN) { + IConsoleError("first argument must be an commandname"); + } else { + _iconsole_cmd * item; + item = IConsoleCmdGet(argv[1]); + if (item==NULL) { + IConsoleError("the given command was not found"); + return NULL; + } + IConsolePrintF(_iconsole_color_default,"cmd_name: %s",item->name); + IConsolePrintF(_iconsole_color_default,"cmd_addr: %i",item->addr); + if (item->hook_access) IConsoleWarning("cmd_access hooked"); + if (item->hook_before_exec) IConsoleWarning("cmd_before_exec hooked"); + if (item->hook_after_exec) IConsoleWarning("cmd_after_exec hooked"); + } + return NULL; } DEF_CONSOLE_CMD(ConDebugLevel) @@ -338,28 +363,29 @@ (void)ConResetTile; // Silence warning, this is only used in _DEBUG #endif - // functions [please add them alphabeticaly] + // functions [please add them alphabeticaly] #ifdef ENABLE_NETWORK IConsoleCmdRegister("connect",ConNetworkConnect); IConsoleCmdHook("connect",ICONSOLE_HOOK_ACCESS,ConCmdHookNoNetwork); -#endif +#endif IConsoleCmdRegister("debug_level",ConDebugLevel); IConsoleCmdRegister("dump_vars",ConListDumpVariables); IConsoleCmdRegister("echo",ConEcho); IConsoleCmdRegister("echoc",ConEchoC); IConsoleCmdRegister("exit",ConExit); - IConsoleCmdRegister("help",ConHelp); + IConsoleCmdRegister("help",ConHelp); + IConsoleCmdRegister("info_cmd",ConInfoCmd); + IConsoleCmdRegister("info_var",ConInfoVar); + IConsoleCmdRegister("list_cmds",ConListCommands); + IConsoleCmdRegister("list_vars",ConListVariables); IConsoleCmdRegister("printf",ConPrintF); IConsoleCmdRegister("printfc",ConPrintFC); IConsoleCmdRegister("quit",ConExit); IConsoleCmdRegister("random",ConRandom); - IConsoleCmdRegister("list_cmds",ConListCommands); - IConsoleCmdRegister("list_vars",ConListVariables); IConsoleCmdRegister("resetengines",ConResetEngines); IConsoleCmdHook("resetengines",ICONSOLE_HOOK_ACCESS,ConCmdHookNoNetwork); IConsoleCmdRegister("screenshot",ConScreenShot); IConsoleCmdRegister("scrollto",ConScrollToTile); - IConsoleCmdRegister("varinfo",ConVarInfo); // variables [please add them alphabeticaly] IConsoleVarRegister("con_developer",(void *) &_stdlib_con_developer,ICONSOLE_VAR_BOOLEAN);