mathlib: make vector math macros more robust

Wrap the vector macros that don't return a value in do {} while (0)
and fix a couple of missing semicolons detected in the process.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2012-11-27 11:03:16 +10:30
parent 60d7c9af44
commit e7839fa7db
3 changed files with 6 additions and 6 deletions

View File

@ -762,8 +762,8 @@ CL_AddFlagModels(entity_t *ent, int team)
ent->origin[i] - f * v_forward[i] + 22 * v_right[i];
newent->origin[2] -= 16;
VectorCopy(ent->angles, newent->angles)
newent->angles[2] -= 45;
VectorCopy(ent->angles, newent->angles);
newent->angles[2] -= 45;
}
/*

View File

@ -764,7 +764,7 @@ SpectatorMove(void)
// friction
speed = Length(pmove.velocity);
if (speed < 1) {
VectorCopy(vec3_origin, pmove.velocity)
VectorCopy(vec3_origin, pmove.velocity);
} else {
drop = 0;

View File

@ -68,9 +68,9 @@ extern int nanmask;
})
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[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 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 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 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)
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb,
vec3_t vecc);