Skip to content

Commit ba42a10

Browse files
committed
Don't allow undefined sfx pointers
1 parent 1064ec4 commit ba42a10

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/ItemManager.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
2929

3030
#include <sstream>
3131
#include <fstream>
32+
#include <cstring>
3233

3334
using namespace std;
3435

@@ -213,6 +214,7 @@ void ItemManager::load(const string& filename) {
213214
}
214215

215216
void ItemManager::loadSounds() {
217+
memset(sfx, 0, sizeof(sfx));
216218

217219
if (audio == true) {
218220
sfx[SFX_BOOK] = Mix_LoadWAV(mods->locate("soundfx/inventory/inventory_book.ogg").c_str());
@@ -227,18 +229,6 @@ void ItemManager::loadSounds() {
227229
sfx[SFX_HEAVY] = Mix_LoadWAV(mods->locate("soundfx/inventory/inventory_heavy.ogg").c_str());
228230
sfx[SFX_WOOD] = Mix_LoadWAV(mods->locate("soundfx/inventory/inventory_wood.ogg").c_str());
229231
sfx[SFX_POTION] = Mix_LoadWAV(mods->locate("soundfx/inventory/inventory_potion.ogg").c_str());
230-
} else {
231-
sfx[SFX_BOOK] = NULL;
232-
sfx[SFX_CLOTH] = NULL;
233-
sfx[SFX_COINS] = NULL;
234-
sfx[SFX_GEM] = NULL;
235-
sfx[SFX_LEATHER] = NULL;
236-
sfx[SFX_METAL] = NULL;
237-
sfx[SFX_PAGE] = NULL;
238-
sfx[SFX_MAILLE] = NULL;
239-
sfx[SFX_OBJECT] = NULL;
240-
sfx[SFX_HEAVY] = NULL;
241-
sfx[SFX_WOOD] = NULL;
242232
}
243233
}
244234

0 commit comments

Comments
 (0)