From 2c07386ccf8e96740d91a0d178e9ccbc4d413adc Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 9 Apr 2012 20:00:53 +0200 Subject: [PATCH] Added: Log warnings when setting excessively high max distances on sound sources --- code/nel/src/sound/driver/fmod/source_fmod.cpp | 7 +++++++ code/nel/src/sound/driver/openal/source_al.cpp | 8 ++++++++ code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp | 9 ++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/code/nel/src/sound/driver/fmod/source_fmod.cpp b/code/nel/src/sound/driver/fmod/source_fmod.cpp index 2ae9a0ea1..4ef2f89d5 100644 --- a/code/nel/src/sound/driver/fmod/source_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/source_fmod.cpp @@ -413,6 +413,13 @@ bool CSourceFMod::getSourceRelativeMode() const // ****************************************************************** void CSourceFMod::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */ ) { + static float maxSqrt = sqrt(std::numeric_limits::max()); + if (maxdist >= maxSqrt) + { + nlwarning("SOUND_DEV (FMod): Ridiculously high max distance set on source"); + maxdist = maxSqrt; + } + _MinDist= mindist; _MaxDist= maxdist; if(_FModChannel!=-1) diff --git a/code/nel/src/sound/driver/openal/source_al.cpp b/code/nel/src/sound/driver/openal/source_al.cpp index fe2dcb086..c207f0d31 100644 --- a/code/nel/src/sound/driver/openal/source_al.cpp +++ b/code/nel/src/sound/driver/openal/source_al.cpp @@ -500,6 +500,14 @@ bool CSourceAL::getSourceRelativeMode() const void CSourceAL::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */) { nlassert( (mindist >= 0.0f) && (maxdist >= 0.0f) ); + + static float maxSqrt = sqrt(std::numeric_limits::max()); + if (maxdist >= maxSqrt) + { + nlwarning("SOUND_DEV (OpenAL): Ridiculously high max distance set on source"); + maxdist = maxSqrt; + } + _MinDistance = mindist; _MaxDistance = maxdist; diff --git a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp index 9c34beaf8..df8101b40 100644 --- a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp @@ -793,7 +793,14 @@ bool CSourceXAudio2::getSourceRelativeMode() const void CSourceXAudio2::setMinMaxDistances(float mindist, float maxdist, bool /* deferred */) { // nldebug(NLSOUND_XAUDIO2_PREFIX "setMinMaxDistances %f, %f", mindist, maxdist); - + + static float maxSqrt = sqrt(std::numeric_limits::max()); + if (maxdist >= maxSqrt) + { + nlwarning("SOUND_DEV (XAudio2): Ridiculously high max distance set on source"); + maxdist = maxSqrt; + } + _Emitter.InnerRadius = mindist; _MinDistance = mindist; _MaxDistance = maxdist;