All pastes #608922 Raw Edit

Something

public c v1 · immutable
·published 2007-07-08 15:53 UTC
rendered paste body
/*===============Cmd_If_fCompares two cvars, if true vstr the third, if false vstr the forth===============*/void Cmd_If_f( void ) {  char	*v;  int 	v1;  int 	v2;  char	*vt;  char	*vf;  char  *op;    if (Cmd_Argc () == 6) {    v1 = Cvar_VariableIntegerValue( Cmd_Argv( 1 ) );    op = Cmd_Argv( 2 );    v2 = Cvar_VariableIntegerValue( Cmd_Argv( 3 ) );    vt = Cvar_VariableString( Cmd_Argv( 4 ) );    vf = Cvar_VariableString( Cmd_Argv( 5 ) );    if ( !strcmp( op, "=" ) && v1 == v2 )    {      v = vt;    }    else if ( !strcmp( op, "=" ) && v1 != v2 )    {      v = vf;    }    else if ( !strcmp( op, "<" ) && v1 < v2 )    {      v = vt;    }    else if ( !strcmp( op, "<" ) && v1 >= v2 )    {      v = vf;    }    else if ( !strcmp( op, ">" ) && v1 > v2 )    {      v = vt;    }    else if ( !strcmp( op, ">" ) && v1 <= v2 )    {      v = vf;    }    else    {      Com_Printf ("invalid operator in if command. valid operators are = < >\n");      return;    }  }  else {    Com_Printf ("if <variablename> <operator> <variablename> <variablename> <variable name> <: compares the first two variable names and executes the third if true, the last optional one if false\n");    return;  }  Cbuf_InsertText( va("%s\n", v ) );}