Moved the $cvar parser to Cmd_TokenizeString.
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index 870f180..3a15737 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -598,6 +598,29 @@ static void Cmd_TokenizeString (const char *text)
                if (!COM_ParseTokenConsole(&text))
                        return;
 
+               // check for $cvar 
+               // (perhaps use another target buffer?)
+               if (com_token[0] == '$' && com_token[1]) 
+               {
+                       cvar_t *cvar;
+
+                       cvar = Cvar_FindVar(&com_token[1]);
+                       if (cvar)
+                       {
+                               strcpy(com_token, cvar->string);
+                       }
+                       else if( com_token[1] == '$' )
+                       {
+                               // remove the first $
+                               char *pos;
+                       
+                               for( pos = com_token ; *pos ; pos++ )
+                               {
+                                       *pos = *(pos + 1);
+                               }
+                       }
+               }
+
                if (cmd_argc < MAX_ARGS)
                {
                        l = (int)strlen(com_token) + 1;