From 20dc601ba8f48e68b167365ee40a5ded80e5149d Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 23 May 2007 16:26:59 +0000 Subject: [PATCH] replace funky !!a ^ !!b XOR usage by a new boolxor(a, b) macro that does that internally - should be more readable git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7347 d7cf8633-e32d-0410-b094-e92efae38249 --- mathlib.h | 3 +++ snd_main.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mathlib.h b/mathlib.h index 2b6201dc..4516a276 100644 --- 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); diff --git a/snd_main.c b/snd_main.c index 4dec2240..d71974a1 100644 --- a/snd_main.c +++ b/snd_main.c @@ -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(); -- 2.39.2