From abf416a5a9615d83f2762f104f49ff9d997d5309 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 20 Apr 2019 18:37:50 +0200 Subject: [PATCH] Fix string_to_money rounding errors in 4.10, 5.10... --- src/openrct2/localisation/Localisation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/localisation/Localisation.cpp b/src/openrct2/localisation/Localisation.cpp index 99ae0930be..fcaf9b28a6 100644 --- a/src/openrct2/localisation/Localisation.cpp +++ b/src/openrct2/localisation/Localisation.cpp @@ -34,6 +34,7 @@ #include #include #include +#include char gCommonStringFormatBuffer[512]; uint8_t gCommonFormatArgs[80]; @@ -1513,7 +1514,7 @@ money32 string_to_money(const char* string_to_monetise) auto number = std::stod(processedString, nullptr); number /= (currencyDesc->rate / 10.0); auto whole = static_cast(number); - auto fraction = static_cast((number - whole) * 100); + auto fraction = static_cast(ceil((number - whole) * 100.0)); money32 result = MONEY(whole, fraction); // Check if MONEY resulted in overflow