예제 #1
0
파일: main.cpp 프로젝트: janisl/jlquake
static void CLQ2_Pause_f() {
	// never pause in multiplayer
	if ( Cvar_VariableValue( "maxclients" ) > 1 || !ComQ2_ServerState() ) {
		Cvar_SetValueLatched( "paused", 0 );
		return;
	}

	Cvar_SetValueLatched( "paused", !cl_paused->value );
}
예제 #2
0
/*
===============
Cmd_Random_f

Give a random integer
===============
*/
void Cmd_Random_f( void ) {
	int 	v1;
	int 	v2;

	if (Cmd_Argc() == 4) {
		v1 = atoi(Cmd_Argv(2));
		v2 = atoi(Cmd_Argv(3));
		Cvar_SetValueLatched(Cmd_Argv(1), (int)(rand() / (float)RAND_MAX * (MAX(v1, v2) - MIN(v1, v2)) + MIN(v1, v2)));
	} else {
		Com_Printf("random <variableToSet> <value1> <value2>\n");
	}
}
예제 #3
0
/*
===============
Cmd_Math_f

Does math and saves the result to a cvar
===============
*/
void Cmd_Math_f( void ) {
	char	*v;
	char 	*v1;
	char 	*v2;
	char  *op;
	if (Cmd_Argc () == 3)
	{
		v = Cmd_Argv( 1 );
		op = Cmd_Argv( 2 );
		if ( !strcmp( op, "++" ) ) {
			Cvar_SetValueLatched( v, Cvar_VariableValue( v ) + 1 );
		}
		else if ( !strcmp( op, "--" ) )	{
			Cvar_SetValueLatched( v, Cvar_VariableValue( v ) - 1 );
		}
		else
		{
			Com_Printf ("math <variableToSet> = <value1> <operator> <value2>\nmath <variableToSet> <operator> <value1>\nmath <variableToSet> ++\nmath <variableToSet> --\nvalid operators are + - * / \n");
			return;
		}
	}
	else if (Cmd_Argc () == 4)
	{
		v = Cmd_Argv( 1 );
		op = Cmd_Argv( 2 );
		v1 = Cmd_Argv( 3 );
		if ( !strcmp( op, "+" ) ) {
			Cvar_SetValueLatched( v, ( atof( v ) + atof( v1 ) ) );
		}
		else if ( !strcmp( op, "-" ) ) {
			Cvar_SetValueLatched( v, ( atof( v ) - atof( v1 ) ) );
		}
		else if ( !strcmp( op, "*" ) ) {
			Cvar_SetValueLatched( v, ( atof( v ) * atof( v1 ) ) );
		}
		else if ( !strcmp( op, "/" ) ) {
			if ( atof( v1 ) == 0.f )
			{
				Com_Printf ("Cannot divide by 0!\n");
				return;
			}
			Cvar_SetValueLatched( v, ( atof( v ) / atof( v1 ) ) );
		}
		else
		{
			Com_Printf ("math <variableToSet> = <value1> <operator> <value2>\nmath <variableToSet> <operator> <value1>\nmath <variableToSet> ++\nmath <variableToSet> --\nvalid operators are + - * / \n");
			return;
		}
	}
	else if (Cmd_Argc () == 6)
	{
		v = Cmd_Argv( 1 );
		v1 = Cmd_Argv( 3 );
		op = Cmd_Argv( 4 );
		v2 = Cmd_Argv( 5 );
		if ( !strcmp( op, "+" ) ) {
			Cvar_SetValueLatched( v, ( atof( v1 ) + atof( v2 ) ) );
		}
		else if ( !strcmp( op, "-" ) ) {
			Cvar_SetValueLatched( v, ( atof( v1 ) - atof( v2 ) ) );
		}
		else if ( !strcmp( op, "*" ) ) {
			Cvar_SetValueLatched( v, ( atof( v1 ) * atof( v2 ) ) );
		}
		else if ( !strcmp( op, "/" ) ) {
			if ( atof( v2 ) == 0.f )
			{
				Com_Printf ("Cannot divide by 0!\n");
				return;
			}
			Cvar_SetValueLatched( v, ( atof( v1 ) / atof( v2 ) ) );
		}
		else
		{
			Com_Printf ("math <variableToSet> = <value1> <operator> <value2>\nmath <variableToSet> <operator> <value1>\nmath <variableToSet> ++\nmath <variableToSet> --\nvalid operators are + - * / \n");
			return;
		}
	}
	else {
		Com_Printf ("math <variableToSet> = <value1> <operator> <value2>\nmath <variableToSet> <operator> <value1>\nmath <variableToSet> ++\nmath <variableToSet> --\nvalid operators are + - * / \n");
		return;
	}
}