summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-06-03 15:14:41 +0000
committerpeter1138 <peter1138@openttd.org>2006-06-03 15:14:41 +0000
commit4565989d54f2a51886605906fa4f6b14f5b3deee (patch)
treef50debae50a66b488c1454debdc6f300a9e61653
parent59d5ed821f814b3693a05b7f8ea61f449db4c54a (diff)
downloadopenttd-4565989d54f2a51886605906fa4f6b14f5b3deee.tar.xz
(svn r5085) - Fix (FS#198): add parentheses to CHANCE16*() (and GENERAL_SPRITE_COLOR) macro parameters (thanks to ASM)
-rw-r--r--macros.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/macros.h b/macros.h
index ff0fe8936..0ef35cc75 100644
--- a/macros.h
+++ b/macros.h
@@ -73,7 +73,7 @@ static inline int64 BIGMULS(int32 a, int32 b) {
#define SETBITS(x,y) ((x) |= (y))
#define CLRBITS(x,y) ((x) &= ~(y))
-#define GENERAL_SPRITE_COLOR(color) ( (color + PALETTE_RECOLOR_START) << PALETTE_SPRITE_START)
+#define GENERAL_SPRITE_COLOR(color) ( ((color) + PALETTE_RECOLOR_START) << PALETTE_SPRITE_START)
#define PLAYER_SPRITE_COLOR(owner) ( GENERAL_SPRITE_COLOR(_player_colors[owner]))
#define SPRITE_PALETTE(x) ((x) | PALETTE_MODIFIER_COLOR)
@@ -125,9 +125,9 @@ static inline int KillFirstBit2x64(int value)
#define IS_INT_INSIDE(a,min,max) ((uint)((a)-(min)) < (uint)((max)-(min)))
-#define CHANCE16(a,b) ((uint16)Random() <= (uint16)((65536 * a) / b))
-#define CHANCE16R(a,b,r) ((uint16)(r=Random()) <= (uint16)((65536 * a) / b))
-#define CHANCE16I(a,b,v) ((uint16)(v) <= (uint16)((65536 * a) / b))
+#define CHANCE16(a,b) ((uint16)Random() <= (uint16)((65536 * (a)) / (b)))
+#define CHANCE16R(a,b,r) ((uint16)(r=Random()) <= (uint16)((65536 * a) / (b)))
+#define CHANCE16I(a,b,v) ((uint16)(v) <= (uint16)((65536 * (a)) / (b)))
#define for_each_bit(_i, _b) \