Fix input/display of speeds in tracerestrict window in tiles/day mode

pull/362/head
Jonathan G Rennison 2 years ago
parent a64a6aeeb8
commit 644bd0a325

@ -1394,6 +1394,7 @@ static void ClimateThresholdModeChanged(int32 new_value)
static void VelocityUnitsChanged(int32 new_value) { static void VelocityUnitsChanged(int32 new_value) {
InvalidateWindowClassesData(WC_PAYMENT_RATES); InvalidateWindowClassesData(WC_PAYMENT_RATES);
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }

@ -845,13 +845,15 @@ static bool IsIntegerValueType(TraceRestrictValueType type)
{ {
switch (type) { switch (type) {
case TRVT_INT: case TRVT_INT:
case TRVT_SPEED:
case TRVT_WEIGHT: case TRVT_WEIGHT:
case TRVT_POWER: case TRVT_POWER:
case TRVT_FORCE: case TRVT_FORCE:
case TRVT_PERCENT: case TRVT_PERCENT:
return true; return true;
case TRVT_SPEED:
return _settings_game.locale.units_velocity != 3;
default: default:
return false; return false;
} }
@ -867,6 +869,9 @@ static bool IsDecimalValueType(TraceRestrictValueType type)
case TRVT_FORCE_WEIGHT_RATIO: case TRVT_FORCE_WEIGHT_RATIO:
return true; return true;
case TRVT_SPEED:
return _settings_game.locale.units_velocity == 3;
default: default:
return false; return false;
} }
@ -931,6 +936,11 @@ static void ConvertValueToDecimal(TraceRestrictValueType type, uint in, int64 &v
ConvertForceWeightRatioToDisplay(in, value, decimal); ConvertForceWeightRatioToDisplay(in, value, decimal);
break; break;
case TRVT_SPEED:
decimal = _settings_game.locale.units_velocity == 3 ? 1 : 0;
value = ConvertKmhishSpeedToDisplaySpeed(in);
break;
default: default:
NOT_REACHED(); NOT_REACHED();
} }
@ -944,11 +954,12 @@ static uint ConvertDecimalToValue(TraceRestrictValueType type, double in)
switch (type) { switch (type) {
case TRVT_POWER_WEIGHT_RATIO: case TRVT_POWER_WEIGHT_RATIO:
return ConvertDisplayToPowerWeightRatio(in); return ConvertDisplayToPowerWeightRatio(in);
break;
case TRVT_FORCE_WEIGHT_RATIO: case TRVT_FORCE_WEIGHT_RATIO:
return ConvertDisplayToForceWeightRatio(in); return ConvertDisplayToForceWeightRatio(in);
break;
case TRVT_SPEED:
return ConvertDisplaySpeedToKmhishSpeed(in * (_settings_game.locale.units_velocity == 3 ? 10 : 1));
default: default:
NOT_REACHED(); NOT_REACHED();

Loading…
Cancel
Save