Add option for console commands to be unlisted.
This commit is contained in:
@@ -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<IConsoleCmd>(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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user