Skip to content

Commit c55e7a4

Browse files
StephenCWillsAJenbo
authored andcommitted
Reload sfx when reloading active mods
1 parent 714ae37 commit c55e7a4

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

Source/diablo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ void OptionLanguageCodeChanged()
17901790
UnloadFonts();
17911791
LanguageInitialize();
17921792
LoadLanguageArchive();
1793-
effects_cleanup_sfx();
1793+
effects_cleanup_sfx(false);
17941794
if (gbRunGame)
17951795
sound_init();
17961796
else

Source/effects.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,15 @@ void sound_update()
246246
StreamUpdate();
247247
}
248248

249-
void effects_cleanup_sfx()
249+
void effects_cleanup_sfx(bool fullUnload)
250250
{
251251
sound_stop();
252252

253+
if (fullUnload) {
254+
sgSFX.clear();
255+
return;
256+
}
257+
253258
for (auto &sfx : sgSFX)
254259
sfx.pSnd = nullptr;
255260
}

Source/effects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void PlaySFX(SfxID psfx);
3131
void PlaySfxLoc(SfxID psfx, Point position, bool randomizeByCategory = true);
3232
void sound_stop();
3333
void sound_update();
34-
void effects_cleanup_sfx();
34+
void effects_cleanup_sfx(bool fullUnload = true);
3535
void sound_init();
3636
void ui_sound_init();
3737
void effects_play_sound(SfxID);

Source/engine/sound.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int CapVolume(int volume)
171171

172172
void OptionAudioChanged()
173173
{
174-
effects_cleanup_sfx();
174+
effects_cleanup_sfx(false);
175175
music_stop();
176176
snd_deinit();
177177
snd_init();

Source/lua/lua_global.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <config.h>
1111

1212
#include "appfat.h"
13+
#include "effects.h"
1314
#include "engine/assets.hpp"
1415
#include "lua/modules/audio.hpp"
1516
#include "lua/modules/hellfire.hpp"
@@ -229,6 +230,13 @@ void LuaReloadActiveMods()
229230
handler();
230231
}
231232

233+
// Reload sound effects in case a mod archive overrides effects.tsv
234+
effects_cleanup_sfx();
235+
if (gbRunGame)
236+
sound_init();
237+
else
238+
ui_sound_init();
239+
232240
// Reload game data (this can probably be done later in the process to avoid having to reload it)
233241
LoadTextData();
234242
LoadPlayerDataFiles();

0 commit comments

Comments
 (0)