Add function for speed unit conversion to unit values
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user