diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-08-15 12:14:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-15 12:14:53 +0200 |
commit | ee333a954934fee206a65795670d15150178c0f3 (patch) | |
tree | 163cc9ccfe6b3929c72987070be7c8a2a415382e /src/newgrf_engine.cpp | |
parent | 2183fd4dabe72bd96b264bf8cdb3a2a8be625cf8 (diff) | |
download | openttd-ee333a954934fee206a65795670d15150178c0f3.tar.xz |
Fix 2183fd4d: [NewGRF] Use divide instead of right shift for signed numbers. (#9480)
"For negative a, the value of a >> b is implementation-defined (in most implementations, this performs arithmetic right shift, so that the result remains negative)."
Diffstat (limited to 'src/newgrf_engine.cpp')
-rw-r--r-- | src/newgrf_engine.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index e57410224..ee4af5e6a 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -1189,7 +1189,7 @@ int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, cons if (callback != CALLBACK_FAILED) { if (is_signed) { /* Sign extend 15 bit integer */ - return static_cast<int16>(callback << 1) >> 1; + return static_cast<int16>(callback << 1) / 2; } else { return callback; } |