Esempio n. 1
0
static qboolean AS_ParseSet( int setID, CSetGroup *sg )
{
    ambientSet_t	*set;
    const char		*name;

    //Make sure we're not overstepping the name array
    if ( setID > NUM_AS_SETS )
        return qfalse;

    //Reset the pointers for this run through
    parsePos = 0;

    name = setNames[setID];

    //Iterate through the whole file and find every occurance of a set
    while ( parsePos <= parseSize )
    {
        //Check for a valid set group
        if ( strncmp( parseBuffer+parsePos, name, strlen(name) ) == 0 )
        {
            //Update the debug info
            numSets++;

            //Push past the set specifier and on to the name
            parsePos+=strlen(name)+1;	//Also take the following space out

            //Get the set name (this MUST be first)
            sscanf( parseBuffer+parsePos, "%s", tempBuffer );
            AS_SkipLine();

            //Test the string against the precaches
            if ( tempBuffer[0] )
            {
                //Not in our precache listings, so skip it
                if ( ( pMap->find( (const char *) &tempBuffer ) == pMap->end() ) )
                    continue;
            }

            //Create a new set
            set = sg->AddSet( (const char *) &tempBuffer );

            //Run the function to parse the data out
            parseFuncs[setID]( *set );
            continue;
        }

        //If not found on this line, go down another and check again
        AS_SkipLine();
    }

    return qtrue;
}
Esempio n. 2
0
static void AS_GetRadius( ambientSet_t &set )
{
    //Get the data
    sscanf( parseBuffer+parsePos, "%s %d", tempBuffer, &set.radius );

    AS_SkipLine();
}
Esempio n. 3
0
static void AS_GetVolumeRange( ambientSet_t &set )
{
    int		min, max;

    //Get the data
    sscanf( parseBuffer+parsePos, "%s %d %d", tempBuffer, &min, &max );

    //Check for swapped min / max
    if ( min > max )
    {
#ifndef FINAL_BUILD
        Com_Printf(S_COLOR_YELLOW"WARNING: Corrected swapped min / max range in a \"volRange\" keyword\n");
#endif

        int swap =	min;
        min = max;
        max = swap;
    }

    //Store the data
    set.volRange_start	= min;
    set.volRange_end	= max;

    AS_SkipLine();
}
Esempio n. 4
0
static void AS_GetTimeBetweenWaves( ambientSet_t &set )
{
    int		startTime, endTime;

    //Get the data
    sscanf( parseBuffer+parsePos, "%s %d %d", tempBuffer, &startTime, &endTime );

    //Check for swapped start / end
    if ( startTime > endTime )
    {
#ifndef FINAL_BUILD
        Com_Printf(S_COLOR_YELLOW"WARNING: Corrected swapped start / end times in a \"timeBetweenWaves\" keyword\n");
#endif

        int swap = startTime;
        startTime = endTime;
        endTime = swap;
    }

    //Store it
    set.time_start	= startTime;
    set.time_end	= endTime;

    AS_SkipLine();
}
Esempio n. 5
0
static void AS_GetSubWaves( ambientSet_t &set )
{
    char	dirBuffer[512], waveBuffer[256], waveName[1024];

    //Get the directory for these sets
    sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, dirBuffer );

    //Move the pointer past these two strings
    parsePos += ((strlen(keywordNames[SET_KEYWORD_SUBWAVES])+1) + (strlen(dirBuffer)+1));

    //Get all the subwaves
    while ( parsePos <= parseSize )
    {
        //Get the data
        sscanf( parseBuffer+parsePos, "%s", waveBuffer );

        if ( set.numSubWaves > MAX_WAVES_PER_GROUP )
        {
#ifndef FINAL_BUILD
            Com_Printf(S_COLOR_YELLOW"WARNING: Too many subwaves on set \"%s\"\n", set.name );
#endif
        }
        else
        {
            //Construct the wave name (pretty, huh?)
            strcpy( (char *) waveName, "sound/" );
            strncat( (char *) waveName, (const char *) dirBuffer, 1024 );
            strncat( (char *) waveName, "/", 512 );
            strncat( (char *) waveName, (const char *) waveBuffer, 512 );
            strncat( (char *) waveName, ".wav", 512 );

            //Place this onto the sound directory name

            //Precache the file at this point and store off the ID instead of the name
            if ( ( set.subWaves[set.numSubWaves++] = S_RegisterSound( waveName ) ) <= 0 )
            {
#ifndef FINAL_BUILD
                //Com_Printf(S_COLOR_RED"ERROR: Unable to load ambient sound \"%s\"\n", waveName);
                Com_Error(ERR_DROP, "ERROR: Unable to load ambient sound \"%s\"\n", waveName);
#endif
            }
        }

        //Move the pointer past this string
        parsePos += strlen(waveBuffer)+1;

        if ( ( (parseBuffer+parsePos)[0] == '\n') || ( (parseBuffer+parsePos)[0] == '\r') )
            break;
    }

    AS_SkipLine();
}
Esempio n. 6
0
static void AS_GetLoopedWave( ambientSet_t &set )
{
    char	waveBuffer[256], waveName[1024];

    //Get the looped wave name
    sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, waveBuffer );

    //Construct the wave name
    Com_sprintf( waveName, sizeof(waveName), "sound/%s.wav", waveBuffer );

    //Precache the file at this point and store off the ID instead of the name
    if ( ( set.loopedWave = S_RegisterSound( waveName ) ) <= 0 )
    {
#ifndef FINAL_BUILD
        Com_Printf(S_COLOR_YELLOW"WARNING: Unable to load ambient sound \"%s\"\n", waveName);
#endif
    }

    AS_SkipLine();
}
Esempio n. 7
0
static void AS_ParseHeader( void )
{
    char	typeBuffer[128];
    int		keywordID;

    while ( parsePos <= parseSize )
    {
        sscanf( parseBuffer+parsePos, "%s", tempBuffer );

        keywordID = AS_GetKeywordIDForString( (const char *) &tempBuffer );

        switch ( keywordID )
        {
        case SET_KEYWORD_TYPE:
            sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, typeBuffer );

            if ( !stricmp( (const char *) typeBuffer, "ambientSet" ) )
            {
                return;
            }
            Com_Error( ERR_DROP, "AS_ParseHeader: Set type \"%s\" is not a valid set type!\n", typeBuffer );

            break;

        case SET_KEYWORD_AMSDIR:
            //TODO: Implement
            break;

        case SET_KEYWORD_OUTDIR:
            //TODO: Implement
            break;

        case SET_KEYWORD_BASEDIR:
            //TODO: Implement
            break;
        }

        AS_SkipLine();
    }
}
Esempio n. 8
0
static void AS_GetLoopedWave( ambientSet_t &set )
{
    char	waveBuffer[256], waveName[1024];

    //Get the looped wave name
    sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, waveBuffer );

    //Construct the wave name
    strcpy( (char *) waveName, "sound/" );
    strncat( (char *) waveName, (const char *) waveBuffer, 1024 );
    strncat( (char *) waveName, ".wav", 1024 );

    //Precache the file at this point and store off the ID instead of the name
    if ( ( set.loopedWave = S_RegisterSound( waveName ) ) <= 0 )
    {
#ifndef FINAL_BUILD
        //Com_Printf(S_COLOR_RED"ERROR: Unable to load ambient sound \"%s\"\n", waveName);
        Com_Error(ERR_DROP, "ERROR: Unable to load looped ambient sound \"%s\"\n", waveName);
#endif
    }

    AS_SkipLine();
}