From 7470286d5bc36ccab25de61194bfc93a30697fde Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 24 Nov 2020 00:14:32 +0100 Subject: [PATCH] - Exhumed: Switch sounds must use CHANF_LISTENERZ because they use no z-coordinate for their position. --- source/exhumed/src/sound.cpp | 12 ++++++------ source/exhumed/src/sound.h | 4 ++-- source/exhumed/src/switch.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/exhumed/src/sound.cpp b/source/exhumed/src/sound.cpp index 728748aaa..d58264b58 100644 --- a/source/exhumed/src/sound.cpp +++ b/source/exhumed/src/sound.cpp @@ -485,7 +485,7 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], } if ((chanflags & CHANF_LISTENERZ) && type != SOURCE_None) { - pos->Y = fcampos.Z; + pos->Y = fcampos.Y; } } } @@ -558,7 +558,7 @@ void GameInterface::UpdateSounds() int soundx, soundy, soundz; short soundsect; -void PlayFX2(unsigned short nSound, short nSprite, int sectf) +void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanflags) { if (!SoundEnabled()) return; if ((nSound&0x1ff) >= kMaxSounds || !soundEngine->isValidSoundId((nSound & 0x1ff)+1)) @@ -637,11 +637,11 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf) FSoundChan* chan = nullptr; if (nSprite >= 0) { - chan = soundEngine->StartSound(SOURCE_Actor, &sprite[nSprite], nullptr, CHAN_BODY, CHANF_OVERLAP, nSound+1, nVolume / 255.f,fullvol? 0.5 : ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f); + chan = soundEngine->StartSound(SOURCE_Actor, &sprite[nSprite], nullptr, CHAN_BODY, chanflags| CHANF_OVERLAP, nSound+1, nVolume / 255.f,fullvol? 0.5 : ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f); } else { - chan = soundEngine->StartSound(SOURCE_Unattached, nullptr, &vv, CHAN_BODY, CHANF_OVERLAP, nSound+1, nVolume / 255.f, ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f); + chan = soundEngine->StartSound(SOURCE_Unattached, nullptr, &vv, CHAN_BODY, chanflags | CHANF_OVERLAP, nSound+1, nVolume / 255.f, ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f); } if (chan) { @@ -660,13 +660,13 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf) // //========================================================================== -void PlayFXAtXYZ(unsigned short ax, int x, int y, int z, int nSector) +void PlayFXAtXYZ(unsigned short ax, int x, int y, int z, int nSector, EChanFlags chanflags) { soundx = x; soundy = y; soundz = z; soundsect = nSector&0x3fff; - PlayFX2(ax, -1, nSector & 0x4000); + PlayFX2(ax, -1, nSector & 0x4000, chanflags); } //========================================================================== diff --git a/source/exhumed/src/sound.h b/source/exhumed/src/sound.h index e2507b1dd..175728a43 100644 --- a/source/exhumed/src/sound.h +++ b/source/exhumed/src/sound.h @@ -131,8 +131,8 @@ int LoadSound(const char* sound); void BendAmbientSound(); void CheckAmbience(short nSector); -void PlayFX2(unsigned short nSound, short nSprite, int sectf = 0); -void PlayFXAtXYZ(unsigned short nSound, int x, int y, int z, int nSector); +void PlayFX2(unsigned short nSound, short nSprite, int sectf = 0, EChanFlags chanflags = CHANF_NONE); +void PlayFXAtXYZ(unsigned short nSound, int x, int y, int z, int nSector, EChanFlags chanflags = CHANF_NONE); inline void D3PlayFX(unsigned short nSound, short nVal) { PlayFX2(nSound, nVal); diff --git a/source/exhumed/src/switch.cpp b/source/exhumed/src/switch.cpp index 818b60880..de52cc3f6 100644 --- a/source/exhumed/src/switch.cpp +++ b/source/exhumed/src/switch.cpp @@ -463,7 +463,7 @@ void FuncSwPressSector(int a, int, int nRun) if (SwitchData[nSwitch].field_12) { short nSprite = PlayerList[nPlayer].nSprite; - PlayFXAtXYZ(StaticSound[nSwitchSound], sprite[nSprite].x, sprite[nSprite].y, 0, sprite[nSprite].sectnum); + PlayFXAtXYZ(StaticSound[nSwitchSound], sprite[nSprite].x, sprite[nSprite].y, 0, sprite[nSprite].sectnum, CHANF_LISTENERZ); StatusMessage(300, "YOU NEED THE KEY FOR THIS DOOR"); } @@ -540,7 +540,7 @@ void FuncSwPressWall(int a, int, int nRun) short nWall = SwitchData[nSwitch].nWall; short nSector = SwitchData[nSwitch].nSector; // CHECKME - where is this set?? - PlayFXAtXYZ(StaticSound[nSwitchSound], wall[nWall].x, wall[nWall].y, 0, nSector); + PlayFXAtXYZ(StaticSound[nSwitchSound], wall[nWall].x, wall[nWall].y, 0, nSector, CHANF_LISTENERZ); return; }