diff --git a/source/common/audio/sound/s_soundinternal.h b/source/common/audio/sound/s_soundinternal.h index cbdeae464..df6943c5d 100644 --- a/source/common/audio/sound/s_soundinternal.h +++ b/source/common/audio/sound/s_soundinternal.h @@ -254,6 +254,11 @@ public: virtual void StopChannel(FSoundChan* chan); sfxinfo_t* LoadSound(sfxinfo_t* sfx); + const sfxinfo_t* GetSfx(unsigned snd) + { + if (snd >= S_sfx.Size()) return nullptr; + return &S_sfx[snd]; + } // Initializes sound stuff, including volume // Sets channels, SFX and music volume, diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index aa841ac84..b12c01b3e 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -169,8 +169,11 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector) int pitch = -1; int relvol = -1; sid = getSfx(sid, attenuation, pitch, relvol); + auto sfx = soundEngine->GetSfx(sid); + EChanFlags flags = CHANF_OVERLAP; + if (sfx && sfx->LoopStart >= 0) flags |= CHANF_LOOP; - soundEngine->StartSound(SOURCE_Unattached, nullptr, &svec, -1, CHANF_OVERLAP, sid, (0.8f / 80.f) * relvol, attenuation, nullptr, pitch / 65536.f); + soundEngine->StartSound(SOURCE_Unattached, nullptr, &svec, -1, flags, sid, (0.8f / 80.f) * relvol, attenuation, nullptr, pitch / 65536.f); } @@ -213,7 +216,11 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3, int a4, int pitc } - soundEngine->StartSound(SOURCE_Actor, pSprite, &svec, a3, a3 == -1? CHANF_OVERLAP : CHANF_NONE , sid, volume * (0.8f / 80.f), attenuation, nullptr, pitch / 65536.f); + auto sfx = soundEngine->GetSfx(sid); + EChanFlags flags = a3 == -1 ? CHANF_OVERLAP : CHANF_NONE; + if (sfx && sfx->LoopStart >= 0) flags |= CHANF_LOOP; + + soundEngine->StartSound(SOURCE_Actor, pSprite, &svec, a3, flags, sid, volume * (0.8f / 80.f), attenuation, nullptr, pitch / 65536.f); } void sfxPlay3DSound(spritetype* pSprite, int soundId, int a3, int a4)