diff --git a/src/console.cpp b/src/console.cpp index 511019281a..24a528d8a4 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -253,13 +253,14 @@ char *RemoveUnderscores(char *name) * @param name name of the command that will be used * @param proc function that will be called upon execution of command */ -void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook) +void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook, bool unlisted) { IConsoleCmd *item_new = MallocT(1); item_new->name = RemoveUnderscores(stredup(name)); item_new->next = NULL; item_new->proc = proc; item_new->hook = hook; + item_new->unlisted = unlisted; IConsoleAddSorted(&_iconsole_cmds, item_new); } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 9cfc8e8f9d..6f28d3bb7e 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1500,7 +1500,7 @@ DEF_CONSOLE_CMD(ConListCommands) for (const IConsoleCmd *cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) { if (argv[1] == NULL || strstr(cmd->name, argv[1]) != NULL) { - if (cmd->hook == NULL || cmd->hook(false) != CHR_HIDE) IConsolePrintF(CC_DEFAULT, "%s", cmd->name); + if (cmd->unlisted == false && (cmd->hook == NULL || cmd->hook(false) != CHR_HIDE)) IConsolePrintF(CC_DEFAULT, "%s", cmd->name); } } diff --git a/src/console_internal.h b/src/console_internal.h index 1b63b26f0d..5673f1ea17 100644 --- a/src/console_internal.h +++ b/src/console_internal.h @@ -40,6 +40,7 @@ struct IConsoleCmd { IConsoleCmdProc *proc; ///< process executed when command is typed IConsoleHook *hook; ///< any special trigger action that needs executing + bool unlisted; }; /** @@ -69,7 +70,7 @@ extern IConsoleAlias *_iconsole_aliases; ///< List of registered aliases. void IConsoleClearBuffer(); /* Commands */ -void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook = NULL); +void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook = NULL, bool unlisted = false); void IConsoleAliasRegister(const char *name, const char *cmd); IConsoleCmd *IConsoleCmdGet(const char *name); IConsoleAlias *IConsoleAliasGet(const char *name);