r508 - trunk/code/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jan 19 12:25:55 EST 2006


Author: tma
Date: 2006-01-19 12:25:55 -0500 (Thu, 19 Jan 2006)
New Revision: 508

Modified:
   trunk/code/client/snd_openal.c
Log:
* Some sloppily coded mods call the Q3 sound API with NaNs -- sanitise this


Modified: trunk/code/client/snd_openal.c
===================================================================
--- trunk/code/client/snd_openal.c	2006-01-19 16:43:06 UTC (rev 507)
+++ trunk/code/client/snd_openal.c	2006-01-19 17:25:55 UTC (rev 508)
@@ -486,6 +486,25 @@
 
 /*
 =================
+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 @@
 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 @@
 	}
 	else
 		VectorCopy( origin, sorigin );
+	S_AL_SanitiseVector( sorigin );
 	qalSourcefv(srcList[src].alSource, AL_POSITION, sorigin);
 
 	// Start it playing
@@ -895,6 +916,8 @@
 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 @@
 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 @@
 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};




More information about the quake3-commits mailing list