]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
this patch adds a number of stereo viewing modes (shutter glasses and video glasses...
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index 5d6121d151fd968054fc66d07f163d41a1347d26..2e134d7885047530f1a227f5168ae765ed5c1281 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -115,25 +115,25 @@ void Cbuf_InsertText (const char *text)
        char    *temp;
        int             templen;
 
-// copy off any commands still remaining in the exec buffer
+       // copy off any commands still remaining in the exec buffer
        templen = cmd_text.cursize;
        if (templen)
        {
-               temp = Z_Malloc (templen);
+               temp = Mem_Alloc (tempmempool, templen);
                memcpy (temp, cmd_text.data, templen);
                SZ_Clear (&cmd_text);
        }
        else
-               temp = NULL;    // shut up compiler
+               temp = NULL;
 
-// add the entire text of the file
+       // add the entire text of the file
        Cbuf_AddText (text);
 
-// add the copied off data
-       if (templen)
+       // add the copied off data
+       if (temp != NULL)
        {
                SZ_Write (&cmd_text, temp, templen);
-               Z_Free (temp);
+               Mem_Free (temp);
        }
 }
 
@@ -158,8 +158,6 @@ void Cbuf_Execute (void)
                text = (char *)cmd_text.data;
 
                quotes = 0;
-               while (*text && *text <= ' ')
-                       text++;
                for (i=0 ; i< cmd_text.cursize ; i++)
                {
                        if (text[i] == '"')
@@ -183,7 +181,7 @@ void Cbuf_Execute (void)
                {
                        i++;
                        cmd_text.cursize -= i;
-                       memcpy (text, text+i, cmd_text.cursize);
+                       memcpy (cmd_text.data, text+i, cmd_text.cursize);
                }
 
 // execute the command line
@@ -239,7 +237,7 @@ void Cmd_StuffCmds_f (void)
        if (!s)
                return;
 
-       text = Z_Malloc (s+1);
+       text = Mem_Alloc (tempmempool, s + 1);
        text[0] = 0;
        for (i=1 ; i<com_argc ; i++)
        {
@@ -250,8 +248,8 @@ void Cmd_StuffCmds_f (void)
                        strcat (text, " ");
        }
 
-// pull out the commands
-       build = Z_Malloc (s+1);
+       // pull out the commands
+       build = Mem_Alloc (tempmempool, s + 1);
        build[0] = 0;
 
        for (i=0 ; i<s-1 ; i++)
@@ -276,8 +274,8 @@ void Cmd_StuffCmds_f (void)
        if (build[0])
                Cbuf_InsertText (build);
 
-       Z_Free (text);
-       Z_Free (build);
+       Mem_Free (text);
+       Mem_Free (build);
 }
 
 
@@ -296,7 +294,7 @@ static void Cmd_Exec_f (void)
                return;
        }
 
-       f = (char *)FS_LoadFile (Cmd_Argv(1), false);
+       f = (char *)FS_LoadFile (Cmd_Argv(1), tempmempool, false);
        if (!f)
        {
                Con_Printf("couldn't exec %s\n",Cmd_Argv(1));
@@ -332,15 +330,6 @@ Cmd_Alias_f
 Creates a new command that executes a command string (possibly ; seperated)
 ===============
 */
-static char *CopyString (char *in)
-{
-       char *out;
-
-       out = Z_Malloc (strlen(in)+1);
-       strcpy (out, in);
-       return out;
-}
-
 static void Cmd_Alias_f (void)
 {
        cmdalias_t      *a;
@@ -392,7 +381,8 @@ static void Cmd_Alias_f (void)
        }
        strlcat (cmd, "\n", sizeof (cmd));
 
-       a->value = CopyString (cmd);
+       a->value = Z_Malloc (strlen (cmd) + 1);
+       strcpy (a->value, cmd);
 }
 
 /*