Skip to content

Commit e1b7c73

Browse files
committed
Fix crash when attempting to stream out a sound that's not streamed in
1 parent 25ffe62 commit e1b7c73

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Client/mods/deathmatch/logic/CClientSoundManager.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,15 @@ void CClientSoundManager::UpdateDistanceStreaming(const CVector& vecListenerPosi
350350
// If the sound is more than 40 units away (or in another dimension), make sure it is deactivated
351351
// If the sound is less than 20 units away, make sure it is activated
352352
//
353-
for (std::set<CClientSound*>::iterator iter = considerMap.begin(); iter != considerMap.end(); ++iter)
353+
for (CClientSound* pSound : considerMap)
354354
{
355-
CClientSound* pSound = *iter;
356-
357355
// Calculate distance to the edge of the sphere
358356
CSphere sphere = pSound->GetWorldBoundingSphere();
359357
float fDistance = (vecListenerPosition - sphere.vecPosition).Length() - sphere.fRadius;
360358

361-
if (fDistance > 40 || m_usDimension != pSound->GetDimension())
359+
if ((fDistance > 40 || m_usDimension != pSound->GetDimension() && MapContains(m_DistanceStreamedInMap, pSound)))
362360
pSound->DistanceStreamOut();
363-
else if (fDistance < 20)
361+
else if (fDistance < 20)
364362
pSound->DistanceStreamIn();
365363
}
366364
}

0 commit comments

Comments
 (0)