- Applied patch from /dev/humancontroller to set cvar_modifiedFlags from Cvar_Set_f (#3636)

- Exchanged ugly code with Cmd_ArgsFrom()
This commit is contained in:
Thilo Schulz 2009-10-19 16:52:16 +00:00
parent 118fbdf741
commit 585e6f9840

View file

@ -739,12 +739,12 @@ weren't declared in C code.
============ ============
*/ */
void Cvar_Set_f( void ) { void Cvar_Set_f( void ) {
int i, c, l, len; int c;
char cmd[5], combined[MAX_STRING_TOKENS]; char *cmd;
cvar_t *v; cvar_t *v;
c = Cmd_Argc(); c = Cmd_Argc();
Q_strncpyz( cmd, Cmd_Argv(0), sizeof( cmd ) ); cmd = Cmd_Argv(0);
if ( c < 2 ) { if ( c < 2 ) {
Com_Printf ("usage: %s <variable> <value>\n", cmd); Com_Printf ("usage: %s <variable> <value>\n", cmd);
@ -755,35 +755,28 @@ void Cvar_Set_f( void ) {
return; return;
} }
combined[0] = 0; v = Cvar_Set2 (Cmd_Argv(1), Cmd_ArgsFrom(2), qfalse);
l = 0;
for ( i = 2 ; i < c ; i++ ) {
len = strlen ( Cmd_Argv( i ) + 1 );
if ( l + len >= MAX_STRING_TOKENS - 2 ) {
break;
}
strcat( combined, Cmd_Argv( i ) );
if ( i != c-1 ) {
strcat( combined, " " );
}
l += len;
}
v = Cvar_Set2 (Cmd_Argv(1), combined, qfalse);
if( !v ) { if( !v ) {
return; return;
} }
switch( cmd[3] ) { switch( cmd[3] ) {
default: case 'a':
case '\0': if( !( v->flags & CVAR_ARCHIVE ) ) {
v->flags |= CVAR_ARCHIVE;
cvar_modifiedFlags |= CVAR_ARCHIVE;
}
break; break;
case 'u': case 'u':
v->flags |= CVAR_USERINFO; if( !( v->flags & CVAR_USERINFO ) ) {
v->flags |= CVAR_USERINFO;
cvar_modifiedFlags |= CVAR_USERINFO;
}
break; break;
case 's': case 's':
v->flags |= CVAR_SERVERINFO; if( !( v->flags & CVAR_SERVERINFO ) ) {
break; v->flags |= CVAR_SERVERINFO;
case 'a': cvar_modifiedFlags |= CVAR_SERVERINFO;
v->flags |= CVAR_ARCHIVE; }
break; break;
} }
} }