fixed possible null access crash

This was SVN commit r12866.
This commit is contained in:
stwf
2012-11-22 03:20:51 +00:00
parent 081c846ff1
commit 909956f8c3
+30 -24
View File
@@ -160,7 +160,8 @@ float CSoundGroup::RadiansOffCenter(const CVector3D& position, bool& onScreen, f
void CSoundGroup::UploadPropertiesAndPlay(int theIndex, const CVector3D& position)
{
#if CONFIG2_AUDIO
if ( g_SoundManager ) {
if ( g_SoundManager )
{
bool isOnscreen;
ALfloat initialRolllOff = 0.1f;
ALfloat itemRollOff = initialRolllOff;
@@ -172,31 +173,36 @@ void CSoundGroup::UploadPropertiesAndPlay(int theIndex, const CVector3D& positio
if (snd_group.size() == 0)
Reload();
ISoundItem* hSound = snd_group[theIndex];
CVector3D origin = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation();
float sndDist = origin.Y;
if (!TestFlag(eOmnipresent))
if ( snd_group.size() > theIndex )
{
if (TestFlag(eDistanceless))
itemRollOff = 0;
hSound->SetLocation(CVector3D((sndDist * sin(offSet)), 0, - sndDist * cos(offSet)));
hSound->SetRollOff(itemRollOff);
if ( ISoundItem* hSound = snd_group[theIndex] )
{
CVector3D origin = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation();
float sndDist = origin.Y;
if (!TestFlag(eOmnipresent))
{
if (TestFlag(eDistanceless))
itemRollOff = 0;
hSound->SetLocation(CVector3D((sndDist * sin(offSet)), 0, - sndDist * cos(offSet)));
hSound->SetRollOff(itemRollOff);
}
if (TestFlag(eRandPitch))
hSound->SetPitch(RandFloat(m_PitchLower, m_PitchUpper));
else
hSound->SetPitch(m_Pitch);
ALfloat theGain = m_Gain;
if (TestFlag(eRandGain))
theGain = RandFloat(m_GainLower, m_GainUpper);
hSound->SetCone(m_ConeInnerAngle, m_ConeOuterAngle, m_ConeOuterGain);
g_SoundManager->PlayGroupItem(hSound, theGain);
}
}
if (TestFlag(eRandPitch))
hSound->SetPitch(RandFloat(m_PitchLower, m_PitchUpper));
else
hSound->SetPitch(m_Pitch);
ALfloat theGain = m_Gain;
if (TestFlag(eRandGain))
theGain = RandFloat(m_GainLower, m_GainUpper);
hSound->SetCone(m_ConeInnerAngle, m_ConeOuterAngle, m_ConeOuterGain);
g_SoundManager->PlayGroupItem(hSound, theGain);
}
}
#else // !CONFIG2_AUDIO