Fix: [NewGRF] Make VA2 operator 11 (ror) behave well-defined when rotating by 0 bits.

This commit is contained in:
frosch
2018-10-31 13:07:51 +01:00
committed by Niels Martin Hansen
parent b3dc90af58
commit 18ca3e8660
2 changed files with 3 additions and 17 deletions

View File

@@ -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));
}