diff options
-rw-r--r-- | console.c | 10 | ||||
-rw-r--r-- | console.h | 6 | ||||
-rw-r--r-- | console_cmds.c | 50 |
3 files changed, 50 insertions, 16 deletions
@@ -187,7 +187,8 @@ void IConsoleInit() 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 @@ void IConsoleError(const byte* string) { 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 IConsoleCmdRegister(const byte * name, void * addr) } } -void* IConsoleCmdGet(const byte * name) +_iconsole_cmd * IConsoleCmdGet(const byte * name) { _iconsole_cmd * item; @@ -66,6 +66,7 @@ _iconsole_var * _iconsole_vars; // list of registred vars // ** 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 IConsoleCmdBufferNavigate(signed char direction); 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 --git a/console_cmds.c b/console_cmds.c index 8afcbe8d5..31cf3685a 100644 --- a/console_cmds.c +++ b/console_cmds.c @@ -173,20 +173,45 @@ DEF_CONSOLE_CMD(ConScreenShot) 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 IConsoleStdLibRegister() (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); |