/* =============== CG_ParseTrailSystem Parse a trail system section =============== */ static bool CG_ParseTrailSystem( baseTrailSystem_t *bts, const char **text_p, const char *name ) { char *token; // read optional parameters while ( 1 ) { token = COM_Parse( text_p ); if ( !*token ) { return false; } if ( !Q_stricmp( token, "{" ) ) { CG_InitialiseBaseTrailBeam( &baseTrailBeams[ numBaseTrailBeams ] ); if ( !CG_ParseTrailBeam( &baseTrailBeams[ numBaseTrailBeams ], text_p ) ) { Log::Warn( "failed to parse trail beam" ); return false; } if ( bts->numBeams == MAX_BEAMS_PER_SYSTEM ) { Log::Warn( "trail system has > %d beams", MAX_BEAMS_PER_SYSTEM ); return false; } else if ( numBaseTrailBeams == MAX_BASETRAIL_BEAMS ) { Log::Warn( "maximum number of trail beams (%d) reached", MAX_BASETRAIL_BEAMS ); return false; } else { //start parsing beams again bts->beams[ bts->numBeams ] = &baseTrailBeams[ numBaseTrailBeams ]; bts->numBeams++; numBaseTrailBeams++; } continue; } else if ( !Q_stricmp( token, "thirdPersonOnly" ) ) { bts->thirdPersonOnly = true; } else if ( !Q_stricmp( token, "lifeTime" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } bts->lifeTime = atoi_neg( token, false ); continue; } else if ( !Q_stricmp( token, "beam" ) ) //acceptable text { continue; } else if ( !Q_stricmp( token, "}" ) ) { if ( cg_debugTrails.integer >= 1 ) { Log::Warn( "Parsed trail system %s", name ); } return true; //reached the end of this trail system } else { Log::Warn( "unknown token '%s' in trail system %s", token, bts->name ); return false; } } return false; }
/* =============== CG_ParseTrailBeam Parse a trail beam =============== */ static bool CG_ParseTrailBeam( baseTrailBeam_t *btb, const char **text_p ) { char *token; // read optional parameters while ( 1 ) { token = COM_Parse( text_p ); if ( !*token ) { return false; } if ( !Q_stricmp( token, "segments" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } btb->numSegments = atoi_neg( token, false ); if ( btb->numSegments >= MAX_TRAIL_BEAM_NODES ) { btb->numSegments = MAX_TRAIL_BEAM_NODES - 1; Log::Warn( "too many segments in trail beam" ); } continue; } else if ( !Q_stricmp( token, "width" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } btb->frontWidth = atof_neg( token, false ); token = COM_Parse( text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "-" ) ) { btb->backWidth = btb->frontWidth; } else { btb->backWidth = atof_neg( token, false ); } continue; } else if ( !Q_stricmp( token, "alpha" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } btb->frontAlpha = atof_neg( token, false ); token = COM_Parse( text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "-" ) ) { btb->backAlpha = btb->frontAlpha; } else { btb->backAlpha = atof_neg( token, false ); } continue; } else if ( !Q_stricmp( token, "color" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "{" ) ) { if ( !CG_ParseColor( btb->frontColor, text_p ) ) { break; } token = COM_Parse( text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "-" ) ) { btb->backColor[ 0 ] = btb->frontColor[ 0 ]; btb->backColor[ 1 ] = btb->frontColor[ 1 ]; btb->backColor[ 2 ] = btb->frontColor[ 2 ]; } else if ( !Q_stricmp( token, "{" ) ) { if ( !CG_ParseColor( btb->backColor, text_p ) ) { break; } } else { Log::Warn( "missing '{'" ); break; } } else { Log::Warn( "missing '{'" ); break; } continue; } else if ( !Q_stricmp( token, "segmentTime" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } btb->segmentTime = atoi_neg( token, false ); continue; } else if ( !Q_stricmp( token, "fadeOutTime" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } btb->fadeOutTime = atoi_neg( token, false ); continue; } else if ( !Q_stricmp( token, "shader" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } Q_strncpyz( btb->shaderName, token, MAX_QPATH ); continue; } else if ( !Q_stricmp( token, "textureType" ) ) { token = COM_Parse( text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "stretch" ) ) { btb->textureType = TBTT_STRETCH; token = COM_Parse( text_p ); if ( !*token ) { break; } btb->frontTextureCoord = atof_neg( token, false ); token = COM_Parse( text_p ); if ( !*token ) { break; } btb->backTextureCoord = atof_neg( token, false ); } else if ( !Q_stricmp( token, "repeat" ) ) { btb->textureType = TBTT_REPEAT; token = COM_Parse( text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "front" ) ) { btb->clampToBack = false; } else if ( !Q_stricmp( token, "back" ) ) { btb->clampToBack = true; } else { Log::Warn( "unknown textureType clamp \"%s\"", token ); break; } token = COM_Parse( text_p ); if ( !*token ) { break; } btb->repeatLength = atof_neg( token, false ); } else { Log::Warn( "unknown textureType \"%s\"", token ); break; } continue; } else if ( !Q_stricmp( token, "realLight" ) ) { btb->realLight = true; continue; } else if ( !Q_stricmp( token, "jitter" ) ) { if ( btb->numJitters == MAX_TRAIL_BEAM_JITTERS ) { Log::Warn( "too many jitters" ); break; } token = COM_Parse( text_p ); if ( !*token ) { break; } btb->jitters[ btb->numJitters ].magnitude = atof_neg( token, false ); token = COM_Parse( text_p ); if ( !*token ) { break; } btb->jitters[ btb->numJitters ].period = atoi_neg( token, false ); btb->numJitters++; continue; } else if ( !Q_stricmp( token, "jitterAttachments" ) ) { btb->jitterAttachments = true; continue; } else if ( !Q_stricmp( token, "dynamicLight" ) ) { btb->dynamicLight = true; token = COM_Parse( text_p ); if ( !*token ) { break; } btb->dLightRadius = atof( token ); token = COM_Parse( text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "{" ) ) { if ( !CG_ParseColor( btb->dLightColor, text_p ) ) { break; } } } else if ( !Q_stricmp( token, "}" ) ) { return true; //reached the end of this trail beam } else { Log::Warn( "unknown token '%s' in trail beam", token ); return false; } } return false; }
/* =============== CG_ParseTrailBeam Parse a trail beam =============== */ static bool CG_ParseTrailBeam( baseTrailBeam_t *btb, char **text_p ) { char *token; // read optional parameters while( 1 ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) return false; if( !Q_stricmp( token, "segments" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->numSegments = atoi_neg( token, false ); if( btb->numSegments >= MAX_TRAIL_BEAM_NODES ) { btb->numSegments = MAX_TRAIL_BEAM_NODES - 1; CG_Printf( S_COLOR_YELLOW "WARNING: too many segments in trail beam\n" ); } continue; } else if( !Q_stricmp( token, "width" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->frontWidth = atof_neg( token, false ); token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; if( !Q_stricmp( token, "-" ) ) btb->backWidth = btb->frontWidth; else btb->backWidth = atof_neg( token, false ); continue; } else if( !Q_stricmp( token, "alpha" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->frontAlpha = atof_neg( token, false ); token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; if( !Q_stricmp( token, "-" ) ) btb->backAlpha = btb->frontAlpha; else btb->backAlpha = atof_neg( token, false ); continue; } else if( !Q_stricmp( token, "color" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; if( !Q_stricmp( token, "{" ) ) { if( !CG_ParseTrailBeamColor( btb->frontColor, text_p ) ) break; token = COM_Parse( text_p ); if( Q_stricmp( token, "}" ) ) { CG_Printf( S_COLOR_RED "ERROR: missing '}'\n" ); break; } token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; if( !Q_stricmp( token, "-" ) ) { btb->backColor[ 0 ] = btb->frontColor[ 0 ]; btb->backColor[ 1 ] = btb->frontColor[ 1 ]; btb->backColor[ 2 ] = btb->frontColor[ 2 ]; } else if( !Q_stricmp( token, "{" ) ) { if( !CG_ParseTrailBeamColor( btb->backColor, text_p ) ) break; token = COM_Parse( text_p ); if( Q_stricmp( token, "}" ) ) { CG_Printf( S_COLOR_RED "ERROR: missing '}'\n" ); break; } } else { CG_Printf( S_COLOR_RED "ERROR: missing '{'\n" ); break; } } else { CG_Printf( S_COLOR_RED "ERROR: missing '{'\n" ); break; } continue; } else if( !Q_stricmp( token, "segmentTime" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->segmentTime = atoi_neg( token, false ); continue; } else if( !Q_stricmp( token, "fadeOutTime" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->fadeOutTime = atoi_neg( token, false ); continue; } else if( !Q_stricmp( token, "shader" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; Q_strncpyz( btb->shaderName, token, MAX_QPATH ); continue; } else if( !Q_stricmp( token, "textureType" ) ) { token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; if( !Q_stricmp( token, "stretch" ) ) { btb->textureType = TBTT_STRETCH; token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->frontTextureCoord = atof_neg( token, false ); token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->backTextureCoord = atof_neg( token, false ); } else if( !Q_stricmp( token, "repeat" ) ) { btb->textureType = TBTT_REPEAT; token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; if( !Q_stricmp( token, "front" ) ) btb->clampToBack = false; else if( !Q_stricmp( token, "back" ) ) btb->clampToBack = true; else { CG_Printf( S_COLOR_RED "ERROR: unknown textureType clamp \"%s\"\n", token ); break; } token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->repeatLength = atof_neg( token, false ); } else { CG_Printf( S_COLOR_RED "ERROR: unknown textureType \"%s\"\n", token ); break; } continue; } else if( !Q_stricmp( token, "realLight" ) ) { btb->realLight = true; continue; } else if( !Q_stricmp( token, "jitter" ) ) { if( btb->numJitters == MAX_TRAIL_BEAM_JITTERS ) { CG_Printf( S_COLOR_RED "ERROR: too many jitters\n" ); break; } token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->jitters[ btb->numJitters ].magnitude = atof_neg( token, false ); token = COM_Parse( text_p ); if( !Q_stricmp( token, "" ) ) break; btb->jitters[ btb->numJitters ].period = atoi_neg( token, false ); btb->numJitters++; continue; } else if( !Q_stricmp( token, "jitterAttachments" ) ) { btb->jitterAttachments = true; continue; } else if( !Q_stricmp( token, "}" ) ) return true; //reached the end of this trail beam else { CG_Printf( S_COLOR_RED "ERROR: unknown token '%s' in trail beam\n", token ); return false; } } return false; }