diff options
author | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2006-01-19 17:25:55 +0000 |
---|---|---|
committer | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2006-01-19 17:25:55 +0000 |
commit | 687a36439b76ce20b9876809698de73754ecd7fa (patch) | |
tree | c0b7386b00e59493543e19b0c8dd28d552d39f3a /code | |
parent | 0e6e3a7d97d41edc74f6460076839d0c863dd97f (diff) | |
download | ioquake3-aero-687a36439b76ce20b9876809698de73754ecd7fa.tar.gz ioquake3-aero-687a36439b76ce20b9876809698de73754ecd7fa.zip |
* Some sloppily coded mods call the Q3 sound API with NaNs -- sanitise this
git-svn-id: svn://svn.icculus.org/quake3/trunk@508 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r-- | code/client/snd_openal.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index 7fe418f..6923186 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -486,6 +486,25 @@ static sentity_t entityList[MAX_GENTITIES]; /* ================= +S_AL_SanitiseVector +================= +*/ +#define S_AL_SanitiseVector(v) _S_AL_SanitiseVector(v,__LINE__) +static void _S_AL_SanitiseVector( vec3_t v, int line ) +{ + // NaNs can't be compared for equality, thus always fail this test + if( v[ 0 ] == v[ 0 ] && + v[ 1 ] == v[ 1 ] && + v[ 2 ] == v[ 2 ] ) + return; + + Com_DPrintf( S_COLOR_YELLOW "WARNING: vector with one or more NaN components " + "being passed to OpenAL at %s:%d -- zeroing\n", __FILE__, line ); + VectorClear( v ); +} + +/* +================= S_AL_SrcInit ================= */ @@ -761,6 +780,7 @@ S_AL_UpdateEntityPosition static void S_AL_UpdateEntityPosition( int entityNum, const vec3_t origin ) { + S_AL_SanitiseVector( (vec_t *)origin ); if ( entityNum < 0 || entityNum > MAX_GENTITIES ) Com_Error( ERR_DROP, "S_UpdateEntityPosition: bad entitynum %i", entityNum ); VectorCopy( origin, entityList[entityNum].origin ); @@ -815,6 +835,7 @@ void S_AL_StartSound( vec3_t origin, int entnum, int entchannel, sfxHandle_t sfx } else VectorCopy( origin, sorigin ); + S_AL_SanitiseVector( sorigin ); qalSourcefv(srcList[src].alSource, AL_POSITION, sorigin); // Start it playing @@ -895,6 +916,8 @@ S_AL_AddLoopingSound static void S_AL_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) { + S_AL_SanitiseVector( (vec_t *)origin ); + S_AL_SanitiseVector( (vec_t *)velocity ); S_AL_SrcLoop(SRCPRI_AMBIENT, sfx, origin, velocity, entityNum); } @@ -906,6 +929,8 @@ S_AL_AddRealLoopingSound static void S_AL_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) { + S_AL_SanitiseVector( (vec_t *)origin ); + S_AL_SanitiseVector( (vec_t *)velocity ); S_AL_SrcLoop(SRCPRI_ENTITY, sfx, origin, velocity, entityNum); } @@ -1428,6 +1453,10 @@ S_AL_Respatialize static void S_AL_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater ) { + S_AL_SanitiseVector( (vec_t *)origin ); + S_AL_SanitiseVector( axis[ 0 ] ); + S_AL_SanitiseVector( axis[ 1 ] ); + S_AL_SanitiseVector( axis[ 2 ] ); // Axis[0] = Forward // Axis[2] = Up float velocity[] = {0.0f, 0.0f, 0.0f}; |