fix error handling - ensure SoundGroup doesn't crash when sound loading fails (previously it was only handling the case where loading failed due to sound being disabled)

This was SVN commit r6269.
This commit is contained in:
janwas 2008-07-23 05:39:54 +00:00
parent aebe9a7936
commit fa7ce687f0

View File

@ -65,7 +65,7 @@ void CSoundGroup::PlayNext(const CVector3D& position)
{
// load up replacement file
m_hReplacement = snd_open(m_filepath + m_intensity_file);
if(m_hReplacement == ERR::AGAIN) // sound is disabled
if(m_hReplacement < 0) // one cause: sound is disabled
return;
snd_set_gain(m_hReplacement, m_Gain);
snd_set_pitch(m_hReplacement, m_Pitch);
@ -91,7 +91,7 @@ void CSoundGroup::PlayNext(const CVector3D& position)
m_index = (size_t)rand(0, (size_t)filenames.size());
// (note: previously snd_group[m_index] was used in place of hs)
Handle hs = snd_open(m_filepath + filenames[m_index]);
if(hs == ERR::AGAIN) // sound is disabled
if(hs < 0) // one cause: sound is disabled
return;
snd_set_gain(hs, m_Gain);
snd_set_pitch(hs, m_Pitch);