]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
Fix some warnings found by cppcheck
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index f7d84dc2c21f55023b5d270c54b460dc59c09714..64a90e26b008a509cb6927c4fa3d079e10514fbc 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -325,7 +325,7 @@ void Cbuf_Execute (cmd_state_t *cmd)
                // better than CRASHING on overlong input lines that may SOMEHOW enter the buffer
                if(i >= MAX_INPUTLINE)
                {
-                       Con_Warnf("Warning: console input buffer had an overlong line. Ignored.\n");
+                       Con_Printf(CON_WARN "Warning: console input buffer had an overlong line. Ignored.\n");
                        line[0] = 0;
                }
                else
@@ -410,6 +410,10 @@ static void Cmd_StuffCmds_f (cmd_state_t *cmd)
        int             i, j, l;
        // 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.state == host_init)
+               return;
 
        if (Cmd_Argc (cmd) != 1)
        {
@@ -1122,9 +1126,9 @@ static const char *Cmd_GetCvarValue(cmd_state_t *cmd, const char *var, size_t va
        {
                // empty cvar name?
                if(alias)
-                       Con_Warnf("Warning: Could not expand $ in alias %s\n", alias->name);
+                       Con_Printf(CON_WARN "Warning: Could not expand $ in alias %s\n", alias->name);
                else
-                       Con_Warnf("Warning: Could not expand $\n");
+                       Con_Printf(CON_WARN "Warning: Could not expand $\n");
                return "$";
        }
 
@@ -1170,9 +1174,9 @@ static const char *Cmd_GetCvarValue(cmd_state_t *cmd, const char *var, size_t va
                if(required)
                {
                        if(alias)
-                               Con_Errorf("Error: Could not expand $%s in alias %s\n", varname, alias->name);
+                               Con_Printf(CON_ERROR "Error: Could not expand $%s in alias %s\n", varname, alias->name);
                        else
-                               Con_Errorf("Error: Could not expand $%s\n", varname);
+                               Con_Printf(CON_ERROR "Error: Could not expand $%s\n", varname);
                        return NULL;
                }
                else if(optional)
@@ -1182,9 +1186,9 @@ static const char *Cmd_GetCvarValue(cmd_state_t *cmd, const char *var, size_t va
                else
                {
                        if(alias)
-                               Con_Warnf("Warning: Could not expand $%s in alias %s\n", varname, alias->name);
+                               Con_Printf(CON_WARN "Warning: Could not expand $%s in alias %s\n", varname, alias->name);
                        else
-                               Con_Warnf("Warning: Could not expand $%s\n", varname);
+                               Con_Printf(CON_WARN "Warning: Could not expand $%s\n", varname);
                        dpsnprintf(varval, sizeof(varval), "$%s", varname);
                        return varval;
                }
@@ -1516,7 +1520,7 @@ void Cmd_Init(void)
        // server commands received from clients have no reason to access cvars, cvar expansion seems perilous.
        cmd_serverfromclient.cvars = &cvars_null;
        cmd_serverfromclient.cvars_flagsmask = 0;
-       cmd_serverfromclient.cmd_flags = CMD_SERVER_FROM_CLIENT;
+       cmd_serverfromclient.cmd_flags = CMD_SERVER_FROM_CLIENT | CMD_USERINFO;
        cmd_serverfromclient.userdefined = &cmd_userdefined_null;
 
 //