]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
Fix a size_t comparison warning by doing the math better.
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index cf5f3a0e0438e54eab5a40e42aa086efdf715c53..ce0c4013b26c9cb9bc7ae78f53e06e2d7941c0e0 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -196,7 +196,7 @@ void Cbuf_AddText (cmd_state_t *cmd, const char *text)
        l = (int)strlen(text);
 
        Cbuf_Lock(cmd);
-       if (cmd->text.cursize + l >= (size_t)cmd->text.maxsize)
+       if (cmd->text.maxsize - cmd->text.cursize <= l)
                Con_Print("Cbuf_AddText: overflow\n");
        else
                SZ_Write(&cmd->text, (const unsigned char *)text, l);
@@ -1502,6 +1502,7 @@ void Cmd_Init_Commands(qboolean dedicated_server)
 //
        // client-only commands
        Cmd_AddCommand(&cmd_client, "cmd", Cmd_ForwardToServer_f, "send a console commandline to the server (used by some mods)");
+       Cmd_AddCommand(&cmd_clientfromserver, "cmd", Cmd_ForwardToServer_f, "send a console commandline to the server (used by some mods)");
        Cmd_AddCommand(&cmd_client, "wait", Cmd_Wait_f, "make script execution wait for next rendered frame");
        Cmd_AddCommand(&cmd_client, "cprint", Cmd_Centerprint_f, "print something at the screen center");
 
@@ -1981,11 +1982,18 @@ const char **Cmd_CompleteAliasBuildList (cmd_state_t *cmd, const char *partial)
        return buf;
 }
 
-void Cmd_ClearCsqcFuncs (cmd_state_t *cmd)
+// TODO: Make this more generic?
+void Cmd_ClearCSQCCommands (cmd_state_t *cmd)
 {
        cmd_function_t *func;
-       for (func = cmd->userdefined->csqc_functions; func; func = func->next)
-               func->csqcfunc = false;
+       cmd_function_t **next = &cmd->userdefined->csqc_functions;
+       
+       while(*next)
+       {
+               func = *next;
+               *next = func->next;
+               Z_Free(func);
+       }
 }
 
 /*
@@ -2049,7 +2057,7 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb
        // if it's a client command and no command was found, say so.
        if (cmd->source == src_client)
        {
-               Con_Printf("player \"%s\" tried to %s\n", host_client->name, text);
+               Con_Printf("Client \"%s\" tried to execute \"%s\"\n", host_client->name, text);
                goto done;
        }
 
@@ -2064,9 +2072,13 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb
        }
 
 // check cvars
-       if (!Cvar_Command(cmd) && host_framecount > 0)
-               Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0));
-
+       if (!Cvar_Command(cmd) && host_framecount > 0) {
+               if (cmd == &cmd_clientfromserver) {
+                       Con_Printf("Server tried to execute \"%s\"\n", Cmd_Argv(cmd, 0));
+               } else {
+                       Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0));
+               }
+       }
 done:
        cmd->tokenizebufferpos = oldpos;
        if (lockmutex)