]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
qw support is 99% working
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index c1839648f26a2404d6704942b0d16baf3c9028da..b042cd28b3de7cccffaacb127bb2ad099d1f7db3 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -434,13 +434,10 @@ static void Cmd_PreprocessString( const char *intext, char *outtext, unsigned ma
                        // $<number> is replaced with an argument to this alias (or copied as-is if no such parameter exists), can be multiple digits
                        if( *in == '$' ) {
                                outtext[outlen++] = *in++;
-                       } else if( *in == '*' ) {
+                       } else if( *in == '*' && alias ) {
                                const char *linein = Cmd_Args();
 
-                               if( !alias )
-                                       continue;
-                               
-                               // include all params
+                               // include all parameters
                                if (linein) {
                                        while( *linein && outlen < maxoutlen ) {
                                                outtext[outlen++] = *linein++;
@@ -448,13 +445,10 @@ static void Cmd_PreprocessString( const char *intext, char *outtext, unsigned ma
                                }
 
                                in++;
-                       } else if( '0' <= *in && *in <= '9' ) {
+                       } else if( '0' <= *in && *in <= '9' && alias ) {
                                char *nexttoken;
                                int argnum;
 
-                               if( !alias )
-                                       continue;
-
                                argnum = strtol( in, &nexttoken, 10 );
 
                                if( 0 <= argnum && argnum < Cmd_Argc() ) {
@@ -479,7 +473,11 @@ static void Cmd_PreprocessString( const char *intext, char *outtext, unsigned ma
                                        }
                                        in = tempin;
                                } else {
-                                       Con_Printf( "Warning: could not find cvar %s when expanding alias %s\n    %s\n", com_token, alias->name, alias->value );
+                                       if( alias ) {
+                                               Con_Printf( "Warning: could not find cvar %s when expanding alias %s\n    %s\n", com_token, alias->name, alias->value );
+                                       } else {
+                                               Con_Printf( "Warning: could not find cvar %s\n", com_token );
+                                       }
                                        outtext[outlen++] = '$';
                                }
                        }
@@ -504,7 +502,9 @@ static void Cmd_ExecuteAlias (cmdalias_t *alias)
 {
        static char buffer[ MAX_INPUTLINE + 2 ];
        Cmd_PreprocessString( alias->value, buffer, sizeof(buffer) - 2, alias );
-       Cbuf_AddText( buffer );
+       // insert at start of command buffer, so that aliases execute in order
+       // (fixes bug introduced by Black on 20050705)
+       Cbuf_InsertText( buffer );
 }
 
 /*
@@ -1030,14 +1030,17 @@ void Cmd_ForwardStringToServer (const char *s)
                return;
        }
 
-       if (cls.demoplayback)
-               return;         // not really connected
+       if (!cls.netcon)
+               return;
 
        // LordHavoc: thanks to Fuh for bringing the pure evil of SZ_Print to my
        // attention, it has been eradicated from here, its only (former) use in
        // all of darkplaces.
-       MSG_WriteByte(&cls.message, clc_stringcmd);
-       SZ_Write(&cls.message, (const unsigned char *)s, (int)strlen(s) + 1);
+       if (cls.protocol == PROTOCOL_QUAKEWORLD)
+               MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
+       else
+               MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
+       SZ_Write(&cls.netcon->message, (const unsigned char *)s, (int)strlen(s) + 1);
 }
 
 /*