1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-12 09:09:09 +00:00

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)."
This commit is contained in:
Michael Lutz
2021-08-15 12:14:53 +02:00
committed by GitHub
parent 2183fd4dab
commit ee333a9549
2 changed files with 2 additions and 2 deletions

View File

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