mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-30 18:09:09 +00:00
"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:
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user