]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cmd: misc cleanup
authorbones_was_here <bones_was_here@xonotic.au>
Mon, 11 Dec 2023 15:31:04 +0000 (01:31 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Tue, 12 Dec 2023 06:41:56 +0000 (16:41 +1000)
Removes an unnecessary pointer stored in all the cbuf objects.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cmd.c
cmd.h

diff --git a/cmd.c b/cmd.c
index 5315d48d005ba911f6fcdd68365d08856ff619bd..1f2609569ef42e31dc189f03afa6512b6629dc5d 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -1635,12 +1635,10 @@ void Cmd_Init(void)
        // local console
        cmd_iter_all[0].cmd = cmd_local = Cmd_AddInterpreter(cbuf, &cvars_all, CF_CLIENT | CF_SERVER, CF_CLIENT | CF_CLIENT_FROM_SERVER | CF_SERVER_FROM_CLIENT, &cmd_userdefined_all);
        cmd_local->Handle = Cmd_CL_Callback;
-       cmd_local->NotFound = NULL;
 
        // server commands received from clients have no reason to access cvars, cvar expansion seems perilous.
        cmd_iter_all[1].cmd = cmd_serverfromclient = Cmd_AddInterpreter(cbuf, &cvars_null, 0, CF_SERVER_FROM_CLIENT | CF_USERINFO, &cmd_userdefined_null);
        cmd_serverfromclient->Handle = Cmd_SV_Callback;
-       cmd_serverfromclient->NotFound = Cmd_SV_NotFound;
 
        cmd_iter_all[2].cmd = NULL;
 //
@@ -1711,9 +1709,10 @@ void Cmd_Shutdown(void)
 Cmd_TokenizeString
 
 Parses the given string into command line tokens.
+Takes a null terminated string.  Does not need to be /n terminated.
 ============
 */
-// AK: This function should only be called from ExcuteString because the current design is a bit of an hack
+// AK: This function should only be called from ExecuteString because the current design is a bit of an hack
 static void Cmd_TokenizeString (cmd_state_t *cmd, const char *text)
 {
        int l;
@@ -2173,15 +2172,6 @@ qbool Cmd_SV_Callback(cmd_state_t *cmd, cmd_function_t *func, const char *text,
        return false;
 }
 
-qbool Cmd_SV_NotFound(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src)
-{
-       if (cmd->source == src_client)
-       {
-               Con_Printf("Client \"%s\" tried to execute \"%s\"\n", host_client->name, text);
-               return true;
-       }
-       return false;
-}
 /*
 ============
 Cmd_ExecuteString
@@ -2195,6 +2185,7 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb
        int oldpos;
        cmd_function_t *func;
        cmd_alias_t *a;
+
        if (lockmutex)
                Cbuf_Lock(cmd->cbuf);
        oldpos = cmd->cbuf->tokenizebufferpos;
@@ -2208,28 +2199,20 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb
 
 // check functions
        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;
-               }
-       }
 
        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;
-               }
-       }
 
        // if it's a client command and no command was found, say so.
-       if(cmd->NotFound)
+       if (cmd->source == src_client)
        {
-               if(cmd->NotFound(cmd, func, text, src))
-                       goto done;
+               Con_Printf("Client \"%s\" tried to execute \"%s\"\n", host_client->name, text);
+               goto done;
        }
 
 // check alias
diff --git a/cmd.h b/cmd.h
index a1cd89e7218aa987739a2055b437911c0b60417a..fef1f11feeab9f30c6821fa7339bb0283f34fdda 100644 (file)
--- a/cmd.h
+++ b/cmd.h
@@ -145,14 +145,12 @@ typedef struct cmd_state_s
        int cmd_flags; // cmd flags that identify this interpreter
 
        qbool (*Handle)(struct cmd_state_s *, struct cmd_function_s *, const char *, enum cmd_source_s);
-       qbool (*NotFound)(struct cmd_state_s *, struct cmd_function_s *, const char *, enum cmd_source_s);
 }
 cmd_state_t;
 
 qbool Cmd_Callback(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src);
 qbool Cmd_CL_Callback(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src);
 qbool Cmd_SV_Callback(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src);
-qbool Cmd_SV_NotFound(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src);
 
 typedef struct cmd_input_s
 {
@@ -236,17 +234,11 @@ qbool Cmd_Exists (cmd_state_t *cmd, const char *cmd_name);
 const char *Cmd_CompleteCommand (cmd_state_t *cmd, const char *partial);
 
 int Cmd_CompleteAliasCountPossible (cmd_state_t *cmd, const char *partial);
-
 const char **Cmd_CompleteAliasBuildList (cmd_state_t *cmd, const char *partial);
-
 int Cmd_CompleteCountPossible (cmd_state_t *cmd, const char *partial);
-
 const char **Cmd_CompleteBuildList (cmd_state_t *cmd, const char *partial);
-
 void Cmd_CompleteCommandPrint (cmd_state_t *cmd, const char *partial);
-
 const char *Cmd_CompleteAlias (cmd_state_t *cmd, const char *partial);
-
 void Cmd_CompleteAliasPrint (cmd_state_t *cmd, const char *partial);
 
 // Enhanced console completion by Fett erich@heintz.com
@@ -274,10 +266,6 @@ static inline const char *Cmd_Args (cmd_state_t *cmd)
 /// where the given parameter apears, or 0 if not present
 int Cmd_CheckParm (cmd_state_t *cmd, const char *parm);
 
-//void Cmd_TokenizeString (char *text);
-// Takes a null terminated string.  Does not need to be /n terminated.
-// breaks the string up into arg tokens.
-
 /// Parses a single line of text into arguments and tries to execute it.
 /// The text can come from the command buffer, a remote client, or stdin.
 void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qbool lockmutex);