Browse Source

Reload sfx when reloading active mods

pull/8324/head
staphen 3 months ago committed by Anders Jenbo
parent
commit
c55e7a4107
  1. 2
      Source/diablo.cpp
  2. 7
      Source/effects.cpp
  3. 2
      Source/effects.h
  4. 2
      Source/engine/sound.cpp
  5. 8
      Source/lua/lua_global.cpp

2
Source/diablo.cpp

@ -1790,7 +1790,7 @@ void OptionLanguageCodeChanged()
UnloadFonts();
LanguageInitialize();
LoadLanguageArchive();
effects_cleanup_sfx();
effects_cleanup_sfx(false);
if (gbRunGame)
sound_init();
else

7
Source/effects.cpp

@ -246,10 +246,15 @@ void sound_update()
StreamUpdate();
}
void effects_cleanup_sfx()
void effects_cleanup_sfx(bool fullUnload)
{
sound_stop();
if (fullUnload) {
sgSFX.clear();
return;
}
for (auto &sfx : sgSFX)
sfx.pSnd = nullptr;
}

2
Source/effects.h

@ -31,7 +31,7 @@ void PlaySFX(SfxID psfx);
void PlaySfxLoc(SfxID psfx, Point position, bool randomizeByCategory = true);
void sound_stop();
void sound_update();
void effects_cleanup_sfx();
void effects_cleanup_sfx(bool fullUnload = true);
void sound_init();
void ui_sound_init();
void effects_play_sound(SfxID);

2
Source/engine/sound.cpp

@ -171,7 +171,7 @@ int CapVolume(int volume)
void OptionAudioChanged()
{
effects_cleanup_sfx();
effects_cleanup_sfx(false);
music_stop();
snd_deinit();
snd_init();

8
Source/lua/lua_global.cpp

@ -10,6 +10,7 @@
#include <config.h>
#include "appfat.h"
#include "effects.h"
#include "engine/assets.hpp"
#include "lua/modules/audio.hpp"
#include "lua/modules/hellfire.hpp"
@ -229,6 +230,13 @@ void LuaReloadActiveMods()
handler();
}
// Reload sound effects in case a mod archive overrides effects.tsv
effects_cleanup_sfx();
if (gbRunGame)
sound_init();
else
ui_sound_init();
// Reload game data (this can probably be done later in the process to avoid having to reload it)
LoadTextData();
LoadPlayerDataFiles();

Loading…
Cancel
Save