summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-11-07 22:41:50 +0000
committertruelight <truelight@openttd.org>2007-11-07 22:41:50 +0000
commit87295922cf8b1023bda47b3da5876c04d96da042 (patch)
tree5c167b8e64b06eb8b463738827372ce597a354ed /src
parent4e518e3cebdbcdf06a9b027d378b41c4aa79d8f6 (diff)
downloadopenttd-87295922cf8b1023bda47b3da5876c04d96da042.tar.xz
(svn r11390) -Fix r11387: AB() was wrong (spotted by Rafal Rzepecki, patch by skidd13)
Diffstat (limited to 'src')
-rw-r--r--src/macros.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/macros.h b/src/macros.h
index 2f5a9b48f..004e4039d 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -66,9 +66,8 @@ template<typename T, typename U> static inline T SB(T& x, const uint8 s, const u
*/
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;
}