[quake3-commits] r1684 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Oct 19 12:52:16 EDT 2009


Author: thilo
Date: 2009-10-19 12:52:16 -0400 (Mon, 19 Oct 2009)
New Revision: 1684

Modified:
   trunk/code/qcommon/cvar.c
Log:
- Applied patch from /dev/humancontroller to set cvar_modifiedFlags from Cvar_Set_f (#3636)
- Exchanged ugly code with Cmd_ArgsFrom()



Modified: trunk/code/qcommon/cvar.c
===================================================================
--- trunk/code/qcommon/cvar.c	2009-10-19 16:16:52 UTC (rev 1683)
+++ trunk/code/qcommon/cvar.c	2009-10-19 16:52:16 UTC (rev 1684)
@@ -739,12 +739,12 @@
 ============
 */
 void Cvar_Set_f( void ) {
-	int		i, c, l, len;
-	char	cmd[5], combined[MAX_STRING_TOKENS];
-	cvar_t *v;
+	int		c;
+	char	*cmd;
+	cvar_t	*v;
 
 	c = Cmd_Argc();
-	Q_strncpyz( cmd, Cmd_Argv(0), sizeof( cmd ) );
+	cmd = Cmd_Argv(0);
 
 	if ( c < 2 ) {
 		Com_Printf ("usage: %s <variable> <value>\n", cmd);
@@ -755,36 +755,29 @@
 		return;
 	}
 
-	combined[0] = 0;
-	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);
+	v = Cvar_Set2 (Cmd_Argv(1), Cmd_ArgsFrom(2), qfalse);
 	if( !v ) {
 		return;
 	}
 	switch( cmd[3] ) {
-		default:
-		case '\0':
+		case 'a':
+			if( !( v->flags & CVAR_ARCHIVE ) ) {
+				v->flags |= CVAR_ARCHIVE;
+				cvar_modifiedFlags |= CVAR_ARCHIVE;
+			}
 			break;
 		case 'u':
-			v->flags |= CVAR_USERINFO;
+			if( !( v->flags & CVAR_USERINFO ) ) {
+				v->flags |= CVAR_USERINFO;
+				cvar_modifiedFlags |= CVAR_USERINFO;
+			}
 			break;
 		case 's':
-			v->flags |= CVAR_SERVERINFO;
+			if( !( v->flags & CVAR_SERVERINFO ) ) {
+				v->flags |= CVAR_SERVERINFO;
+				cvar_modifiedFlags |= CVAR_SERVERINFO;
+			}
 			break;
-		case 'a':
-			v->flags |= CVAR_ARCHIVE;
-			break;
 	}
 }
 



More information about the quake3-commits mailing list