Changeset - r28799:00b47c66bc05
[Not reviewed]
master
0 1 0
Rubidium - 10 months ago 2024-02-21 17:36:21
rubidium@openttd.org
Fix #12148, fca8166: Do not draw decimals when number of digits is 0
1 file changed with 4 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/strings.cpp
Show inline comments
 
@@ -1198,12 +1198,16 @@ static void FormatString(StringBuilder &
 
					FormatNumber(builder, args.GetNextParameter<int64_t>(), _number_format_separators);
 
					break;
 

	
 
				case SCC_DECIMAL: { // {DECIMAL}
 
					int64_t number = args.GetNextParameter<int64_t>();
 
					int digits = args.GetNextParameter<int>();
 
					if (digits == 0) {
 
						FormatNumber(builder, number, _number_format_separators);
 
						break;
 
					}
 

	
 
					int64_t divisor = PowerOfTen(digits);
 
					int64_t fractional = number % divisor;
 
					number /= divisor;
 
					FormatNumber(builder, number, _number_format_separators);
 
					fmt::format_to(builder, "{}{:0{}d}", GetDecimalSeparator(), fractional, digits);
0 comments (0 inline, 0 general)