static void pkunk_postprocess (ELEMENT *ElementPtr) { STARSHIP *StarShipPtr; GetElementStarShip (ElementPtr, &StarShipPtr); if (StarShipPtr->RaceDescPtr->characteristics.special_wait) --StarShipPtr->RaceDescPtr->characteristics.special_wait; else if ((StarShipPtr->cur_status_flags & SPECIAL) && StarShipPtr->RaceDescPtr->ship_info.energy_level < StarShipPtr->RaceDescPtr->ship_info.max_energy) { COUNT CurSound; do { CurSound = 2 + ((COUNT)TFB_Random () % (GetSoundCount (StarShipPtr->RaceDescPtr->ship_data.ship_sounds) - 2)); } while (CurSound == LastSound); ProcessSound (SetAbsSoundIndex ( StarShipPtr->RaceDescPtr->ship_data.ship_sounds, CurSound ), ElementPtr); LastSound = CurSound; DeltaEnergy (ElementPtr, SPECIAL_ENERGY_COST); StarShipPtr->RaceDescPtr->characteristics.special_wait = SPECIAL_WAIT; } }
//----------------------------------------------------------------------------- // Purpose: // Input : *scriptfile - //----------------------------------------------------------------------------- void CSoundEmitterSystemBase::BuildPrecacheSoundList( const char *scriptfile, CUtlVector< int >& list ) { int i, c; list.RemoveAll(); int scriptindex = FindSoundScript( scriptfile ); if ( scriptindex == m_SoundKeyValues.InvalidIndex() ) { Warning( "Can't PrecacheSoundScript( '%s' ), file not in manifest '%s'\n", scriptfile, MANIFEST_FILE ); return; } // Walk sounds adding appropriate indices to list c = GetSoundCount(); for ( i = 0 ; i < c; i++ ) { CSoundEntry *se = &m_Sounds[ i ]; Assert( se ); if ( se->m_nScriptFileIndex == scriptindex ) { list.AddToTail( i ); } } }
void CSceneCache::Save( CUtlBuffer& buf ) { buf.PutUnsignedInt( msecs ); unsigned short c = GetSoundCount(); buf.PutShort( c ); Assert( sounds.Count() <= 65536 ); for ( int i = 0; i < c; ++i ) { buf.PutString( GetSoundName( i ) ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CSoundEmitterSystemBase::CheckForMissingWavFiles( bool verbose ) { int missing = 0; int c = GetSoundCount(); int i; char testfile[ 512 ]; for ( i = 0; i < c; i++ ) { CSoundParametersInternal *internal = InternalGetParametersForSound( i ); if ( !internal ) { Assert( 0 ); continue; } int waveCount = internal->soundnames.Count(); for ( int wave = 0; wave < waveCount; wave++ ) { CUtlSymbol sym = internal->soundnames[ wave ]; const char *name = m_Waves.String( sym ); if ( !name || !name[ 0 ] ) { Assert( 0 ); continue; } // Skip ! sentence stuff if ( name[0] == CHAR_SENTENCE ) continue; Q_snprintf( testfile, sizeof( testfile ), "sound/%s", PSkipSoundChars( name ) ); if ( filesystem->FileExists( testfile ) ) continue; internal->had_missing_wave_files = true; ++missing; if ( verbose ) { DevMsg( "Sound %s references missing file %s\n", GetSoundName( i ), name ); } } } return missing; }
void CSoundEmitterSystemBase::SaveChangesToSoundScript( int scriptindex ) { const char *outfile = GetSoundScriptName( scriptindex ); if ( !outfile ) { Msg( "CSoundEmitterSystemBase::SaveChangesToSoundScript: No script file for index %i\n", scriptindex ); return; } if ( filesystem->FileExists( outfile ) && !filesystem->IsFileWritable( outfile ) ) { Warning( "%s is not writable, can't save data to file\n", outfile ); return; } CUtlBuffer buf( 0, 0, true ); // FIXME: Write sound script header if ( filesystem->FileExists( GAME_SOUNDS_HEADER_BLOCK ) ) { FileHandle_t header = filesystem->Open( GAME_SOUNDS_HEADER_BLOCK, "rt", NULL ); if ( header != FILESYSTEM_INVALID_HANDLE ) { int len = filesystem->Size( header ); unsigned char *data = new unsigned char[ len + 1 ]; Q_memset( data, 0, len + 1 ); filesystem->Read( data, len, header ); filesystem->Close( header ); data[ len ] = 0; buf.Put( data, Q_strlen( (char *)data ) ); delete[] data; } buf.Printf( "\n" ); } int c = GetSoundCount(); for ( int i = 0; i < c; i++ ) { if ( Q_stricmp( outfile, GetSourceFileForSound( i ) ) ) continue; // It's marked for deletion, just skip it if ( m_Sounds[ i ].m_bRemoved ) continue; CSoundEmitterSystemBase::CSoundParametersInternal *p = InternalGetParametersForSound( i ); if ( !p ) continue; buf.Printf( "\"%s\"\n{\n", GetSoundName( i ) ); buf.Printf( "\t\"channel\"\t\t\"%s\"\n", p->m_szChannel ); buf.Printf( "\t\"volume\"\t\t\"%s\"\n", p->m_szVolume ); buf.Printf( "\t\"pitch\"\t\t\t\"%s\"\n", p->m_szPitch ); buf.Printf( "\n" ); buf.Printf( "\t\"soundlevel\"\t\"%s\"\n", p->m_szSoundLevel ); if ( p->play_to_owner_only ) { buf.Printf( "\t\"play_to_owner_only\"\t\"1\"\n" ); } if ( !p->precache ) { buf.Printf( "\t\"precache\"\t\"0\"\n" ); } int waveCount = p->soundnames.Count(); if ( waveCount > 0 ) { buf.Printf( "\n" ); if ( waveCount == 1 ) { buf.Printf( "\t\"wave\"\t\t\t\"%s\"\n", GetWaveName( p->soundnames[ 0 ] ) ); } else { buf.Printf( "\t\"rndwave\"\n" ); buf.Printf( "\t{\n" ); for ( int wave = 0; wave < waveCount; wave++ ) { buf.Printf( "\t\t\"wave\"\t\"%s\"\n", GetWaveName( p->soundnames[ wave ] ) ); } buf.Printf( "\t}\n" ); } } buf.Printf( "}\n" ); if ( i != c - 1 ) { buf.Printf( "\n" ); } } // Write it out baby FileHandle_t fh = filesystem->Open( outfile, "wt" ); if (fh) { filesystem->Write( buf.Base(), buf.TellPut(), fh ); filesystem->Close(fh); // Changed saved successfully m_SoundKeyValues[ scriptindex ].dirty = false; } else { Warning( "SceneManager_SaveSoundsToScriptFile: Unable to write file %s!!!\n", outfile ); } }