Esempio n. 1
0
/*
================
idAASFileLocal::ParsePlanes
================
*/
bool idAASFileLocal::ParsePlanes( idLexer &src )
{
    int numPlanes, i;
    idPlane plane;
    idVec4 vec;

    numPlanes = src.ParseInt();
    planeList.Resize( numPlanes );
    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    for ( i = 0; i < numPlanes; i++ )
    {
        src.ParseInt();
        if ( !src.Parse1DMatrix( 4, vec.ToFloatPtr() ) )
        {
            return false;
        }
        plane.SetNormal( vec.ToVec3() );
        plane.SetDist( vec[3] );
        planeList.Append( plane );
    }
    if ( !src.ExpectTokenString( "}" ) )
    {
        return false;
    }
    return true;
}
Esempio n. 2
0
/*
================
idAASFileLocal::ParseReachabilities
================
*/
bool idAASFileLocal::ParseReachabilities( idLexer &src, int areaNum )
{
    int num, j;
    aasArea_t *area;
    idReachability reach, *newReach;
    idReachability_Special *special;

    area = &areas[areaNum];

    num = src.ParseInt();
    src.ExpectTokenString( "{" );
    area->reach = NULL;
    area->rev_reach = NULL;
    area->travelFlags = AreaContentsTravelFlags( areaNum );
    for ( j = 0; j < num; j++ )
    {
        Reachability_Read( src, &reach );
        switch( reach.travelType )
        {
        case TFL_SPECIAL:
            newReach = special = new idReachability_Special();
            Reachability_Special_Read( src, special );
            break;
        default:
            newReach = new idReachability();
            break;
        }
        newReach->CopyBase( reach );
        newReach->fromAreaNum = areaNum;
        newReach->next = area->reach;
        area->reach = newReach;
    }
    src.ExpectTokenString( "}" );
    return true;
}
Esempio n. 3
0
/*
================
idTypeInfoTools::ParseTemplateArguments
================
*/
bool idTypeInfoTools::ParseTemplateArguments( idLexer &src, idStr &arguments ) {
	int indent;
	idToken token;

	arguments = "";

	if ( !src.ExpectTokenString( "<" ) ) {
		return false;
	}

	indent = 1;
	while( indent ) {
		if ( !src.ReadToken( &token ) ) {
			break;
		}
		if ( token == "<" ) {
			indent++;
		} else if ( token == ">" ) {
			indent--;
		} else {
			if ( arguments.Length() ) {
				arguments += " ";
			}
			arguments += token;
		}
	}
	return true;
}
Esempio n. 4
0
/*
============
idAASSettings::ParseFloat
============
*/
bool idAASSettings::ParseFloat( idLexer &src, float &f ) {
	if ( !src.ExpectTokenString( "=" ) ) {
		return false;
	}
	f = src.ParseFloat();
	return true;
}
Esempio n. 5
0
/*
================
idAASFileLocal::ParseClusters
================
*/
bool idAASFileLocal::ParseClusters( idLexer &src )
{
    int numClusters, i;
    aasCluster_t cluster;

    numClusters = src.ParseInt();
    clusters.Resize( numClusters );
    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    for ( i = 0; i < numClusters; i++ )
    {
        src.ParseInt();
        src.ExpectTokenString( "(" );
        cluster.numAreas = src.ParseInt();
        cluster.numReachableAreas = src.ParseInt();
        cluster.firstPortal = src.ParseInt();
        cluster.numPortals = src.ParseInt();
        src.ExpectTokenString( ")" );
        clusters.Append( cluster );
    }
    if ( !src.ExpectTokenString( "}" ) )
    {
        return false;
    }
    return true;
}
Esempio n. 6
0
/*
============
idAASSettings::ParseBool
============
*/
bool idAASSettings::ParseBool( idLexer &src, bool &b ) {
	if ( !src.ExpectTokenString( "=" ) ) {
		return false;
	}
	b = src.ParseBool();
	return true;
}
Esempio n. 7
0
/*
============
idAASSettings::ParseInt
============
*/
bool idAASSettings::ParseInt( idLexer &src, int &i ) {
	if ( !src.ExpectTokenString( "=" ) ) {
		return false;
	}
	i = src.ParseInt();
	return true;
}
Esempio n. 8
0
/*
================
idAASFileLocal::ParseVertices
================
*/
bool idAASFileLocal::ParseVertices( idLexer &src )
{
    int numVertices, i;
    idVec3 vec;

    numVertices = src.ParseInt();
    vertices.Resize( numVertices );
    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    for ( i = 0; i < numVertices; i++ )
    {
        src.ParseInt();
        if ( !src.Parse1DMatrix( 3, vec.ToFloatPtr() ) )
        {
            return false;
        }
        vertices.Append( vec );
    }
    if ( !src.ExpectTokenString( "}" ) )
    {
        return false;
    }
    return true;
}
Esempio n. 9
0
/*
====================
idRenderModelMD5::ParseJoint
====================
*/
void idRenderModelMD5::ParseJoint( idLexer& parser, idMD5Joint* joint, idJointQuat* defaultPose )
{
	//
	// parse name
	//
	idToken	token;
	parser.ReadToken( &token );
	joint->name = token;
	
	//
	// parse parent
	//
	int num = parser.ParseInt();
	if( num < 0 )
	{
		joint->parent = NULL;
	}
	else
	{
		if( num >= joints.Num() - 1 )
		{
			parser.Error( "Invalid parent for joint '%s'", joint->name.c_str() );
		}
		joint->parent = &joints[ num ];
	}
	
	//
	// parse default pose
	//
	parser.Parse1DMatrix( 3, defaultPose->t.ToFloatPtr() );
	parser.Parse1DMatrix( 3, defaultPose->q.ToFloatPtr() );
	defaultPose->q.w = defaultPose->q.CalcW();
}
/*
================
idTypeInfoTools::VerifyVariable
================
*/
void idTypeInfoTools::VerifyVariable( const char *varName, const char *varType, const char *scope, const char *prefix, const char *postfix, const char *value, const void *varPtr, int varSize ) {
	idToken token;

	if ( typeError ) {
		return;
	}

	src->SkipUntilString( "=" );
	src->ExpectTokenType( TT_STRING, 0, &token );
	if ( token.Cmp( value ) != 0 ) {

		// NOTE: skip several things

		if ( IsRenderHandleVariable( varName, varType, scope, prefix, postfix, value ) ) {
			return;
		}

		if ( IsAllowedToChangedFromSaveGames( varName, varType, scope, prefix, postfix, value ) ) {
			return;
		}

		src->Warning( "state diff for %s%s::%s%s\n%s\n%s", prefix, scope, varName, postfix, token.c_str(), value );
		typeError = true;
	}
}
Esempio n. 11
0
/*
============
idAASSettings::ParseVector
============
*/
bool idAASSettings::ParseVector( idLexer &src, idVec3 &vec )
{
    if ( !src.ExpectTokenString( "=" ) )
    {
        return false;
    }
    return ( src.Parse1DMatrix( 3, vec.ToFloatPtr() ) != 0 );
}
Esempio n. 12
0
/*
================
idAASFileLocal::ParsePortals
================
*/
bool idAASFileLocal::ParsePortals( idLexer &src )
{
    int numPortals, i;
    aasPortal_t portal;

    numPortals = src.ParseInt();
    portals.Resize( numPortals );
    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    for ( i = 0; i < numPortals; i++ )
    {
        src.ParseInt();
        src.ExpectTokenString( "(" );
        portal.areaNum = src.ParseInt();
        portal.clusters[0] = src.ParseInt();
        portal.clusters[1] = src.ParseInt();
        portal.clusterAreaNum[0] = src.ParseInt();
        portal.clusterAreaNum[1] = src.ParseInt();
        src.ExpectTokenString( ")" );
        portals.Append( portal );
    }
    if ( !src.ExpectTokenString( "}" ) )
    {
        return false;
    }
    return true;
}
Esempio n. 13
0
/*
================
Reachability_Special_Read
================
*/
bool Reachability_Special_Read( idLexer &src, idReachability_Special *reach ) {
	idToken key, value;

	src.ExpectTokenString( "{" );
	while( src.ReadToken( &key ) ) {
		if ( key == "}" ) {
			return true;
		}
		src.ExpectTokenType( TT_STRING, 0, &value );
		reach->dict.Set( key, value );
	}
	return false;
}
Esempio n. 14
0
/*
================
idAASFileLocal::ParseNodes
================
*/
bool idAASFileLocal::ParseNodes( idLexer &src )
{
    int numNodes, i;
    aasNode_t node;

    numNodes = src.ParseInt();
    nodes.Resize( numNodes );
    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    for ( i = 0; i < numNodes; i++ )
    {
        src.ParseInt();
        src.ExpectTokenString( "(" );
        node.planeNum = src.ParseInt();
        node.children[0] = src.ParseInt();
        node.children[1] = src.ParseInt();
        src.ExpectTokenString( ")" );
        nodes.Append( node );
    }
    if ( !src.ExpectTokenString( "}" ) )
    {
        return false;
    }
    return true;
}
Esempio n. 15
0
/*
================
idDeclAF::ParseContents
================
*/
bool idDeclAF::ParseContents( idLexer &src, int &c ) const {
	idToken token;
	idStr str;

	while( src.ReadToken( &token ) ) {
		str += token;
		if ( !src.CheckTokenString( "," ) ) {
			break;
		}
		str += ",";
	}
	c = ContentsFromString( str );
	return true;
}
Esempio n. 16
0
/*
========================
ParseInOutStruct
========================
*/
void ParseInOutStruct( idLexer & src, int attribType, idList< inOutVariable_t > & inOutVars ) {
	src.ExpectTokenString( "{" );

	while( !src.CheckTokenString( "}" ) ) {
		inOutVariable_t var;

		idToken token;
		src.ReadToken( &token );
		var.type = token;
		src.ReadToken( &token );
		var.nameCg = token;

		if ( !src.CheckTokenString( ":" ) ) {
			src.SkipUntilString( ";" );
			continue;
		}

		src.ReadToken( &token );
		var.nameGLSL = token;
		src.ExpectTokenString( ";" );

		// convert the type
		for ( int i = 0; typeConversion[i].typeCG != NULL; i++ ) {
			if ( var.type.Cmp( typeConversion[i].typeCG ) == 0 ) {
				var.type = typeConversion[i].typeGLSL;
				break;
			}
		}

		// convert the semantic to a GLSL name
		for ( int i = 0; attribsPC[i].semantic != NULL; i++ ) {
			if ( ( attribsPC[i].flags & attribType ) != 0 ) {
				if ( var.nameGLSL.Cmp( attribsPC[i].semantic ) == 0 ) {
					var.nameGLSL = attribsPC[i].glsl;
					break;
				}
			}
		}

		// check if it was defined previously
		var.declareInOut = true;
		for ( int i = 0; i < inOutVars.Num(); i++ ) {
			if ( var.nameGLSL == inOutVars[i].nameGLSL ) {
				var.declareInOut = false;
				break;
			}
		}

		inOutVars.Append( var );
	}

	src.ExpectTokenString( ";" );
}
Esempio n. 17
0
/*
===================
MatchAndAppendToken
===================
*/
static void MatchAndAppendToken( idLexer &src, const char *match ) {
	if ( !src.ExpectTokenString( match ) ) {
		return;
	}
	// a matched token won't need a leading space
	idStr::Append( parseBuffer, MAX_IMAGE_NAME, match );
}
Esempio n. 18
0
/*
================
idAASFileLocal::ParseIndex
================
*/
bool idAASFileLocal::ParseIndex( idLexer &src, idList<aasIndex_t> &indexes )
{
    int numIndexes, i;
    aasIndex_t index;

    numIndexes = src.ParseInt();
    indexes.Resize( numIndexes );
    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    for ( i = 0; i < numIndexes; i++ )
    {
        src.ParseInt();
        src.ExpectTokenString( "(" );
        index = src.ParseInt();
        src.ExpectTokenString( ")" );
        indexes.Append( index );
    }
    if ( !src.ExpectTokenString( "}" ) )
    {
        return false;
    }
    return true;
}
Esempio n. 19
0
/*
================
idAASFileLocal::ParseEdges
================
*/
bool idAASFileLocal::ParseEdges( idLexer &src )
{
    int numEdges, i;
    aasEdge_t edge;

    numEdges = src.ParseInt();
    edges.Resize( numEdges );
    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    for ( i = 0; i < numEdges; i++ )
    {
        src.ParseInt();
        src.ExpectTokenString( "(" );
        edge.vertexNum[0] = src.ParseInt();
        edge.vertexNum[1] = src.ParseInt();
        src.ExpectTokenString( ")" );
        edges.Append( edge );
    }
    if ( !src.ExpectTokenString( "}" ) )
    {
        return false;
    }
    return true;
}
Esempio n. 20
0
/*
================
idDeclParticle::ParseParms

Parses a variable length list of parms on one line
================
*/
void idDeclParticle::ParseParms( idLexer &src, float *parms, int maxParms ) {
	idToken token;

	memset( parms, 0, maxParms * sizeof( *parms ) );
	int	count = 0;
	while( 1 ) {
		if ( !src.ReadTokenOnLine( &token ) ) {
			return;
		}
		if ( count == maxParms ) {
			src.Error( "too many parms on line" );
			return;
		}
		token.StripQuotes();
		parms[count] = atof( token );
		count++;
	}
}
Esempio n. 21
0
/*
============
sdGUIDFile::ParseEntry
============
*/
bool sdGUIDFile::ParseEntry( idLexer& src ) {
	// parse entry
	sdGUIDInfo newInfo;

	idDict data;
	if ( !data.Parse( src ) ) {
		return false;
	}

	idStr tempString;
	if ( data.GetString( "ip", "", tempString ) ) {
		int ip;
		if ( !IPForString( tempString.c_str(), ip ) ) {
			return false;
		}
		newInfo.SetIP( ip );
	} else if ( data.GetString( "pbid", "", tempString ) ) {
		int pbguid;
		if ( !PBGUIDForString( tempString.c_str(), pbguid ) ) {
			return false;
		}
		newInfo.SetPBID( pbguid );
	} else if ( data.GetString( "guid", "", tempString ) ) {
		sdNetClientId id;
		if ( !GUIDForString( tempString.c_str(), id ) ) {
			return false;
		}
		newInfo.SetGUID( id );
	}

	newInfo.SetAuthGroup( data.GetString( "auth_group" ) );

	const char* banText = data.GetString( "ban_time" );
	if ( *banText != '\0' ) {
		if ( !idStr::Icmp( banText, "forever" ) ) {
			newInfo.BanForever();
		} else {
			int t;
			sdProperties::sdFromString( t, banText );
			newInfo.SetBanTime( t );
		}
	}

	const char* userName = data.GetString( "user_name" );
	if ( *userName != '\0' ) {
		newInfo.SetUserName( userName );
	}

	if ( newInfo.GetMatchType() == sdGUIDInfo::MT_INVALID ) {
		src.Warning( "No match type specified" );
		return true;
	}

	info.Alloc() = newInfo;

	return true;
}
Esempio n. 22
0
void testAllToken(idLexer& lexer)
{
    idToken token{};
    while (!lexer.EndOfToken()) {
        token.Reset();
        if (lexer.GetToken(&token)) {
            LOG(debug) << "token: " << token.AsTypeStringView() << "\t\t" << token.AsStringView();
        } else {
            LOG(warning) << "get token error line: " << lexer.Line();
            break;
        }
    }

    /*
    for (auto c : lexer.GetBuffer()) {
        std::cout << c;
    }
    std::cout << "\n";
    */
}
Esempio n. 23
0
/*
================
idDeclAF::ParseSlider
================
*/
bool idDeclAF::ParseSlider( idLexer& src )
{
	idToken token;
	idDeclAF_Constraint* constraint = new( TAG_DECL ) idDeclAF_Constraint;
	
	constraint->SetDefault( this );
	constraints.Alloc() = constraint;
	
	if( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
			!src.ExpectTokenString( "{" ) )
	{
		return false;
	}
	
	constraint->type = DECLAF_CONSTRAINT_SLIDER;
	constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
	constraint->name = token;
	constraint->friction = 0.5f;
	
	while( src.ReadToken( &token ) )
	{
	
		if( !token.Icmp( "body1" ) )
		{
			src.ExpectTokenType( TT_STRING, 0, &token );
			constraint->body1 = token;
		}
		else if( !token.Icmp( "body2" ) )
		{
			src.ExpectTokenType( TT_STRING, 0, &token );
			constraint->body2 = token;
		}
		else if( !token.Icmp( "axis" ) )
		{
			if( !constraint->axis.Parse( src ) )
			{
				return false;
			}
		}
		else if( !token.Icmp( "friction" ) )
		{
			constraint->friction = src.ParseFloat();
		}
		else if( token == "}" )
		{
			break;
		}
		else
		{
			src.Error( "unknown token %s in slider", token.c_str() );
			return false;
		}
	}
	
	return true;
}
Esempio n. 24
0
/*
================
idDeclAF::ParseFixed
================
*/
bool idDeclAF::ParseFixed( idLexer &src ) {
	idToken token;
	idDeclAF_Constraint *constraint = new idDeclAF_Constraint;

	constraint->SetDefault( this );
	constraints.Alloc() = constraint;

	if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
			!src.ExpectTokenString( "{" ) ) {
		return false;
	}

	constraint->type = DECLAF_CONSTRAINT_FIXED;
	constraint->name = token;

	while( src.ReadToken( &token ) ) {

		if ( !token.Icmp( "body1" ) ) {
			src.ExpectTokenType( TT_STRING, 0, &token );
			constraint->body1 = token;
		} else if ( !token.Icmp( "body2" ) ) {
			src.ExpectTokenType( TT_STRING, 0, &token );
			constraint->body2 = token;
		} else if ( token == "}" ) {
			break;
		} else {
			src.Error( "unknown token %s in ball and socket joint", token.c_str() );
			return false;
		}
	}

	return true;
}
Esempio n. 25
0
/*
================
idDeclParticle::ParseParametric
================
*/
void idDeclParticle::ParseParametric( idLexer &src, idParticleParm *parm ) {
	idToken token;

	parm->table = NULL;
	parm->from = parm->to = 0.0f;

	if ( !src.ReadToken( &token ) ) {
		src.Error( "not enough parameters" );
		return;
	}

	if ( token.IsNumeric() ) {
		// can have a to + 2nd parm
		parm->from = parm->to = atof( token );
		if ( src.ReadToken( &token ) ) {
			if ( !token.Icmp( "to" ) ) {
				if ( !src.ReadToken( &token ) ) {
					src.Error( "missing second parameter" );
					return;
				}
				parm->to = atof( token );
			} else {
				src.UnreadToken( &token );
			}
		}
	} else {
		// table
		parm->table = static_cast<const idDeclTable *>( declManager->FindType( DECL_TABLE, token, false ) );
	}

}
Esempio n. 26
0
/*
============
idAASSettings::ParseBBoxes
============
*/
bool idAASSettings::ParseBBoxes( idLexer &src )
{
    idToken token;
    idBounds bounds;

    numBoundingBoxes = 0;

    if ( !src.ExpectTokenString( "{" ) )
    {
        return false;
    }
    while( src.ReadToken( &token ) )
    {
        if ( token == "}" )
        {
            return true;
        }
        src.UnreadToken( &token );
        src.Parse1DMatrix( 3, bounds[0].ToFloatPtr() );
        if ( !src.ExpectTokenString( "-" ) )
        {
            return false;
        }
        src.Parse1DMatrix( 3, bounds[1].ToFloatPtr() );

        boundingBoxes[numBoundingBoxes++] = bounds;
    }
    return false;
}
Esempio n. 27
0
/*
================
Reachability_Read
================
*/
bool Reachability_Read( idLexer &src, idReachability *reach ) {
	reach->travelType = src.ParseInt();
	reach->toAreaNum = src.ParseInt();
	src.Parse1DMatrix( 3, reach->start.ToFloatPtr() );
	src.Parse1DMatrix( 3, reach->end.ToFloatPtr() );
	reach->edgeNum = src.ParseInt();
	reach->travelTime = src.ParseInt();
	return true;
}
Esempio n. 28
0
/*
===============
idSoundShader::ParseShader
===============
*/
bool idSoundShader::ParseShader( idLexer &src )
{
    int			i;
    idToken		token;

    parms.minDistance = 1;
    parms.maxDistance = 10;
    parms.volume = 1;
    parms.shakes = 0;
    parms.soundShaderFlags = 0;
    parms.soundClass = 0;

    speakerMask = 0;
    altSound = NULL;

    for( i = 0; i < SOUND_MAX_LIST_WAVS; i++ )
    {
        leadins[i] = NULL;
        entries[i] = NULL;
    }
    numEntries = 0;
    numLeadins = 0;

    int	maxSamples = idSoundSystemLocal::s_maxSoundsPerShader.GetInteger();
    if ( com_makingBuild.GetBool() || maxSamples <= 0 || maxSamples > SOUND_MAX_LIST_WAVS )
    {
        maxSamples = SOUND_MAX_LIST_WAVS;
    }

    while ( 1 )
    {
        if ( !src.ExpectAnyToken( &token ) )
        {
            return false;
        }
        // end of definition
        else if ( token == "}" )
        {
            break;
        }
        // minimum number of sounds
        else if ( !token.Icmp( "minSamples" ) )
        {
            maxSamples = idMath::ClampInt( src.ParseInt(), SOUND_MAX_LIST_WAVS, maxSamples );
        }
        // description
        else if ( !token.Icmp( "description" ) )
        {
            src.ReadTokenOnLine( &token );
            desc = token.c_str();
        }
        // mindistance
        else if ( !token.Icmp( "mindistance" ) )
        {
            parms.minDistance = src.ParseFloat();
        }
        // maxdistance
        else if ( !token.Icmp( "maxdistance" ) )
        {
            parms.maxDistance = src.ParseFloat();
        }
        // shakes screen
        else if ( !token.Icmp( "shakes" ) )
        {
            src.ExpectAnyToken( &token );
            if ( token.type == TT_NUMBER )
            {
                parms.shakes = token.GetFloatValue();
            }
            else
            {
                src.UnreadToken( &token );
                parms.shakes = 1.0f;
            }
        }
        // reverb
        else if ( !token.Icmp( "reverb" ) )
        {
            int reg0 = src.ParseFloat();
            if ( !src.ExpectTokenString( "," ) )
            {
                src.FreeSource();
                return false;
            }
            int reg1 = src.ParseFloat();
            // no longer supported
        }
        // volume
        else if ( !token.Icmp( "volume" ) )
        {
            parms.volume = src.ParseFloat();
        }
        // leadinVolume is used to allow light breaking leadin sounds to be much louder than the broken loop
        else if ( !token.Icmp( "leadinVolume" ) )
        {
            leadinVolume = src.ParseFloat();
        }
        // speaker mask
        else if ( !token.Icmp( "mask_center" ) )
        {
            speakerMask |= 1<<SPEAKER_CENTER;
        }
        // speaker mask
        else if ( !token.Icmp( "mask_left" ) )
        {
            speakerMask |= 1<<SPEAKER_LEFT;
        }
        // speaker mask
        else if ( !token.Icmp( "mask_right" ) )
        {
            speakerMask |= 1<<SPEAKER_RIGHT;
        }
        // speaker mask
        else if ( !token.Icmp( "mask_backright" ) )
        {
            speakerMask |= 1<<SPEAKER_BACKRIGHT;
        }
        // speaker mask
        else if ( !token.Icmp( "mask_backleft" ) )
        {
            speakerMask |= 1<<SPEAKER_BACKLEFT;
        }
        // speaker mask
        else if ( !token.Icmp( "mask_lfe" ) )
        {
            speakerMask |= 1<<SPEAKER_LFE;
        }
        // soundClass
        else if ( !token.Icmp( "soundClass" ) )
        {
            parms.soundClass = src.ParseInt();
            if ( parms.soundClass < 0 || parms.soundClass >= SOUND_MAX_CLASSES )
            {
                src.Warning( "SoundClass out of range" );
                return false;
            }
        }
        // altSound
        else if ( !token.Icmp( "altSound" ) )
        {
            if ( !src.ExpectAnyToken( &token ) )
            {
                return false;
            }
            altSound = declManager->FindSound( token.c_str() );
        }
        // ordered
        else if ( !token.Icmp( "ordered" ) )
        {
            // no longer supported
        }
        // no_dups
        else if ( !token.Icmp( "no_dups" ) )
        {
            parms.soundShaderFlags |= SSF_NO_DUPS;
        }
        // no_flicker
        else if ( !token.Icmp( "no_flicker" ) )
        {
            parms.soundShaderFlags |= SSF_NO_FLICKER;
        }
        // plain
        else if ( !token.Icmp( "plain" ) )
        {
            // no longer supported
        }
        // looping
        else if ( !token.Icmp( "looping" ) )
        {
            parms.soundShaderFlags |= SSF_LOOPING;
        }
        // no occlusion
        else if ( !token.Icmp( "no_occlusion" ) )
        {
            parms.soundShaderFlags |= SSF_NO_OCCLUSION;
        }
        // private
        else if ( !token.Icmp( "private" ) )
        {
            parms.soundShaderFlags |= SSF_PRIVATE_SOUND;
        }
        // antiPrivate
        else if ( !token.Icmp( "antiPrivate" ) )
        {
            parms.soundShaderFlags |= SSF_ANTI_PRIVATE_SOUND;
        }
        // once
        else if ( !token.Icmp( "playonce" ) )
        {
            parms.soundShaderFlags |= SSF_PLAY_ONCE;
        }
        // global
        else if ( !token.Icmp( "global" ) )
        {
            parms.soundShaderFlags |= SSF_GLOBAL;
        }
        // unclamped
        else if ( !token.Icmp( "unclamped" ) )
        {
            parms.soundShaderFlags |= SSF_UNCLAMPED;
        }
        // omnidirectional
        else if ( !token.Icmp( "omnidirectional" ) )
        {
            parms.soundShaderFlags |= SSF_OMNIDIRECTIONAL;
        }
        // onDemand can't be a parms, because we must track all references and overrides would confuse it
        else if ( !token.Icmp( "onDemand" ) )
        {
            // no longer loading sounds on demand
            //onDemand = true;
        }

        // the wave files
        else if ( !token.Icmp( "leadin" ) )
        {
            // add to the leadin list
            if ( !src.ReadToken( &token ) )
            {
                src.Warning( "Expected sound after leadin" );
                return false;
            }
            if ( soundSystemLocal.soundCache && numLeadins < maxSamples )
            {
                leadins[ numLeadins ] = soundSystemLocal.soundCache->FindSound( token.c_str(), onDemand );
                numLeadins++;
            }
        }
        else if ( token.Find( ".wav", false ) != -1 || token.Find( ".ogg", false ) != -1 )
        {
            // add to the wav list
            if ( soundSystemLocal.soundCache && numEntries < maxSamples )
            {
                token.BackSlashesToSlashes();
                idStr lang = cvarSystem->GetCVarString( "sys_lang" );
                if ( lang.Icmp( "english" ) != 0 && token.Find( "sound/vo/", false ) >= 0 )
                {
                    idStr work = token;
                    work.ToLower();
                    work.StripLeading( "sound/vo/" );
                    work = va( "sound/vo/%s/%s", lang.c_str(), work.c_str() );
                    if ( fileSystem->ReadFile( work, NULL, NULL ) > 0 )
                    {
                        token = work;
                    }
                    else
                    {
                        // also try to find it with the .ogg extension
                        work.SetFileExtension( ".ogg" );
                        if ( fileSystem->ReadFile( work, NULL, NULL ) > 0 )
                        {
                            token = work;
                        }
                    }
                }
                entries[ numEntries ] = soundSystemLocal.soundCache->FindSound( token.c_str(), onDemand );
                numEntries++;
            }
        }
        else
        {
            src.Warning( "unknown token '%s'", token.c_str() );
            return false;
        }
    }

    if ( parms.shakes > 0.0f )
    {
        CheckShakesAndOgg();
    }

    return true;
}
Esempio n. 29
0
bool idEFXFile::ReadEffect( idLexer &src, idSoundEffect *effect ) {
	idToken name, token;

	if ( !src.ReadToken( &token ) )
		return false;

	// reverb effect
	if ( token != "reverb" ) {
		// other effect (not supported at the moment)
		src.Error( "idEFXFile::ReadEffect: Unknown effect definition" );

		return false;
	}

	src.ReadTokenOnLine( &token );
	name = token;

	if ( !src.ReadToken( &token ) )
		return false;

	if ( token != "{" ) {
		src.Error( "idEFXFile::ReadEffect: { not found, found %s", token.c_str() );
		return false;
	}

	ALenum err;
	alGetError();
	EFXprintf("Loading EFX effect '%s' (#%u)\n", name.c_str(), effect->effect);

	do {
		if ( !src.ReadToken( &token ) ) {
			src.Error( "idEFXFile::ReadEffect: EOF without closing brace" );
			return false;
		}

		if ( token == "}" ) {
			effect->name = name;
			break;
		}

		if ( token == "environment" ) {
			// <+KittyCat> the "environment" token should be ignored (efx has nothing equatable to it)
			src.ParseInt();
		} else if ( token == "environment size" ) {
			float size = src.ParseFloat();
			efxf(AL_EAXREVERB_DENSITY, (size < 2.0f) ? (size - 1.0f) : 1.0f);
		} else if ( token == "environment diffusion" ) {
			efxf(AL_EAXREVERB_DIFFUSION, src.ParseFloat());
		} else if ( token == "room" ) {
			efxf(AL_EAXREVERB_GAIN, mB_to_gain(src.ParseInt(), GAIN));
		} else if ( token == "room hf" ) {
			efxf(AL_EAXREVERB_GAINHF, mB_to_gain(src.ParseInt(), GAINHF));
		} else if ( token == "room lf" ) {
			efxf(AL_EAXREVERB_GAINLF, mB_to_gain(src.ParseInt(), GAINLF));
		} else if ( token == "decay time" ) {
			efxf(AL_EAXREVERB_DECAY_TIME, src.ParseFloat());
		} else if ( token == "decay hf ratio" ) {
			efxf(AL_EAXREVERB_DECAY_HFRATIO, src.ParseFloat());
		} else if ( token == "decay lf ratio" ) {
			efxf(AL_EAXREVERB_DECAY_LFRATIO, src.ParseFloat());
		} else if ( token == "reflections" ) {
			efxf(AL_EAXREVERB_REFLECTIONS_GAIN, mB_to_gain(src.ParseInt(), REFLECTIONS_GAIN));
		} else if ( token == "reflections delay" ) {
			efxf(AL_EAXREVERB_REFLECTIONS_DELAY, src.ParseFloat());
		} else if ( token == "reflections pan" ) {
			efxfv(AL_EAXREVERB_REFLECTIONS_PAN, src.ParseFloat(), src.ParseFloat(), src.ParseFloat());
		} else if ( token == "reverb" ) {
			efxf(AL_EAXREVERB_LATE_REVERB_GAIN, mB_to_gain(src.ParseInt(), LATE_REVERB_GAIN));
		} else if ( token == "reverb delay" ) {
			efxf(AL_EAXREVERB_LATE_REVERB_DELAY, src.ParseFloat());
		} else if ( token == "reverb pan" ) {
			efxfv(AL_EAXREVERB_LATE_REVERB_PAN, src.ParseFloat(), src.ParseFloat(), src.ParseFloat());
		} else if ( token == "echo time" ) {
			efxf(AL_EAXREVERB_ECHO_TIME, src.ParseFloat());
		} else if ( token == "echo depth" ) {
			efxf(AL_EAXREVERB_ECHO_DEPTH, src.ParseFloat());
		} else if ( token == "modulation time" ) {
			efxf(AL_EAXREVERB_MODULATION_TIME, src.ParseFloat());
		} else if ( token == "modulation depth" ) {
			efxf(AL_EAXREVERB_MODULATION_DEPTH, src.ParseFloat());
		} else if ( token == "air absorption hf" ) {
			efxf(AL_EAXREVERB_AIR_ABSORPTION_GAINHF, mB_to_gain(src.ParseFloat(), AIR_ABSORPTION_GAINHF));
		} else if ( token == "hf reference" ) {
			efxf(AL_EAXREVERB_HFREFERENCE, src.ParseFloat());
		} else if ( token == "lf reference" ) {
			efxf(AL_EAXREVERB_LFREFERENCE, src.ParseFloat());
		} else if ( token == "room rolloff factor" ) {
			efxf(AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, src.ParseFloat());
		} else if ( token == "flags" ) {
			src.ReadTokenOnLine( &token );
			unsigned int flags = token.GetUnsignedLongValue();

			efxi(AL_EAXREVERB_DECAY_HFLIMIT, (flags & 0x20) ? AL_TRUE : AL_FALSE);
			// the other SCALE flags have no equivalent in efx
		} else {
			src.ReadTokenOnLine( &token );
			src.Error( "idEFXFile::ReadEffect: Invalid parameter in reverb definition" );
		}
	} while ( 1 );

	return true;
}
Esempio n. 30
0
/*
================
idDeclAF::ParseBody
================
*/
bool idDeclAF::ParseBody( idLexer &src ) {
	bool hasJoint = false;
	idToken token;
	idAFVector angles;
	idDeclAF_Body *body = new idDeclAF_Body;

	bodies.Alloc() = body;

	body->SetDefault( this );

	if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
			!src.ExpectTokenString( "{" ) ) {
		return false;
	}

	body->name = token;
	if ( !body->name.Icmp( "origin" ) || !body->name.Icmp( "world" ) ) {
		src.Error( "a body may not be named \"origin\" or \"world\"" );
		return false;
	}

	while( src.ReadToken( &token ) ) {

		if ( !token.Icmp( "model" ) ) {
			if ( !src.ExpectTokenType( TT_NAME, 0, &token ) ) {
				return false;
			}
			if ( !token.Icmp( "box" ) ) {
				body->modelType = TRM_BOX;
				if ( !src.ExpectTokenString( "(" ) ||
					!body->v1.Parse( src ) ||
					!src.ExpectTokenString( "," ) ||
					!body->v2.Parse( src ) ||
					!src.ExpectTokenString( ")" ) ) {
					return false;
				}
			} else if ( !token.Icmp( "octahedron" ) ) {
				body->modelType = TRM_OCTAHEDRON;
				if ( !src.ExpectTokenString( "(" ) ||
					!body->v1.Parse( src ) ||
					!src.ExpectTokenString( "," ) ||
					!body->v2.Parse( src ) ||
					!src.ExpectTokenString( ")" ) ) {
					return false;
				}
			} else if ( !token.Icmp( "dodecahedron" ) ) {
				body->modelType = TRM_DODECAHEDRON;
				if ( !src.ExpectTokenString( "(" ) ||
					!body->v1.Parse( src ) ||
					!src.ExpectTokenString( "," ) ||
					!body->v2.Parse( src ) ||
					!src.ExpectTokenString( ")" ) ) {
					return false;
				}
			} else if ( !token.Icmp( "cylinder" ) ) {
				body->modelType = TRM_CYLINDER;
				if ( !src.ExpectTokenString( "(" ) ||
					!body->v1.Parse( src ) ||
					!src.ExpectTokenString( "," ) ||
					!body->v2.Parse( src ) ||
					!src.ExpectTokenString( "," ) ) {
					return false;
				}
				body->numSides = src.ParseInt();
				if ( !src.ExpectTokenString( ")" ) ) {
					return false;
				}
			} else if ( !token.Icmp( "cone" ) ) {
				body->modelType = TRM_CONE;
				if ( !src.ExpectTokenString( "(" ) ||
					!body->v1.Parse( src ) ||
					!src.ExpectTokenString( "," ) ||
					!body->v2.Parse( src ) ||
					!src.ExpectTokenString( "," ) ) {
					return false;
				}
				body->numSides = src.ParseInt();
				if ( !src.ExpectTokenString( ")" ) ) {
					return false;
				}
			} else if ( !token.Icmp( "bone" ) ) {
				body->modelType = TRM_BONE;
				if ( !src.ExpectTokenString( "(" ) ||
					!body->v1.Parse( src ) ||
					!src.ExpectTokenString( "," ) ||
					!body->v2.Parse( src ) ||
					!src.ExpectTokenString( "," ) ) {
					return false;
				}
				body->width = src.ParseFloat();
				if ( !src.ExpectTokenString( ")" ) ) {
					return false;
				}
			} else if ( !token.Icmp( "custom" ) ) {
				src.Error( "custom models not yet implemented" );
				return false;
			} else {
				src.Error( "unkown model type %s", token.c_str() );
				return false;
			}
		} else if ( !token.Icmp( "origin" ) ) {
			if ( !body->origin.Parse( src ) ) {
				return false;
			}
		} else if ( !token.Icmp( "angles" ) ) {
			if ( !angles.Parse( src ) ) {
				return false;
			}
			body->angles = idAngles( angles.ToVec3().x, angles.ToVec3().y, angles.ToVec3().z );
		} else if ( !token.Icmp( "joint" ) ) {
			if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
				return false;
			}
			body->jointName = token;
			hasJoint = true;
		} else if ( !token.Icmp( "mod" ) ) {
			if ( !src.ExpectAnyToken( &token ) ) {
				return false;
			}
			body->jointMod = JointModFromString( token.c_str() );
		} else if ( !token.Icmp( "density" ) ) {
			body->density = src.ParseFloat();
		} else if ( !token.Icmp( "inertiaScale" ) ) {
			src.Parse1DMatrix( 9, body->inertiaScale[0].ToFloatPtr() );
		} else if ( !token.Icmp( "friction" ) ) {
			body->linearFriction = src.ParseFloat();
			src.ExpectTokenString( "," );
			body->angularFriction = src.ParseFloat();
			src.ExpectTokenString( "," );
			body->contactFriction = src.ParseFloat();
		} else if ( !token.Icmp( "contents" ) ) {
			ParseContents( src, body->contents );
		} else if ( !token.Icmp( "clipMask" ) ) {
			ParseContents( src, body->clipMask );
		} else if ( !token.Icmp( "selfCollision" ) ) {
			body->selfCollision = src.ParseBool();
		} else if ( !token.Icmp( "containedjoints" ) ) {
			if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
				return false;
			}
			body->containedJoints = token;
		} else if ( !token.Icmp( "frictionDirection" ) ) {
			if ( !body->frictionDirection.Parse( src ) ) {
				return false;
			}
		} else if ( !token.Icmp( "contactMotorDirection" ) ) {
			if ( !body->contactMotorDirection.Parse( src ) ) {
				return false;
			}
		} else if ( token == "}" ) {
			break;
		} else {
			src.Error( "unknown token %s in body", token.c_str() );
			return false;
		}
	}

	if ( body->modelType == TRM_INVALID ) {
		src.Error( "no model set for body" );
		return false;
	}

	if ( !hasJoint ) {
		src.Error( "no joint set for body" );
		return false;
	}

	body->clipMask |= CONTENTS_MOVEABLECLIP;

	return true;
}