Add function for speed unit conversion to unit values

pull/279/head
Jonathan G Rennison 3 years ago
parent 8e27202524
commit f786b372c0

@ -798,6 +798,20 @@ uint ConvertSpeedToDisplaySpeed(uint speed)
return _units_velocity[_settings_game.locale.units_velocity].c.ToDisplay(speed, false);
}
/**
* Convert the given (internal) speed to the display speed, in units (not decimal values).
* @param speed the speed to convert
* @return the converted speed.
*/
uint ConvertSpeedToUnitDisplaySpeed(uint speed)
{
uint result = ConvertSpeedToDisplaySpeed(speed);
for (uint i = 0; i < _units_velocity[_settings_game.locale.units_velocity].decimal_places; i++) {
result /= 10;
}
return result;
}
/**
* Convert the given display speed to the (internal) speed.
* @param speed the speed to convert

@ -8,6 +8,7 @@
/** @file unit_conversion.h Functions related to unit conversion. */
uint ConvertSpeedToDisplaySpeed(uint speed);
uint ConvertSpeedToUnitDisplaySpeed(uint speed);
uint ConvertDisplaySpeedToSpeed(uint speed);
uint ConvertWeightToDisplayWeight(uint weight);
uint ConvertDisplayWeightToWeight(uint weight);

Loading…
Cancel
Save