OpenTTD Source  20240917-master-g9ab0a47812
UnitConversion Struct Reference

Helper for unit conversion. More...

Public Member Functions

int64_t ToDisplay (int64_t input, bool round=true) const
 Convert value from OpenTTD's internal unit into the displayed value. More...
 
int64_t FromDisplay (int64_t input, bool round=true, int64_t divider=1) const
 Convert the displayed value back into a value of OpenTTD's internal unit. More...
 

Data Fields

double factor
 Amount to multiply or divide upon conversion.
 

Detailed Description

Helper for unit conversion.

Definition at line 698 of file strings.cpp.

Member Function Documentation

◆ FromDisplay()

int64_t UnitConversion::FromDisplay ( int64_t  input,
bool  round = true,
int64_t  divider = 1 
) const
inline

Convert the displayed value back into a value of OpenTTD's internal unit.

Parameters
inputThe input to convert.
roundWhether to round the value up or not.
dividerDivide the return value by this.
Returns
The converted value.

Definition at line 721 of file strings.cpp.

Referenced by ConvertDisplaySpeedToKmhishSpeed(), and ConvertDisplaySpeedToSpeed().

◆ ToDisplay()

int64_t UnitConversion::ToDisplay ( int64_t  input,
bool  round = true 
) const
inline

Convert value from OpenTTD's internal unit into the displayed value.

Parameters
inputThe input to convert.
roundWhether to round the value or not.
Returns
The converted value.

Definition at line 707 of file strings.cpp.

Referenced by ConvertKmhishSpeedToDisplaySpeed(), and ConvertSpeedToDisplaySpeed().


The documentation for this struct was generated from the following file: