From 28095be341dcb88bc69e65c08a003bc03f66f001 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sat, 22 Nov 2025 23:09:03 -0600 Subject: [PATCH] feat(sound): implement SI2::PlayUISound --- src/sound/SI2.cpp | 21 ++++++++++++++++++++- src/sound/SI2.hpp | 2 ++ src/sound/SoundKitProperties.cpp | 22 ++++++++++++++++++++++ src/sound/SoundKitProperties.hpp | 23 +++++++++++++++++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/sound/SoundKitProperties.cpp create mode 100644 src/sound/SoundKitProperties.hpp diff --git a/src/sound/SI2.cpp b/src/sound/SI2.cpp index 15fe9a8..9d35c92 100644 --- a/src/sound/SI2.cpp +++ b/src/sound/SI2.cpp @@ -1,4 +1,5 @@ #include "sound/SI2.hpp" +#include "SoundKitProperties.hpp" #include "console/CVar.hpp" #include "sound/CVarHandlers.hpp" #include "sound/SESound.hpp" @@ -229,10 +230,28 @@ void SI2::InitSoundKitGroups() { } } -void SI2::PlayUISound(int32_t id) { +void SI2::PlaySoundKit(int32_t id, int32_t a2, void* handle, const SoundKitProperties& properties, int32_t a5, void* a6, int32_t a7, int32_t a8) { // TODO } +void SI2::PlayUISound(int32_t id) { + static auto voiceChatOnID = SI2::GetSoundKitID("VoiceChatOn"); + static auto voiceChatOffID = SI2::GetSoundKitID("VoiceChatOff"); + + SoundKitProperties properties; + properties.ResetToDefaults(); + + if (id == voiceChatOnID || id == voiceChatOffID) { + properties.m_type = 3; + } + + properties.int20 = 128; + properties.uint24 = 2; + properties.uint3C = 0; + + SI2::PlaySoundKit(id, 0, nullptr, properties, 0, nullptr, 1, 0); +} + void SI2::RegisterCVars() { CVar::Register( "StartTalkingDelay", diff --git a/src/sound/SI2.hpp b/src/sound/SI2.hpp index 49fdc20..99d462f 100644 --- a/src/sound/SI2.hpp +++ b/src/sound/SI2.hpp @@ -9,6 +9,7 @@ class SOUNDKITDEF; struct SOUNDKITLOOKUP; +class SoundKitProperties; class SI2 { public: @@ -24,6 +25,7 @@ class SI2 { static int32_t Init(int32_t a1); static void InitSoundKitDefs(); static void InitSoundKitGroups(); + static void PlaySoundKit(int32_t id, int32_t a2, void* handle, const SoundKitProperties& properties, int32_t a5, void* a6, int32_t a7, int32_t a8); static void PlayUISound(int32_t id); static void RegisterCVars(); static void RegisterScriptFunctions(); diff --git a/src/sound/SoundKitProperties.cpp b/src/sound/SoundKitProperties.cpp new file mode 100644 index 0000000..51a313f --- /dev/null +++ b/src/sound/SoundKitProperties.cpp @@ -0,0 +1,22 @@ +#include "sound/SoundKitProperties.hpp" +#include "util/SFile.hpp" + +void SoundKitProperties::ResetToDefaults() { + // TODO + + this->int20 = -1; + + // TODO + + this->m_type = 0; + + // TODO + + this->uint24 = 0; + + // TODO + + this->m_streaming = SFile::IsStreamingMode() != 0; + + // TODO +} diff --git a/src/sound/SoundKitProperties.hpp b/src/sound/SoundKitProperties.hpp new file mode 100644 index 0000000..7887c28 --- /dev/null +++ b/src/sound/SoundKitProperties.hpp @@ -0,0 +1,23 @@ +#ifndef SOUND_SOUND_KIT_PROPERTIES_HPP +#define SOUND_SOUND_KIT_PROPERTIES_HPP + +#include + +class SoundKitProperties { + public: + // Member variables + uint32_t m_type; + // TODO + int32_t int20; + uint32_t uint24; + // TODO + uint32_t uint3C; + // TODO + int32_t m_streaming; + // TODO + + // Member functions + void ResetToDefaults(); +}; + +#endif