diff --git a/src/settings.cpp b/src/settings.cpp index 014574f502..ff9a2e257d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1394,6 +1394,7 @@ static void ClimateThresholdModeChanged(int32 new_value) static void VelocityUnitsChanged(int32 new_value) { InvalidateWindowClassesData(WC_PAYMENT_RATES); + InvalidateWindowClassesData(WC_TRACE_RESTRICT); MarkWholeScreenDirty(); } diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 49407961c7..e6818a420e 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -845,13 +845,15 @@ static bool IsIntegerValueType(TraceRestrictValueType type) { switch (type) { case TRVT_INT: - case TRVT_SPEED: case TRVT_WEIGHT: case TRVT_POWER: case TRVT_FORCE: case TRVT_PERCENT: return true; + case TRVT_SPEED: + return _settings_game.locale.units_velocity != 3; + default: return false; } @@ -867,6 +869,9 @@ static bool IsDecimalValueType(TraceRestrictValueType type) case TRVT_FORCE_WEIGHT_RATIO: return true; + case TRVT_SPEED: + return _settings_game.locale.units_velocity == 3; + default: return false; } @@ -931,6 +936,11 @@ static void ConvertValueToDecimal(TraceRestrictValueType type, uint in, int64 &v ConvertForceWeightRatioToDisplay(in, value, decimal); break; + case TRVT_SPEED: + decimal = _settings_game.locale.units_velocity == 3 ? 1 : 0; + value = ConvertKmhishSpeedToDisplaySpeed(in); + break; + default: NOT_REACHED(); } @@ -944,11 +954,12 @@ static uint ConvertDecimalToValue(TraceRestrictValueType type, double in) switch (type) { case TRVT_POWER_WEIGHT_RATIO: return ConvertDisplayToPowerWeightRatio(in); - break; case TRVT_FORCE_WEIGHT_RATIO: return ConvertDisplayToForceWeightRatio(in); - break; + + case TRVT_SPEED: + return ConvertDisplaySpeedToKmhishSpeed(in * (_settings_game.locale.units_velocity == 3 ? 10 : 1)); default: NOT_REACHED();