changeset 7840:3bf07f5b9bc4 draft

(svn r11390) -Fix r11387: AB() was wrong (spotted by Rafal Rzepecki, patch by skidd13)
author truelight <truelight@openttd.org>
date Wed, 07 Nov 2007 22:41:50 +0000
parents dc96989488d7
children 076cd8a1d64c
files src/macros.h
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/macros.h
+++ b/src/macros.h
@@ -66,9 +66,8 @@
  */
 template<typename T, typename U> static inline T AB(T& x, const uint8 s, const uint8 n, const U i)
 {
-	const T tmp = (T)(((1U << n) - 1) << s);
-	x &= ~tmp;
-	x |= (T)((x + (i << s)) & tmp);
+	const T mask = (T)(((1U << n) - 1) << s);
+	x = (T)((x & ~mask) | ((x + (i << s)) & mask));
 	return x;
 }