diff options
author | frosch <frosch@openttd.org> | 2018-10-31 13:07:51 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2018-10-31 14:35:46 +0100 |
commit | 18ca3e8660f90737d672b6780301ff4b998df56f (patch) | |
tree | facb4aeaa2480f19938a253887b899c1c8332a2b /src/core | |
parent | b3dc90af58474e08971c9c70e0cd62bd1ed4dd88 (diff) | |
download | openttd-18ca3e8660f90737d672b6780301ff4b998df56f.tar.xz |
Fix: [NewGRF] Make VA2 operator 11 (ror) behave well-defined when rotating by 0 bits.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/bitmath_func.hpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index 31e679b00..fd05aa3f5 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -302,6 +302,7 @@ static inline bool HasAtMostOneBit(T value) template <typename T> static inline T ROL(const T x, const uint8 n) { + if (n == 0) return x; return (T)(x << n | x >> (sizeof(x) * 8 - n)); } @@ -317,6 +318,7 @@ static inline T ROL(const T x, const uint8 n) template <typename T> static inline T ROR(const T x, const uint8 n) { + if (n == 0) return x; return (T)(x >> n | x << (sizeof(x) * 8 - n)); } |