From 5dfdac62ab88c06c2e2993b811b1e17a467d3a3d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 2 Mar 2020 00:42:02 -0500 Subject: [PATCH] - add checking in S_StartSound for startTime length --- src/sound/s_sound.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index 5979d320f..a3250582e 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -36,6 +36,7 @@ #include #include +#include "templates.h" #include "s_soundinternal.h" #include "m_swap.h" #include "superfasthash.h" @@ -566,9 +567,13 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, if (chanflags & (CHANF_UI|CHANF_NOPAUSE)) startflags |= SNDF_NOPAUSE; if (chanflags & CHANF_UI) startflags |= SNDF_NOREVERB; + startTime = (startflags & SNDF_LOOP) + ? fmod(startTime, (float)GSnd->GetMSLength(sfx->data) / 1000.f) + : clamp(startTime, 0.f, (float)GSnd->GetMSLength(sfx->data) / 1000.f); + if (attenuation > 0 && type != SOURCE_None) { - chan = (FSoundChan*)GSnd->StartSound3D (sfx->data, &listener, float(volume), rolloff, float(attenuation), pitch, basepriority, pos, vel, channel, startflags, NULL, startTime); + chan = (FSoundChan*)GSnd->StartSound3D (sfx->data, &listener, float(volume), rolloff, float(attenuation), pitch, basepriority, pos, vel, channel, startflags, NULL, startTime); } else {