diff options
-rw-r--r-- | console.c | 1 | ||||
-rw-r--r-- | console_cmds.c | 37 |
2 files changed, 30 insertions, 8 deletions
@@ -1023,6 +1023,7 @@ void IConsoleCmdExec(const char *cmdstr) for (cmdptr = cmdstr; *cmdptr != '\0'; *cmdptr++) { if (!IsValidAsciiChar(*cmdptr)) { IConsoleError("command contains malformed characters, aborting"); + IConsolePrintF(_iconsole_color_error, "ERROR: command was: '%s'", cmdstr); return; } } diff --git a/console_cmds.c b/console_cmds.c index 69518d37c..3fd533a22 100644 --- a/console_cmds.c +++ b/console_cmds.c @@ -193,7 +193,7 @@ DEF_CONSOLE_CMD(ConLoad) const char *file; if (argc == 0) { - IConsoleHelp("Load a game by name or index. Usage: 'load <file | number>'"); + IConsoleHelp("Load a game by name or index. Usage: 'load <file \\ number>'"); return true; } @@ -223,7 +223,7 @@ DEF_CONSOLE_CMD(ConListFiles) int i; if (argc == 0) { - IConsoleHelp("List all the files in the current dir via console. Usage: 'ls | dir'"); + IConsoleHelp("List all the files in the current dir via console. Usage: 'ls \\ dir'"); return true; } @@ -245,7 +245,7 @@ DEF_CONSOLE_CMD(ConChangeDirectory) const char *file; if (argc == 0) { - IConsoleHelp("Change the dir via console. Usage: 'cd <directory | number>'"); + IConsoleHelp("Change the dir via console. Usage: 'cd <directory \\ number>'"); return true; } @@ -605,6 +605,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect) DEF_CONSOLE_CMD(ConExec) { char cmdline[ICON_CMDLN_SIZE]; + char *cmdptr; if (argc == 0) { IConsoleHelp("Execute a local script file. Usage: 'exec <script> <?>'"); @@ -622,8 +623,16 @@ DEF_CONSOLE_CMD(ConExec) _script_running = true; - while (_script_running && fgets(cmdline, sizeof(cmdline), _script_file) != NULL) + while (_script_running && fgets(cmdline, sizeof(cmdline), _script_file) != NULL) { + /* Remove newline characters from the executing script */ + for (cmdptr = cmdline; *cmdptr != '\0'; *cmdptr++) { + if (*cmdptr == '\n' || *cmdptr == '\r') { + *cmdptr = '\0'; + break; + } + } IConsoleCmdExec(cmdline); + } if (ferror(_script_file)) IConsoleError("Encountered errror while trying to read from script file"); @@ -737,7 +746,7 @@ DEF_CONSOLE_CMD(ConAlias) DEF_CONSOLE_CMD(ConScreenShot) { if (argc == 0) { - IConsoleHelp("Create a screenshot of the game. Usage: 'screenshot [big|no_con]'"); + IConsoleHelp("Create a screenshot of the game. Usage: 'screenshot [big\\no_con]'"); IConsoleHelp("'big' makes a screenshot of the whole map, 'no_con' hides the console to create the screenshot"); return true; } @@ -839,8 +848,9 @@ DEF_CONSOLE_CMD(ConExit) DEF_CONSOLE_CMD(ConHelp) { if (argc == 2) { - IConsoleCmd *cmd; - IConsoleVar *var; + const IConsoleCmd *cmd; + const IConsoleVar *var; + const IConsoleAlias *alias; cmd = IConsoleCmdGet(argv[1]); if (cmd != NULL) { @@ -848,6 +858,17 @@ DEF_CONSOLE_CMD(ConHelp) return true; } + alias = IConsoleAliasGet(argv[1]); + if (alias != NULL) { + cmd = IConsoleCmdGet(alias->cmdline); + if (cmd != NULL) { + cmd->proc(0, NULL); + return true; + } + IConsolePrintF(_iconsole_color_error, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline); + return true; + } + var = IConsoleVarGet(argv[1]); if (var != NULL && var->help != NULL) { IConsolePrintF(_iconsole_color_warning, "%s.", var->help); @@ -868,7 +889,7 @@ DEF_CONSOLE_CMD(ConHelp) IConsolePrint( 1, ""); IConsolePrint( 1, " to assign strings, or use them as arguments, enclose it within quotes"); IConsolePrint( 1, " like this: '<command> \"string argument with spaces\"'"); - IConsolePrint( 1, " use 'help <command>|<variable>' to get specific information"); + IConsolePrint( 1, " use 'help <command>\\<variable>' to get specific information"); IConsolePrint( 1, ""); return true; } |