示例#1
0
/*
============
idInternalCVar::Update
============
*/
void idInternalCVar::Update( const idCVar *cvar )
{

    // if this is a statically declared variable
    if ( cvar->GetFlags() & CVAR_STATIC )
    {

        if ( flags & CVAR_STATIC )
        {

            // the code has more than one static declaration of the same variable, make sure they have the same properties
            if ( resetString.Icmp( cvar->GetString() ) != 0 )
            {
                common->Warning( "CVar '%s' declared multiple times with different initial value", nameString.c_str() );
            }
            if ( ( flags & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) != ( cvar->GetFlags() & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) )
            {
                common->Warning( "CVar '%s' declared multiple times with different type", nameString.c_str() );
            }
            if ( valueMin != cvar->GetMinValue() || valueMax != cvar->GetMaxValue() )
            {
                common->Warning( "CVar '%s' declared multiple times with different minimum/maximum", nameString.c_str() );
            }

        }

        // the code is now specifying a variable that the user already set a value for, take the new value as the reset value
        resetString = cvar->GetString();
        descriptionString = cvar->GetDescription();
        description = descriptionString.c_str();
        valueMin = cvar->GetMinValue();
        valueMax = cvar->GetMaxValue();
        Mem_Free( valueStrings );
        valueStrings = CopyValueStrings( cvar->GetValueStrings() );
        valueCompletion = cvar->GetValueCompletion();
        UpdateValue();
        cvarSystem->SetModifiedFlags( cvar->GetFlags() );
    }

    flags |= cvar->GetFlags();

    UpdateCheat();

    // only allow one non-empty reset string without a warning
    if ( resetString.Length() == 0 )
    {
        resetString = cvar->GetString();
    }
    else if ( cvar->GetString()[0] && resetString.Cmp( cvar->GetString() ) != 0 )
    {
        common->Warning( "cvar \"%s\" given initial values: \"%s\" and \"%s\"\n", nameString.c_str(), resetString.c_str(), cvar->GetString() );
    }
}
示例#2
0
/*
============
idInternalCVar::idInternalCVar
============
*/
idInternalCVar::idInternalCVar( const idCVar *cvar ) {
	nameString = cvar->GetName();
	name = nameString.c_str();
	valueString = cvar->GetString();
	value = valueString.c_str();
	resetString = cvar->GetString();
	descriptionString = cvar->GetDescription();
	description = descriptionString.c_str();
	flags = cvar->GetFlags() | CVAR_MODIFIED;
	valueMin = cvar->GetMinValue();
	valueMax = cvar->GetMaxValue();
	valueStrings = CopyValueStrings( cvar->GetValueStrings() );
	valueCompletion = cvar->GetValueCompletion();
	UpdateValue();
	UpdateCheat();
	internalVar = this;
}