Prevent modulo 0

This commit is contained in:
BeaR 2014-10-23 12:04:46 +02:00
parent 99c07d884d
commit 78aa7c51be

View file

@ -561,8 +561,8 @@ void CSound::SetVoiceTimeOffset(CVoiceHandle Voice, float offset)
if(m_aVoices[VoiceID].m_pSample)
{
int TickOffset = m_aVoices[VoiceID].m_pSample->m_Rate * offset;
if(m_aVoices[VoiceID].m_Flags&ISound::FLAG_POS)
TickOffset = TickOffset%m_aVoices[VoiceID].m_pSample->m_NumFrames;
if(m_aVoices[VoiceID].m_pSample->m_NumFrames > 0 && m_aVoices[VoiceID].m_Flags&ISound::FLAG_POS)
TickOffset = TickOffset % m_aVoices[VoiceID].m_pSample->m_NumFrames;
else
TickOffset = clamp(TickOffset, 0, m_aVoices[VoiceID].m_pSample->m_NumFrames);