From: bones_was_here Date: Mon, 11 Dec 2023 12:02:55 +0000 (+1000) Subject: cmd: reinstate execution of aliases with the same name as a command X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=14bd731965d8d345372660d8b500a734d5c6a6b2;p=xonotic%2Fdarkplaces.git cmd: reinstate execution of aliases with the same name as a command Fixes https://gitlab.com/xonotic/darkplaces/-/issues/397 Based on the div0-stable version of Cmd_ExecuteString(). Signed-off-by: bones_was_here --- diff --git a/cmd.c b/cmd.c index 1f260956..b4bb9a58 100644 --- a/cmd.c +++ b/cmd.c @@ -2201,21 +2201,25 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb for (func = cmd->userdefined->qc_functions; func; func = func->next) if (!strcasecmp(cmd->argv[0], func->name)) if(cmd->Handle(cmd, func, text, src)) - goto done; + goto functions_done; for (func = cmd->engine_functions; func; func=func->next) if (!strcasecmp (cmd->argv[0], func->name)) if(cmd->Handle(cmd, func, text, src)) - goto done; + goto functions_done; - // if it's a client command and no command was found, say so. +functions_done: + // If it's a client command and wasn't found and handled, say so. + // Also don't let clients call server aliases. if (cmd->source == src_client) { - Con_Printf("Client \"%s\" tried to execute \"%s\"\n", host_client->name, text); + if (!func) + Con_Printf("Client \"%s\" tried to execute \"%s\"\n", host_client->name, text); goto done; } // check alias + // Execute any alias with the same name as a command after the command. for (a=cmd->userdefined->alias ; a ; a=a->next) { if (!strcasecmp (cmd->argv[0], a->name)) @@ -2225,6 +2229,10 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb } } + // If the command was found and handled don't try to handle it as a cvar. + if (func) + goto done; + // check cvars if (!Cvar_Command(cmd) && host.framecount > 0) Con_Printf(CON_WARN "Unknown command \"%s\"\n", Cmd_Argv(cmd, 0));