summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-21 15:57:14 +0000
committerrubidium <rubidium@openttd.org>2007-06-21 15:57:14 +0000
commit02154f38b8c5c2984fc86d534f8d6606a553ef0b (patch)
treec53b4cc3afeff70cb86f9c58e0b1f461dc1f9565 /src/strings.cpp
parent3fe19238b2b771839c6c3ec613778e2ca6274a79 (diff)
downloadopenttd-02154f38b8c5c2984fc86d534f8d6606a553ef0b.tar.xz
(svn r10252) -Fix: never overflow when applying exchange rates before drawing the amount of money.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 5ac7133c4..94c937e4f 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -340,15 +340,17 @@ static char *FormatTinyDate(char *buff, Date date, const char* last)
return FormatString(buff, GetStringPtr(STR_DATE_TINY), args, 0, last);
}
-static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, int64 number, bool compact, const char* last)
+static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money number, bool compact, const char* last)
{
const char* multiplier = "";
char buf[40];
char* p;
int j;
- /* multiply by exchange rate */
- number *= spec->rate;
+ /* Multiply by exchange rate, but do it safely. */
+ CommandCost cs(number);
+ cs.MultiplyCost(spec->rate);
+ number = cs.GetCost();
/* convert from negative */
if (number < 0) {