For those who ever tried the “cvar” script actions: it’s been partially broken ever since the Era of Sock. More specifically: inc allways increases with 1 although it requires a parameter and set, bitset, bitreset and random do not work at all.
Since I intend to use the cvar command to store map-persistant data (usefull for 2 maps “talking” to each other) I wrote a small fix. Beware that this allows a map script to change any cvar to any numeric value it wants. (Though it has allready been possible before to mess with cvars using the “inc” command. For example, cheats can be turned on in W:ET 2.60 from a map script.)
g_script_actions.c @ 4040
if (!Q_stricmp(lastToken, "inc")) {
if (!token[0]) {
G_Error( "G_Scripting: cvar %s requires a parameter
", lastToken );
}
- trap_Cvar_Set( cvarName, va("%i", cvarValue+1) );
+ trap_Cvar_Set( cvarName, va( "%i", cvarValue + atoi( token ) ) );
} else if (!Q_stricmp(lastToken, "abort_if_less_than")) {
g_script_actions.c @ 4077
} else if (!Q_stricmp(lastToken, "bitset")) {
if (!token[0]) {
G_Error( "G_Scripting: cvar %s requires a parameter
", lastToken );
}
cvarValue |= (1<<atoi(token));
+ trap_Cvar_Set( cvarName, va( "%i", cvarValue ) );
} else if (!Q_stricmp(lastToken, "bitreset")) {
if (!token[0]) {
G_Error( "G_Scripting: cvar %s requires a parameter
", lastToken );
}
cvarValue &= ~(1<<atoi(token));
+ trap_Cvar_Set( cvarName, va( "%i", cvarValue ) );
} else if (!Q_stricmp(lastToken, "abort_if_bitset")) {
g_script_actions.c @ 4105
} else if (!Q_stricmp(lastToken, "set")) {
if (!token[0]) {
G_Error( "G_Scripting: cvar %s requires a parameter
", lastToken );
}
- cvarValue = atoi(token);
+ trap_Cvar_Set( cvarName, va( "%i", atoi( token ) ) );
} else if (!Q_stricmp(lastToken, "random")) {
if (!token[0]) {
G_Error( "G_Scripting: cvar %s requires a parameter
", lastToken );
}
cvarValue = rand() % atoi(token);
+ trap_Cvar_Set( cvarName, va( "%i", cvarValue ) );
} else if (!Q_stricmp(lastToken, "trigger_if_equal")) {