From ff5b215c13b060fd3bc1cebcf47817571f4ed23b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 16 Mar 2004 04:15:07 +0000 Subject: [PATCH] multi statement macro fixes as pointed out by Grievre --- include/QF/mathlib.h | 20 ++++++++++---------- include/QF/progs.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/QF/mathlib.h b/include/QF/mathlib.h index bb17d62ac..de0fcaa15 100644 --- a/include/QF/mathlib.h +++ b/include/QF/mathlib.h @@ -45,27 +45,27 @@ extern const vec_t * const vec3_origin; #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) #define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2]) -#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} -#define VectorNegate(a,b) {(b)[0]=-(a)[0];(b)[1]=-(a)[1];(b)[2]=-(a)[2];} -#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} -#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} -#define VectorMult(a,b,c) {(c)[0]=(a)[0]*(b)[0];(c)[1]=(a)[1]*(b)[1];(c)[2]=(a)[2]*(b)[2];} -#define VectorMultAdd(a,s,b,c) {(c)[0]=(a)[0]+(s)*(b)[0];(c)[1]=(a)[1]+(s)*(b)[1];(c)[2]=(a)[2]+(s)*(b)[2];} -#define VectorMultSub(a,s,b,c) {(c)[0]=(a)[0]-(s)*(b)[0];(c)[1]=(a)[1]-(s)*(b)[1];(c)[2]=(a)[2]-(s)*(b)[2];} +#define VectorSubtract(a,b,c) do {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} while (0) +#define VectorNegate(a,b) do {(b)[0]=-(a)[0];(b)[1]=-(a)[1];(b)[2]=-(a)[2];} while (0) +#define VectorAdd(a,b,c) do {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} while (0) +#define VectorCopy(a,b) do {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} while (0) +#define VectorMult(a,b,c) do {(c)[0]=(a)[0]*(b)[0];(c)[1]=(a)[1]*(b)[1];(c)[2]=(a)[2]*(b)[2];} while (0) +#define VectorMultAdd(a,s,b,c) do {(c)[0]=(a)[0]+(s)*(b)[0];(c)[1]=(a)[1]+(s)*(b)[1];(c)[2]=(a)[2]+(s)*(b)[2];} while (0) +#define VectorMultSub(a,s,b,c) do {(c)[0]=(a)[0]-(s)*(b)[0];(c)[1]=(a)[1]-(s)*(b)[1];(c)[2]=(a)[2]-(s)*(b)[2];} while (0) #define VectorLength(a) sqrt(DotProduct(a, a)) -#define VectorScale(a,b,c) {(c)[0]=(a)[0]*(b);(c)[1]=(a)[1]*(b);(c)[2]=(a)[2]*(b);} +#define VectorScale(a,b,c) do {(c)[0]=(a)[0]*(b);(c)[1]=(a)[1]*(b);(c)[2]=(a)[2]*(b);} while (0) #define VectorCompare(x, y) (((x)[0] == (y)[0]) && ((x)[1] == (y)[1]) && ((x)[2] == (y)[2])) #define VectorIsZero(a) ((a)[0] == 0 && (a)[1] == 0 && (a)[2] == 0) #define VectorZero(a) ((a)[2] = (a)[1] = (a)[0] = 0); #define VectorBlend(v1,v2,b,v) \ - { \ + do { \ (v)[0] = (v1)[0] * (1 - (b)) + (v2)[0] * (b); \ (v)[1] = (v1)[1] * (1 - (b)) + (v2)[1] * (b); \ (v)[2] = (v1)[2] * (1 - (b)) + (v2)[2] * (b); \ - } + } while (0) /* * VectorDistance, the distance between two points. diff --git a/include/QF/progs.h b/include/QF/progs.h index 3f545af7b..420695db3 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -163,7 +163,7 @@ qboolean PR_EdictValid (progs_t *pr, int e); #define RETURN_STRING(p, s) (R_STRING (p) = PR_SetReturnString((p), s)) #define RETURN_EDICT(p, e) (R_STRING (p) = EDICT_TO_PROG(p, e)) #define RETURN_POINTER(pr,p) (R_POINTER (pr) = POINTER_TO_PROG (pr, p)) -#define RETURN_VECTOR(p, v) (VectorCopy (v, R_VECTOR (p))) +#define RETURN_VECTOR(p, v) VectorCopy (v, R_VECTOR (p)) #define E_var(e,o,t) ((e)->v[o].t##_var)