From 6320f99388d92b5785a07ddc2de5a5250b6fe8cf Mon Sep 17 00:00:00 2001 From: Amun Date: Wed, 7 Jan 2026 18:47:25 +0200 Subject: [PATCH] Sound effects volume bug --- .../PythonSoundManagerModule.cpp | 13 +---------- src/UserInterface/PythonSystem.cpp | 23 ++++++++----------- src/UserInterface/PythonSystem.h | 6 ++--- src/UserInterface/PythonSystemModule.cpp | 8 +++---- 4 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/UserInterface/PythonSoundManagerModule.cpp b/src/UserInterface/PythonSoundManagerModule.cpp index 3fdd410..e8a4a91 100644 --- a/src/UserInterface/PythonSoundManagerModule.cpp +++ b/src/UserInterface/PythonSoundManagerModule.cpp @@ -96,7 +96,7 @@ PyObject* sndSetMusicVolume(PyObject* poSelf, PyObject* poArgs) return Py_BuildNone(); } -PyObject* sndSetSoundVolumef(PyObject* poSelf, PyObject* poArgs) +PyObject* sndSetSoundVolume(PyObject* poSelf, PyObject* poArgs) { float fVolume; if (!PyTuple_GetFloat(poArgs, 0, &fVolume)) @@ -106,16 +106,6 @@ PyObject* sndSetSoundVolumef(PyObject* poSelf, PyObject* poArgs) return Py_BuildNone(); } -PyObject* sndSetSoundVolume(PyObject* poSelf, PyObject* poArgs) -{ - float volume; - if (!PyTuple_GetFloat(poArgs, 0, &volume)) - return Py_BuildException(); - - SoundEngine::Instance().SetSoundVolume(volume / 100.0f); - return Py_BuildNone(); -} - void initsnd() { static PyMethodDef s_methods[] = @@ -130,7 +120,6 @@ void initsnd() { "SetMasterVolume", sndSetMasterVolume, METH_VARARGS }, { "SetMusicVolume", sndSetMusicVolume, METH_VARARGS }, - { "SetSoundVolumef", sndSetSoundVolumef, METH_VARARGS }, { "SetSoundVolume", sndSetSoundVolume, METH_VARARGS }, { NULL, NULL, NULL }, }; diff --git a/src/UserInterface/PythonSystem.cpp b/src/UserInterface/PythonSystem.cpp index fbeb7c0..7e45a4c 100644 --- a/src/UserInterface/PythonSystem.cpp +++ b/src/UserInterface/PythonSystem.cpp @@ -213,7 +213,7 @@ float CPythonSystem::GetMusicVolume() return m_Config.music_volume; } -int CPythonSystem::GetSoundVolume() +float CPythonSystem::GetSoundVolume() { return m_Config.voice_volume; } @@ -223,9 +223,9 @@ void CPythonSystem::SetMusicVolume(float fVolume) m_Config.music_volume = fVolume; } -void CPythonSystem::SetSoundVolumef(float fVolume) +void CPythonSystem::SetSoundVolume(float fVolume) { - m_Config.voice_volume = int(5 * fVolume); + m_Config.voice_volume = fVolume; } int CPythonSystem::GetDistance() @@ -294,7 +294,7 @@ void CPythonSystem::SetDefaultConfig() m_Config.gamma = 3; m_Config.music_volume = 1.0f; - m_Config.voice_volume = 5; + m_Config.voice_volume = 1.0f; m_Config.bDecompressDDS = 0; m_Config.bSoftwareTiling = 0; @@ -409,15 +409,10 @@ bool CPythonSystem::LoadConfig() m_Config.is_object_culling = atoi(value) ? true : false; else if (!stricmp(command, "VISIBILITY")) m_Config.iDistance = atoi(value); - else if (!stricmp(command, "MUSIC_VOLUME")) { - if(strchr(value, '.') == 0) { // Old compatiability - m_Config.music_volume = pow(10.0f, (-1.0f + (((float) atoi(value)) / 5.0f))); - if(atoi(value) == 0) - m_Config.music_volume = 0.0f; - } else - m_Config.music_volume = atof(value); - } else if (!stricmp(command, "VOICE_VOLUME")) - m_Config.voice_volume = (char) atoi(value); + else if (!stricmp(command, "MUSIC_VOLUME")) + m_Config.music_volume = atof(value); + else if (!stricmp(command, "VOICE_VOLUME")) + m_Config.voice_volume = atof(value); else if (!stricmp(command, "GAMMA")) m_Config.gamma = atoi(value); else if (!stricmp(command, "IS_SAVE_ID")) @@ -503,7 +498,7 @@ bool CPythonSystem::SaveConfig() "OBJECT_CULLING %d\n" "VISIBILITY %d\n" "MUSIC_VOLUME %.3f\n" - "VOICE_VOLUME %d\n" + "VOICE_VOLUME %.3f\n" "GAMMA %d\n" "IS_SAVE_ID %d\n" "SAVE_ID %s\n" diff --git a/src/UserInterface/PythonSystem.h b/src/UserInterface/PythonSystem.h index f70d2b3..8528b83 100644 --- a/src/UserInterface/PythonSystem.h +++ b/src/UserInterface/PythonSystem.h @@ -59,7 +59,7 @@ class CPythonSystem : public CSingleton int iShadowLevel; FLOAT music_volume; - BYTE voice_volume; + FLOAT voice_volume; int gamma; @@ -141,9 +141,9 @@ class CPythonSystem : public CSingleton // Sound float GetMusicVolume(); - int GetSoundVolume(); + float GetSoundVolume(); void SetMusicVolume(float fVolume); - void SetSoundVolumef(float fVolume); + void SetSoundVolume(float fVolume); int GetDistance(); int GetShadowLevel(); diff --git a/src/UserInterface/PythonSystemModule.cpp b/src/UserInterface/PythonSystemModule.cpp index bc4f356..efd9e10 100644 --- a/src/UserInterface/PythonSystemModule.cpp +++ b/src/UserInterface/PythonSystemModule.cpp @@ -134,7 +134,7 @@ PyObject * systemGetMusicVolume(PyObject * poSelf, PyObject * poArgs) PyObject * systemGetSoundVolume(PyObject * poSelf, PyObject * poArgs) { - return Py_BuildValue("i", CPythonSystem::Instance().GetSoundVolume()); + return Py_BuildValue("f", CPythonSystem::Instance().GetSoundVolume()); } PyObject * systemSetMusicVolume(PyObject * poSelf, PyObject * poArgs) @@ -147,13 +147,13 @@ PyObject * systemSetMusicVolume(PyObject * poSelf, PyObject * poArgs) return Py_BuildNone(); } -PyObject * systemSetSoundVolumef(PyObject * poSelf, PyObject * poArgs) +PyObject * systemSetSoundVolume(PyObject * poSelf, PyObject * poArgs) { float fVolume; if (!PyTuple_GetFloat(poArgs, 0, &fVolume)) return Py_BuildException(); - CPythonSystem::Instance().SetSoundVolumef(fVolume); + CPythonSystem::Instance().SetSoundVolume(fVolume); return Py_BuildNone(); } @@ -408,7 +408,7 @@ void initsystem() { "GetSoundVolume", systemGetSoundVolume, METH_VARARGS }, { "SetMusicVolume", systemSetMusicVolume, METH_VARARGS }, - { "SetSoundVolumef", systemSetSoundVolumef, METH_VARARGS }, + { "SetSoundVolume", systemSetSoundVolume, METH_VARARGS }, { "IsSoftwareCursor", systemIsSoftwareCursor, METH_VARARGS }, { "SetViewChatFlag", systemSetViewChatFlag, METH_VARARGS },