From 10f350ad1f5e14b0b6eb240dc286e3f7769e62fe Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sat, 22 Nov 2025 10:16:16 -0600 Subject: [PATCH] chore(sound): cvars in SI2::Init are local statics --- src/sound/SI2.cpp | 43 +++++-------------------------------------- src/sound/SI2.hpp | 7 ------- 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/src/sound/SI2.cpp b/src/sound/SI2.cpp index 3738a11..59cfa22 100644 --- a/src/sound/SI2.cpp +++ b/src/sound/SI2.cpp @@ -4,14 +4,6 @@ #include "sound/SESound.hpp" #include "ui/FrameScript.hpp" -CVar* SI2::s_pCVar_Sound_EnableReverb; -CVar* SI2::s_pCVar_Sound_EnableSoftwareHRTF; -CVar* SI2::s_pCVar_Sound_NumChannels; -CVar* SI2::s_pCVar_Sound_OutputDriverIndex; -CVar* SI2::s_pCVar_Sound_OutputDriverName; - -static int32_t s_initFlags; - int32_t SI2::Init(int32_t a1) { // TODO // if (CmdLineGetBool(26)) { @@ -38,12 +30,7 @@ int32_t SI2::Init(int32_t a1) { int32_t enableReverb = 0; - if (!(s_initFlags & 0x1)) { - SI2::s_pCVar_Sound_EnableReverb = CVar::Lookup("Sound_EnableReverb"); - s_initFlags |= 0x1; - } - - auto enableReverbVar = SI2::s_pCVar_Sound_EnableReverb; + static auto enableReverbVar = CVar::Lookup("Sound_EnableReverb"); if (enableReverbVar) { enableReverb = enableReverbVar->GetInt(); @@ -53,12 +40,7 @@ int32_t SI2::Init(int32_t a1) { int32_t enableSoftwareHRTF = 0; - if (!(s_initFlags & 0x2)) { - SI2::s_pCVar_Sound_EnableSoftwareHRTF = CVar::Lookup("Sound_EnableSoftwareHRTF"); - s_initFlags |= 0x2; - } - - auto enableSoftwareHRTFVar = SI2::s_pCVar_Sound_EnableSoftwareHRTF; + static auto enableSoftwareHRTFVar = CVar::Lookup("Sound_EnableSoftwareHRTF"); if (enableSoftwareHRTFVar) { enableSoftwareHRTF = enableSoftwareHRTFVar->GetInt(); @@ -68,12 +50,7 @@ int32_t SI2::Init(int32_t a1) { int32_t numChannels = 4; - if (!(s_initFlags & 0x4)) { - SI2::s_pCVar_Sound_NumChannels = CVar::Lookup("Sound_NumChannels"); - s_initFlags |= 0x4; - } - - auto numChannelsVar = SI2::s_pCVar_Sound_NumChannels; + static auto numChannelsVar = CVar::Lookup("Sound_NumChannels"); if (numChannelsVar) { numChannels = numChannelsVar->GetInt(); @@ -83,12 +60,7 @@ int32_t SI2::Init(int32_t a1) { int32_t outputDriverIndex = 0; - if (!(s_initFlags & 0x8)) { - SI2::s_pCVar_Sound_OutputDriverIndex = CVar::Lookup("Sound_OutputDriverIndex"); - s_initFlags |= 0x8; - } - - auto outputDriverIndexVar = SI2::s_pCVar_Sound_OutputDriverIndex; + static auto outputDriverIndexVar = CVar::Lookup("Sound_OutputDriverIndex"); if (outputDriverIndexVar) { outputDriverIndex = outputDriverIndexVar->GetInt(); @@ -98,12 +70,7 @@ int32_t SI2::Init(int32_t a1) { const char* outputDriverName = ""; - if (!(s_initFlags & 0x10)) { - SI2::s_pCVar_Sound_OutputDriverName = CVar::Lookup("Sound_OutputDriverName"); - s_initFlags |= 0x10; - } - - auto outputDriverNameVar = SI2::s_pCVar_Sound_OutputDriverName; + static auto outputDriverNameVar = CVar::Lookup("Sound_OutputDriverName"); if (outputDriverNameVar) { outputDriverName = outputDriverNameVar->GetString(); diff --git a/src/sound/SI2.hpp b/src/sound/SI2.hpp index 2189671..ba4992e 100644 --- a/src/sound/SI2.hpp +++ b/src/sound/SI2.hpp @@ -5,16 +5,9 @@ #include "ui/Types.hpp" #include -class CVar; - class SI2 { public: // Static variables - static CVar* s_pCVar_Sound_EnableReverb; - static CVar* s_pCVar_Sound_EnableSoftwareHRTF; - static CVar* s_pCVar_Sound_NumChannels; - static CVar* s_pCVar_Sound_OutputDriverIndex; - static CVar* s_pCVar_Sound_OutputDriverName; static FrameScript_Method s_ScriptFunctions[NUM_SCRIPT_FUNCTIONS_SI2]; // Static functions