From e298f8389b452890c1b7306fdfe073a23fdd71a7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 3 May 2016 21:05:13 -0700 Subject: [PATCH] Avoid divide-by-0 when the area sound radius is less than the max distance --- src/sound/oalsound.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 8303324d1..71f021416 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -1431,7 +1431,8 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener /* Since the OpenAL distance is decoupled from the sound's distance, get the OpenAL * distance that corresponds to the area radius. */ alSourcef(source, AL_SOURCE_RADIUS, (chanflags&SNDF_AREA) ? - 1.f / GetRolloff(rolloff, AREA_SOUND_RADIUS) : 0.f + // Clamp in case the max distance is <= the area radius + 1.f/MAX(GetRolloff(rolloff, AREA_SOUND_RADIUS), 0.00001f) : 0.f ); } else if((chanflags&SNDF_AREA) && dist_sqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS)