replace funky !!a ^ !!b XOR usage by a new boolxor(a, b) macro that does that interna...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 May 2007 16:26:59 +0000 (16:26 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 May 2007 16:26:59 +0000 (16:26 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7347 d7cf8633-e32d-0410-b094-e92efae38249

mathlib.h
snd_main.c

index 2b6201d..4516a27 100644 (file)
--- a/mathlib.h
+++ b/mathlib.h
@@ -60,6 +60,9 @@ extern vec3_t vec3_origin;
 // TOCHECK: what is this function supposed to do?
 #define bit2i(n) log2i((n) << 1)
 
+// boolean XOR (why doesn't C have the ^^ operator for this purpose?)
+#define boolxor(a,b) (!(a) != !(b))
+
 // returns the smallest integer greater than or equal to "value", or 0 if "value" is too big
 unsigned int CeilPowerOf2(unsigned int value);
 
index 4dec224..d71974a 100644 (file)
@@ -401,7 +401,7 @@ static void S_SetChannelLayout (void)
        listeners = snd_speakerlayout.listeners;
 
        // Swap the left and right channels if snd_swapstereo is set
-       if (!!snd_swapstereo.integer ^ !!v_flipped.integer)
+       if (boolxor(snd_swapstereo.integer, v_flipped.integer))
        {
                switch (snd_speakerlayout.channels)
                {
@@ -455,7 +455,7 @@ static void S_SetChannelLayout (void)
                                   (layout == SND_CHANNELLAYOUT_ALSA) ? "ALSA" : "standard");
        }
 
-       current_swapstereo = !!snd_swapstereo.integer ^ !!v_flipped.integer;
+       current_swapstereo = boolxor(snd_swapstereo.integer, v_flipped.integer);
        current_channellayout = snd_channellayout.integer;
        current_channellayout_used = layout;
 }
@@ -1525,7 +1525,7 @@ void S_Update(const matrix4x4_t *listenermatrix)
                return;
 
        // If snd_swapstereo or snd_channellayout has changed, recompute the channel layout
-       if (current_swapstereo != (!!snd_swapstereo.integer ^ !!v_flipped.integer) ||
+       if (current_swapstereo != boolxor(snd_swapstereo.integer, v_flipped.integer) ||
                current_channellayout != snd_channellayout.integer)
                S_SetChannelLayout();