OpenTTD
Public Member Functions | Data Fields
UnitConversion Struct Reference

Helper for unit conversion. More...

Public Member Functions

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

Data Fields

int multiplier
 Amount to multiply upon conversion.
int shift
 Amount to shift upon conversion.

Detailed Description

Helper for unit conversion.

Definition at line 637 of file strings.cpp.

Member Function Documentation

int64 UnitConversion::FromDisplay ( int64  input,
bool  round = true,
int64  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 659 of file strings.cpp.

References shift.

Referenced by ConvertDisplaySpeedToKmhishSpeed(), and ConvertDisplaySpeedToSpeed().

int64 UnitConversion::ToDisplay ( int64  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 647 of file strings.cpp.

References shift.

Referenced by ConvertKmhishSpeedToDisplaySpeed(), ConvertSpeedToDisplaySpeed(), and FormatString().


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