From ee333a954934fee206a65795670d15150178c0f3 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 15 Aug 2021 12:14:53 +0200 Subject: 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)." --- src/train_cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/train_cmd.cpp') diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 1498a5fad..f926be637 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -363,7 +363,7 @@ int Train::GetCurveSpeedLimit() const /* Apply max_speed modifier (cached value is fixed-point binary with 8 fractional bits) * and clamp the result to an acceptable range. */ - max_speed += (max_speed * this->tcache.cached_curve_speed_mod) >> 8; + max_speed += (max_speed * this->tcache.cached_curve_speed_mod) / 256; max_speed = Clamp(max_speed, 2, absolute_max_speed); } -- cgit v1.2.3-54-g00ecf