From d807743447eddc44891cd9829e8791f8ab5b6a13 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 23 Feb 2024 23:14:52 -0500 Subject: [PATCH] do not add duplicate sounds to the sab files --- .../ObjContainer/SoundBank/SoundBankWriter.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp index 153a75ba..5c495209 100644 --- a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp +++ b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp @@ -46,7 +46,17 @@ public: void AddSound(const std::string& soundFilePath, unsigned int soundId, bool looping, bool streamed) override { - this->m_sounds.emplace_back(soundFilePath, soundId, looping, streamed); + auto itr = std::find_if(this->m_sounds.begin(), + this->m_sounds.end(), + [soundId](SoundBankEntryInfo& entry) + { + return entry.m_sound_id == soundId; + }); + + if (itr == this->m_sounds.end()) + { + this->m_sounds.emplace_back(soundFilePath, soundId, looping, streamed); + } } void GoTo(const int64_t offset)