diff --git a/src/sound/SI2.cpp b/src/sound/SI2.cpp index ca0673e..e710e36 100644 --- a/src/sound/SI2.cpp +++ b/src/sound/SI2.cpp @@ -3,9 +3,11 @@ #include "sound/CVarHandlers.hpp" #include "sound/SESound.hpp" #include "sound/SOUNDKITDEF.hpp" +#include "sound/SOUNDKITLOOKUP.hpp" #include "ui/FrameScript.hpp" TSGrowableArray SI2::s_SoundKitDefs; +TSHashTable SI2::s_SoundKitLookupTable; int32_t SI2::Init(int32_t a1) { // TODO @@ -108,7 +110,7 @@ void SI2::InitSoundKitDefs() { for (uint32_t i = 0; i < g_soundEntriesDB.GetNumRecords(); i++) { auto soundEntriesRec = g_soundEntriesDB.GetRecordByIndex(i); - // Sound kit definition + // Populate sound kit definitions auto soundKitDef = STORM_NEW(SOUNDKITDEF); @@ -145,6 +147,8 @@ void SI2::InitSoundKitDefs() { soundKitDef->fileCount++; } + // Copy relevant record fields + soundKitDef->flags = soundEntriesRec->m_flags; soundKitDef->name = soundEntriesRec->m_name; soundKitDef->minDistance = soundEntriesRec->m_minDistance; @@ -160,9 +164,15 @@ void SI2::InitSoundKitDefs() { SI2::s_SoundKitDefs[soundEntriesRec->GetID()] = soundKitDef; - // Sound kit lookup + // Populate sound kit lookups - // TODO SOUNDKITLOOKUP + auto soundKitLookup = SI2::s_SoundKitLookupTable.Ptr(soundEntriesRec->m_name); + + if (!soundKitLookup) { + soundKitLookup = SI2::s_SoundKitLookupTable.New(soundEntriesRec->m_name, 0, 0x0); + } + + soundKitLookup->ID = soundEntriesRec->GetID(); } } diff --git a/src/sound/SI2.hpp b/src/sound/SI2.hpp index 1b6fd4a..b315979 100644 --- a/src/sound/SI2.hpp +++ b/src/sound/SI2.hpp @@ -1,10 +1,13 @@ #ifndef SOUND_SI2_HPP #define SOUND_SI2_HPP +#include "SOUNDKITLOOKUP.hpp" #include "sound/SI2Script.hpp" +#include "storm/hash/Hashkey.hpp" +#include "storm/hash/TSHashTable.hpp" #include "ui/Types.hpp" -#include #include +#include class SOUNDKITDEF; @@ -13,6 +16,7 @@ class SI2 { // Static variables static FrameScript_Method s_ScriptFunctions[NUM_SCRIPT_FUNCTIONS_SI2]; static TSGrowableArray s_SoundKitDefs; + static TSHashTable s_SoundKitLookupTable; // Static functions static int32_t Init(int32_t a1);