From 9b977ba96e6692ef77029cde35a62300f8032c2f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 22:42:24 +0200 Subject: [PATCH] - fixed mixup of values 0 and -1 in sound code. 0 means 'default', -1 means 'silent'. This caused playback issues for useSoundGen. All other places were passing proper volume values along, this is the only one to read the volume from map data. --- source/games/blood/src/sfx.cpp | 7 ++++--- source/games/blood/src/sound.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index b12c01b3e..dd64ab3e4 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -149,7 +149,8 @@ FSoundID getSfx(FSoundID soundId, float &attenuation, int &pitch, int &relvol) auto udata = soundEngine->GetUserData(soundId); if (pitch < 0) pitch = udata ? udata[0] : 0x10000; - if (relvol < 0) relvol = udata && udata[2] ? udata[2] : 80; + if (relvol < 0) relvol = 0; + else if (relvol == 0) relvol = udata && udata[2] ? udata[2] : 80; if (relvol > 255) relvol = 255; // Limit the attenuation. More than 2.0 is simply too much. attenuation = relvol > 0 ? clamp(80.f / relvol, 0.f, 2.f) : 1.f; @@ -167,7 +168,7 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector) float attenuation; int pitch = -1; - int relvol = -1; + int relvol = 0; sid = getSfx(sid, attenuation, pitch, relvol); auto sfx = soundEngine->GetSfx(sid); EChanFlags flags = CHANF_OVERLAP; @@ -225,7 +226,7 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3, int a4, int pitc void sfxPlay3DSound(spritetype* pSprite, int soundId, int a3, int a4) { - sfxPlay3DSoundCP(pSprite, soundId, a3, a4, -1, -1); + sfxPlay3DSoundCP(pSprite, soundId, a3, a4, -1); } diff --git a/source/games/blood/src/sound.h b/source/games/blood/src/sound.h index 8f9566234..a4c384910 100644 --- a/source/games/blood/src/sound.h +++ b/source/games/blood/src/sound.h @@ -54,7 +54,7 @@ void sfxInit(void); void sfxTerm(void); void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector); void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0); -void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = -1); +void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0); void sfxKill3DSound(spritetype *pSprite, int a2 = -1, int a3 = -1); void sfxKillAllSounds(void); void sfxSetReverb(bool toggle);