Exemplo n.º 1
0
/*
================
idCameraPosition::parseToken
================
*/
bool idCameraPosition::parseToken( const idStr &key, idParser *src ) {
	idToken token;

	if ( !key.Icmp( "time" ) ) {
		time = src->ParseInt();
		return true;
	}
	else if ( !key.Icmp( "type" ) ) {
		type = static_cast<idCameraPosition::positionType> ( src->ParseInt() );
		return true;
	}
	else if ( !key.Icmp( "velocity" ) ) {
		long t = atol(token);
		long d = src->ParseInt();
		float s = src->ParseFloat();
		addVelocity(t, d, s);
		return true;
	}
	else if ( !key.Icmp( "baseVelocity" ) ) {
		baseVelocity = src->ParseFloat();
		return true;
	}
	else if ( !key.Icmp( "name" ) ) {
		src->ReadToken( &token );
		name = token;
		return true;
	}
	else {
		src->Error( "unknown camera position key: %s", key.c_str() );
		return false;
	}
}
Exemplo n.º 2
0
/*
================
CPathTreeCtrl::FindItem

Find the given path in the tree.
================
*/
HTREEITEM CPathTreeCtrl::FindItem( const idStr &pathName ) {
	int lastSlash;
	idStr path, tmpPath, itemName;
	HTREEITEM item, parentItem;

	parentItem = NULL;
	item = GetRootItem();

	lastSlash = pathName.Last( '/' );

	while( item && lastSlash > path.Length() ) {
		itemName = GetItemText( item );
		tmpPath = path + itemName;
		if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) {
			parentItem = item;
			item = GetChildItem( item );
			path = tmpPath + "/";
		} else {
			item = GetNextSiblingItem( item );
		}
	}

	for ( item = GetChildItem( parentItem ); item; item = GetNextSiblingItem( item ) ) {
		itemName = GetItemText( item );
		if ( pathName.Icmp( path + itemName ) == 0 ) {
			return item;
		}
	}

	return NULL;
}
Exemplo n.º 3
0
/*
============
idAASLocal::Init
============
*/
bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
	if ( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
		gameLocal.Printf( "Keeping %s\n", file->GetName() );
		RemoveAllObstacles();
	}
	else {
		Shutdown();

		file = AASFileManager->LoadAAS( mapName, mapFileCRC );
		if ( !file ) {
			common->DWarning( "Couldn't load AAS file: '%s'", mapName.c_str() );
			return false;
		}
// RAVEN BEGIN
// rhummer: Check if this is a dummy file, since it really has no valid data dump it.
		else if ( file->IsDummyFile( mapFileCRC ) ) {
			AASFileManager->FreeAAS( file );
			file = NULL;
			return false;
		}
// RAVEN END
		SetupRouting();
	}
	return true;
}
Exemplo n.º 4
0
/*
============
idInternalCVar::Set
============
*/
void idInternalCVar::Set( const char *newValue, bool force, bool fromServer )
{
    if ( session && session->IsMultiplayer() && !fromServer )
    {
#ifndef ID_TYPEINFO
        if ( ( flags & CVAR_NETWORKSYNC ) && idAsyncNetwork::client.IsActive() )
        {
            common->Printf( "%s is a synced over the network and cannot be changed on a multiplayer client.\n", nameString.c_str() );
#if ID_ALLOW_CHEATS
            common->Printf( "ID_ALLOW_CHEATS override!\n" );
#else
            return;
#endif
        }
#endif
        if ( ( flags & CVAR_CHEAT ) && !cvarSystem->GetCVarBool( "net_allowCheats" ) )
        {
            common->Printf( "%s cannot be changed in multiplayer.\n", nameString.c_str() );
#if ID_ALLOW_CHEATS
            common->Printf( "ID_ALLOW_CHEATS override!\n" );
#else
            return;
#endif
        }
    }

    if ( !newValue )
    {
        newValue = resetString.c_str();
    }

    if ( !force )
    {
        if ( flags & CVAR_ROM )
        {
            common->Printf( "%s is read only.\n", nameString.c_str() );
            return;
        }

        if ( flags & CVAR_INIT )
        {
            common->Printf( "%s is write protected.\n", nameString.c_str() );
            return;
        }
    }

    if ( valueString.Icmp( newValue ) == 0 )
    {
        return;
    }

    valueString = newValue;
    value = valueString.c_str();
    UpdateValue();

    SetModified();
    cvarSystem->SetModifiedFlags( flags );
}
Exemplo n.º 5
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() );
    }
}
Exemplo n.º 6
0
/*
============
idAASLocal::Init
============
*/
bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
	if( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
		common->Printf( "Keeping %s\n", file->GetName() );
		RemoveAllObstacles();
	} else {
		Shutdown();
		file = AASFileManager->LoadAAS( mapName, mapFileCRC );
		if( !file ) {
			common->DWarning( "Couldn't load AAS file: '%s'", mapName.c_str() );
			return false;
		}
		SetupRouting();
	}
	return true;
}
Exemplo n.º 7
0
/*
============
idAASLocal::Init
============
*/
bool idAASLocal::Init( const idStr &mapName, const unsigned int mapFileCRC ) {
	// Clear the elevator system before reloading
	elevatorSystem->Clear();

	if ( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
		common->Printf( "Keeping %s\n", file->GetName() );
		RemoveAllObstacles();
	}
	else {
		Shutdown();

		file = AASFileManager->LoadAAS( mapName, mapFileCRC );
		if ( !file ) {
			common->DWarning( "Couldn't load AAS file: '%s'", mapName.c_str() );
			return false;
		}
		mapName.ExtractFileExtension(name);

		SetupRouting();
	}
	return true;
}
Exemplo n.º 8
0
/*
============
idInternalCVar::UpdateValue
============
*/
void idInternalCVar::UpdateValue( void ) {
	bool clamped = false;

	if ( flags & CVAR_BOOL ) {
		integerValue = ( atoi( value ) != 0 );
		floatValue = integerValue;
		if ( idStr::Icmp( value, "0" ) != 0 && idStr::Icmp( value, "1" ) != 0 ) {
			valueString = idStr( (bool)( integerValue != 0 ) );
			value = valueString.c_str();
		}
	} else if ( flags & CVAR_INTEGER ) {
		integerValue = (int)atoi( value );
		if ( valueMin < valueMax ) {
			if ( integerValue < valueMin ) {
				integerValue = (int)valueMin;
				clamped = true;
			} else if ( integerValue > valueMax ) {
				integerValue = (int)valueMax;
				clamped = true;
			}
		}
		if ( clamped || !idStr::IsNumeric( value ) || idStr::FindChar( value, '.' ) ) {
			valueString = idStr( integerValue );
			value = valueString.c_str();
		}
		floatValue = (float)integerValue;
	} else if ( flags & CVAR_FLOAT ) {
		floatValue = (float)atof( value );
		if ( valueMin < valueMax ) {
			if ( floatValue < valueMin ) {
				floatValue = valueMin;
				clamped = true;
			} else if ( floatValue > valueMax ) {
				floatValue = valueMax;
				clamped = true;
			}
		}
		if ( clamped || !idStr::IsNumeric( value ) ) {
			valueString = idStr( floatValue );
			value = valueString.c_str();
		}
		integerValue = (int)floatValue;
	} else {
		if ( valueStrings && valueStrings[0] ) {
			integerValue = 0;
			for ( int i = 0; valueStrings[i]; i++ ) {
				if ( valueString.Icmp( valueStrings[i] ) == 0 ) {
					integerValue = i;
					break;
				}
			}
			valueString = valueStrings[integerValue];
			value = valueString.c_str();
			floatValue = (float)integerValue;
		} else if ( valueString.Length() < 32 ) {
			floatValue = (float)atof( value );
			integerValue = (int)floatValue;
		} else {
			floatValue = 0.0f;
			integerValue = 0;
		}
	}
}