MCPcopy Create free account
hub / github.com/TurningWheel/Barony / physfsReloadSounds

Function physfsReloadSounds

src/files.cpp:5364–5472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5362}
5363
5364void physfsReloadSounds(bool reloadAll)
5365{
5366 if ( no_sound )
5367 {
5368 return;
5369 }
5370 if ( !PHYSFS_getRealDir("sound/sounds.txt") )
5371 {
5372 printlog("error: could not find file: %s", "sound/sounds.txt");
5373 return;
5374 }
5375 std::string soundsDirectory = PHYSFS_getRealDir("sound/sounds.txt");
5376 soundsDirectory.append(PHYSFS_getDirSeparator()).append("sound/sounds.txt");
5377 File* fp = openDataFile(soundsDirectory.c_str(), "rb");
5378 char name[PATH_MAX];
5379
5380 printlog("freeing sounds and loading modded sounds...\n");
5381 if ( reloadAll )
5382 {
5383#ifdef SOUND
5384 if ( sounds != nullptr )
5385 {
5386 for ( int c = 0; c < numsounds; c++ )
5387 {
5388 if ( sounds[c] != nullptr )
5389 {
5390#ifdef USE_FMOD
5391 sounds[c]->release(); //Free the sound in FMOD
5392#endif
5393#ifdef USE_OPENAL
5394 OPENAL_Sound_Release(sounds[c]); //Free the sound in OPENAL
5395#endif
5396 sounds[c] = nullptr;
5397 }
5398 }
5399 }
5400#endif
5401 }
5402
5403 for ( int c = 0; !fp->eof(); c++ )
5404 {
5405 fp->gets2(name, PATH_MAX);
5406 bool soundHasBeenModified = false;
5407 // has this sound index been modified?
5408 std::vector<int>::iterator it = Mods::soundsListModifiedIndexes.end();
5409 if ( !Mods::soundsListModifiedIndexes.empty() )
5410 {
5411 it = std::find(Mods::soundsListModifiedIndexes.begin(),
5412 Mods::soundsListModifiedIndexes.end(), c);
5413 if ( it != Mods::soundsListModifiedIndexes.end() )
5414 {
5415 soundHasBeenModified = true; // found the sound in the vector.
5416 }
5417 }
5418
5419 if ( PHYSFS_getRealDir(name) != NULL )
5420 {
5421 std::string soundRealDir = PHYSFS_getRealDir(name);

Callers 4

unloadModsMethod · 0.85
loadModsMethod · 0.85
handleMainMenuFunction · 0.85
consolecommand.cppFile · 0.85

Calls 14

printlogFunction · 0.85
openDataFileFunction · 0.85
OPENAL_Sound_ReleaseFunction · 0.85
findFunction · 0.85
FMODErrorCheckFunction · 0.85
OPENAL_CreateSoundFunction · 0.85
updateLoadingScreenFunction · 0.85
appendMethod · 0.80
c_strMethod · 0.80
eofMethod · 0.80
gets2Method · 0.80
endMethod · 0.45

Tested by

no test coverage detected