]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
Fix scope screwup preventing apropos from printing cvars
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index 352d8c5be40491efe542a7d84a26b2411a41882f..81f9660307731973755a28ab27a03a31c3d734dc 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -397,6 +397,8 @@ void Cbuf_Frame(cmd_state_t *cmd)
 ==============================================================================
 */
 
+extern qboolean host_init;
+
 /*
 ===============
 Cmd_StuffCmds_f
@@ -413,6 +415,10 @@ static void Cmd_StuffCmds_f (cmd_state_t *cmd)
        // this is for all commandline options combined (and is bounds checked)
        char    build[MAX_INPUTLINE];
 
+       // come back later so we don't crash
+       if(host_init)
+               return;
+
        if (Cmd_Argc (cmd) != 1)
        {
                Con_Print("stuffcmds : execute command line parameters\n");
@@ -1423,6 +1429,7 @@ static void Cmd_Apropos_f(cmd_state_t *cmd)
        int count;
        qboolean ispattern;
        char vabuf[1024];
+       char *cvar_name;
 
        if (Cmd_Argc(cmd) > 1)
                partial = Cmd_Args(cmd);
@@ -1439,11 +1446,26 @@ static void Cmd_Apropos_f(cmd_state_t *cmd)
        count = 0;
        for (cvar = cmd->cvars->vars; cvar; cvar = cvar->next)
        {
-               if (!matchpattern_with_separator(cvar->name, partial, true, "", false))
-               if (!matchpattern_with_separator(cvar->description, partial, true, "", false))
+               if (!matchpattern_with_separator(cvar->name, partial, true, "", false) &&
+                   !matchpattern_with_separator(cvar->description, partial, true, "", false))
+               {
+                       for (int i = 0; i < cvar->aliasindex; i++)
+                       {
+                               if (!matchpattern_with_separator(cvar->aliases[i], partial, true, "", false)) {
+                                       continue;
+                               } else {
+                                       cvar_name = cvar->aliases[i];
+                                       goto print;
+                               }
+                       }       
                        continue;
-               Con_Printf ("cvar ^3%s^7 is \"%s\" [\"%s\"] %s\n", cvar->name, cvar->string, cvar->defstring, cvar->description);
-               count++;
+               } else {
+                       cvar_name = (char *)cvar->name;
+print:
+                       Con_Printf ("cvar ");
+                       Cvar_PrintHelp(cvar, cvar_name, true);
+                       count++;
+               }
        }
        for (func = cmd->userdefined->csqc_functions; func; func = func->next)
        {