From 1503bbce4ea46f054af8f8abb9c14ad64cd1da67 Mon Sep 17 00:00:00 2001 From: TheRedDaemon <66257843+TheRedDaemon@users.noreply.github.com> Date: Sun, 17 May 2026 23:37:46 +0200 Subject: [PATCH] reimplement: SHC_3BB0A8C1_0x00479C80 optimization issues --- .../findSamplePlaceForSoundUnk.cpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/OpenSHC/Audio/mss/SoundSystem/findSamplePlaceForSoundUnk.cpp diff --git a/src/OpenSHC/Audio/mss/SoundSystem/findSamplePlaceForSoundUnk.cpp b/src/OpenSHC/Audio/mss/SoundSystem/findSamplePlaceForSoundUnk.cpp new file mode 100644 index 0000000..08354bc --- /dev/null +++ b/src/OpenSHC/Audio/mss/SoundSystem/findSamplePlaceForSoundUnk.cpp @@ -0,0 +1,40 @@ +#include "OpenSHC/Audio/mss/SoundSystem.func.hpp" + +#include "OpenSHC/Globals/DAT_SoundEffectsHelperData1.hpp" + +namespace OpenSHC { +namespace Audio { + namespace MSS { + + // TODO: Remove, only test + // GLOBAL: STRONGHOLDCRUSADER 0x00df3828 + int test; + + // FUNCTION: STRONGHOLDCRUSADER 0x00479C80 + void SoundSystem::findSamplePlaceForSoundUnk(int soundIndex) + { + if (this->soundFileCurrSampleNum_0x28c[soundIndex] >= 0) { + return; + } + + test = 0; // DAT_SoundEffectsHelperData1::ptr->DAT_NumberOfUsedSoundSamplePlaces = 0; + + for (int i = 1; i < 32; ++i) { + if (this->sampleSoundIndex_0x20c[i]) { + ++test; // ++DAT_SoundEffectsHelperData1::ptr->DAT_NumberOfUsedSoundSamplePlaces; + } + } + + for (int i = 1; i < 32; ++i) { + if (this->sampleSoundIndex_0x20c[i]) { + continue; + } + this->sampleSoundIndex_0x20c[i] = soundIndex; + this->soundFileCurrSampleNum_0x28c[soundIndex] = i; + return; + } + } + + } +} +}