Implement a type-checking clamp macro

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2012-10-23 14:27:57 +10:30
parent 25b7b14943
commit d2c2c6059c
2 changed files with 5 additions and 2 deletions

View File

@ -279,8 +279,8 @@ R_TranslatePlayerSkin(int playernum)
top = player->topcolor;
bottom = player->bottomcolor;
top = (top < 0) ? 0 : ((top > 13) ? 13 : top);
bottom = (bottom < 0) ? 0 : ((bottom > 13) ? 13 : bottom);
top = qclamp(top, 0, 13);
bottom = qclamp(bottom, 0, 13);
top *= 16;
bottom *= 16;

View File

@ -45,6 +45,9 @@ typedef int fixed16_t;
(a_ < b_) ? a_ : b_; \
})
/* clamp macro with type checking */
#define qclamp(var,min,max) qmax(qmin(var,max),min)
#ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif