示例#1
0
/**
 * Parses one ObsZone line from the See You task file
 * @param turnpoint_infos Updated with the OZ info
 * @param params Input array of parameters preparsed from See You task file
 * @param n_params Number parameters in the line
 * @return OZ index from CU (0 to n-1) or -1 if no OZ found
 */
static int
ParseOZs(SeeYouTurnpointInformation turnpoint_infos[], const TCHAR *params[],
         unsigned n_params)
{
  // Read OZ index
  TCHAR* end;
  const int oz_index = _tcstol(params[0] + 8, &end, 10);
  if (params[0] + 8 == end || oz_index >= 30)
    return -1;

  turnpoint_infos[oz_index].valid = true;
  // Iterate through available OZ options
  for (unsigned i = 1; i < n_params; i++) {
    const TCHAR *pair = params[i];
    SeeYouTurnpointInformation &tp_info = turnpoint_infos[oz_index];

    if (_tcsncmp(pair, _T("style"), 5) == 0) {
      if (_tcslen(pair) > 6)
        tp_info.style = ParseStyle(pair + 6);
    } else if (_tcsncmp(pair, _T("R1="), 3) == 0) {
      if (_tcslen(pair) > 3)
        tp_info.radius1 = ParseRadius(pair + 3);
    } else if (_tcsncmp(pair, _T("A1="), 3) == 0) {
      if (_tcslen(pair) > 3)
        tp_info.angle1 = ParseAngle(pair + 3);
    } else if (_tcsncmp(pair, _T("R2="), 3) == 0) {
      if (_tcslen(pair) > 3)
        tp_info.radius2 = ParseRadius(pair + 3);
    } else if (_tcsncmp(pair, _T("A2="), 3) == 0) {
      if (_tcslen(pair) > 3)
        tp_info.angle2 = ParseAngle(pair + 3);
    } else if (_tcsncmp(pair, _T("A12="), 4) == 0) {
      if (_tcslen(pair) > 3)
        tp_info.angle12 = ParseAngle(pair + 4);
    } else if (_tcsncmp(pair, _T("max_altitude="), 7) == 0) {
      if (_tcslen(pair) > 7)
        tp_info.max_altitude = ParseMaxAlt(pair + 7);
      } else if (_tcsncmp(pair, _T("is_line"), 4) == 0) {
      if (_tcslen(pair) > 5 && pair[5] == _T('1'))
        tp_info.is_line = true;
    } else if (_tcsncmp(pair, _T("reduce"), 6) == 0) {
      if (_tcslen(pair) > 7 && pair[7] == _T('1'))
        tp_info.reduce = true;
    }
  }
  return oz_index;
}
示例#2
0
// Parse a primitive, apply defaults first, grab any base level
//	key pairs, then process any sub groups we may contain.
//------------------------------------------------------
bool CPrimitiveTemplate::ParsePrimitive( CGPGroup *grp )
{
	CGPGroup	*subGrp;
	CGPValue	*pairs;
	const char	*key; 
	const char	*val;

	// Lets work with the pairs first
	pairs = grp->GetPairs();

	while( pairs )
	{
		// the fields
		key = pairs->GetName();
		val = pairs->GetTopValue();

		// Huge stricmp lists suxor
		if ( !stricmp( key, "count" ))
		{
			ParseCount( val );
		}
		else if ( !stricmp( key, "shaders" ) || !stricmp( key, "shader" ))
		{
			ParseShaders( pairs );
		}
		else if ( !stricmp( key, "models" ) || !stricmp( key, "model" ))
		{
			ParseModels( pairs );
		}
		else if ( !stricmp( key, "sounds" ) || !stricmp( key, "sound" ))
		{
			ParseSounds( pairs );
		}
		else if ( !stricmp( key, "impactfx" ))
		{
			ParseImpactFxStrings( pairs );
		}
		else if ( !stricmp( key, "deathfx" ))
		{
			ParseDeathFxStrings( pairs );
		}
		else if ( !stricmp( key, "emitfx" ))
		{
			ParseEmitterFxStrings( pairs );
		}
		else if ( !stricmp( key, "playfx" ))
		{
			ParsePlayFxStrings( pairs );
		}
		else if ( !stricmp( key, "life" ))
		{
			ParseLife( val );
		}
		else if ( !stricmp( key, "cullrange" ))
		{
			mCullRange = atoi( val );
			mCullRange *= mCullRange; // Square
		}
		else if ( !stricmp( key, "delay" ))
		{
			ParseDelay( val );
		}
		else if ( !stricmp( key, "bounce" ) || !stricmp( key, "intensity" )) // me==bad for reusing this...but it shouldn't hurt anything)
		{
			ParseElasticity( val );
		}
		else if ( !stricmp( key, "min" ))
		{
			ParseMin( val );
		}
		else if ( !stricmp( key, "max" ))
		{
			ParseMax( val );
		}
		else if ( !stricmp( key, "angle" ) || !stricmp( key, "angles" ))
		{
			ParseAngle( val );
		}
		else if ( !stricmp( key, "angleDelta" ))
		{
			ParseAngleDelta( val );
		}
		else if ( !stricmp( key, "velocity" ) || !stricmp( key, "vel" ))
		{
			ParseVelocity( val );
		}
		else if ( !stricmp( key, "acceleration" ) || !stricmp( key, "accel" ))
		{
			ParseAcceleration( val );
		}
		else if ( !stricmp( key, "gravity" ))
		{
			ParseGravity( val );
		}
		else if ( !stricmp( key, "density" ))
		{
			ParseDensity( val );
		}
		else if ( !stricmp( key, "variance" ))
		{
			ParseVariance( val );
		}
		else if ( !stricmp( key, "origin" ))
		{
			ParseOrigin1( val );
		}
		else if ( !stricmp( key, "origin2" ))
		{
			ParseOrigin2( val );
		}
		else if ( !stricmp( key, "radius" )) // part of ellipse/cylinder calcs.
		{
			ParseRadius( val );
		}
		else if ( !stricmp( key, "height" )) // part of ellipse/cylinder calcs.
		{
			ParseHeight( val );
		}
		else if ( !stricmp( key, "rotation" ))
		{
			ParseRotation( val );
		}
		else if ( !Q_stricmp( key, "rotationDelta" ))
		{
			ParseRotationDelta( val );
		}
		else if ( !stricmp( key, "flags" ) || !stricmp( key, "flag" ))
		{ // these need to get passed on to the primitive
			ParseFlags( val );
		}
		else if ( !stricmp( key, "spawnFlags" ) || !stricmp( key, "spawnFlag" ))
		{ // these are used to spawn things in cool ways, but don't ever get passed on to prims.
			ParseSpawnFlags( val );
		}
		else if ( !stricmp( key, "name" ))
		{
			if ( val )
			{
				// just stash the descriptive name of the primitive
				strcpy( mName, val );
			}
		}
		else
		{
			theFxHelper.Print( "Unknown key parsing an effect primitive: %s\n", key );
		}

		pairs = (CGPValue *)pairs->GetNext();
	}

	subGrp = grp->GetSubGroups();

	// Lets chomp on the groups now
	while ( subGrp )
	{
		key = subGrp->GetName();

		if ( !stricmp( key, "rgb" ))
		{
			ParseRGB( subGrp );
		}
		else if ( !stricmp( key, "alpha" ))
		{
			ParseAlpha( subGrp );
		}
		else if ( !stricmp( key, "size" ) || !stricmp( key, "width" ))
		{
			ParseSize( subGrp );
		}
		else if ( !stricmp( key, "size2" ) || !stricmp( key, "width2" ))
		{
			ParseSize2( subGrp );
		}
		else if ( !stricmp( key, "length" ) || !stricmp( key, "height" ))
		{
			ParseLength( subGrp );
		}
		else
		{
			theFxHelper.Print( "Unknown group key parsing a particle: %s\n", key );
		}

		subGrp = (CGPGroup *)subGrp->GetNext();
	}

	return true;
}