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(); UnloadFonts();
LanguageInitialize(); LanguageInitialize();
LoadLanguageArchive(); LoadLanguageArchive();
effects_cleanup_sfx(); effects_cleanup_sfx(false);
if (gbRunGame) if (gbRunGame)
sound_init(); sound_init();
else else

7
Source/effects.cpp

@ -246,10 +246,15 @@ void sound_update()
StreamUpdate(); StreamUpdate();
} }
void effects_cleanup_sfx() void effects_cleanup_sfx(bool fullUnload)
{ {
sound_stop(); sound_stop();
if (fullUnload) {
sgSFX.clear();
return;
}
for (auto &sfx : sgSFX) for (auto &sfx : sgSFX)
sfx.pSnd = nullptr; 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 PlaySfxLoc(SfxID psfx, Point position, bool randomizeByCategory = true);
void sound_stop(); void sound_stop();
void sound_update(); void sound_update();
void effects_cleanup_sfx(); void effects_cleanup_sfx(bool fullUnload = true);
void sound_init(); void sound_init();
void ui_sound_init(); void ui_sound_init();
void effects_play_sound(SfxID); void effects_play_sound(SfxID);

2
Source/engine/sound.cpp

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

8
Source/lua/lua_global.cpp

@ -10,6 +10,7 @@
#include <config.h> #include <config.h>
#include "appfat.h" #include "appfat.h"
#include "effects.h"
#include "engine/assets.hpp" #include "engine/assets.hpp"
#include "lua/modules/audio.hpp" #include "lua/modules/audio.hpp"
#include "lua/modules/hellfire.hpp" #include "lua/modules/hellfire.hpp"
@ -229,6 +230,13 @@ void LuaReloadActiveMods()
handler(); 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) // Reload game data (this can probably be done later in the process to avoid having to reload it)
LoadTextData(); LoadTextData();
LoadPlayerDataFiles(); LoadPlayerDataFiles();

Loading…
Cancel
Save