Mercurial > hg > openttd
changeset 6996:27cc72475f39 draft
(svn r10252) -Fix: never overflow when applying exchange rates before drawing the amount of money.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 21 Jun 2007 15:57:14 +0000 (2007-06-21) |
parents | 82cc23750a0f |
children | fa5196b1b53d |
files | src/strings.cpp |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/strings.cpp +++ b/src/strings.cpp @@ -340,15 +340,17 @@ 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) {