mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
fixed possible null access crash
This was SVN commit r12866.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user