- Blood: Check the sound's internal loop flag when playing a sound.

Fixes #275
This commit is contained in:
Christoph Oelckers 2021-03-02 11:58:29 +01:00
parent e0f1a83f40
commit 4b59acd251
2 changed files with 14 additions and 2 deletions

View file

@ -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,

View file

@ -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)