From 4a44f62b10f7744a363ce448822b71d4abae95e6 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Thu, 25 Jul 2019 04:19:51 +0530 Subject: HDB: Add extension field to SoundCache --- engines/hdb/sound.cpp | 9 +++++++-- engines/hdb/sound.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp index b10c5d573a..5eda13341c 100644 --- a/engines/hdb/sound.cpp +++ b/engines/hdb/sound.cpp @@ -1417,7 +1417,12 @@ bool Sound::init() { _soundCache[index2].loaded = false; _soundCache[index2].name = soundList[index].name; _soundCache[index2].luaName = soundList[index].luaName; - debug(9, "sName: %s, sLuaName: %s", soundList[index].name, soundList[index].luaName); + // FIXME: Create an intuitive way to include #166 + if (index2 < SND_UNLOCKED_ITEM || index == 166) + _soundCache[index2].ext = -1; // WAV + else + _soundCache[index2].ext = 1; // MP3 + debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index2].name, soundList[index2].luaName, _soundCache[index2].ext == 1 ? "MP3" : "WAV"); index++; if (index > kMaxSounds) error("Reached MAX_SOUNDS in Sound::Init() !"); @@ -1497,7 +1502,6 @@ int Sound::registerSound(const char *name) { _soundCache[index].name = name; _soundCache[index].loaded = 0; // just to be sure! - return index; } @@ -1505,6 +1509,7 @@ bool Sound::freeSound(int index) { if (_soundCache[index].loaded == 1) { warning("STUB: Free the audio stream in cache"); _soundCache[index].loaded = 0; + _soundCache[index].ext = 0; return true; } return false; diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h index 0dbb1cfc30..67b8d10da5 100644 --- a/engines/hdb/sound.h +++ b/engines/hdb/sound.h @@ -1413,10 +1413,11 @@ struct SoundCache { int32 size; // size of sound const char *name; // filename / MSD name const char *luaName; // name used by Lua for i.d. + int ext; // 0 = Uninitialized, -1 = WAV, 1 = MP3 //void *data; // actual file data //FSOUND_SAMPLE *sample; // used to play sound in FMOD - SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr) { + SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) { } }; -- cgit v1.2.3