|
@@ -328,21 +328,21 @@ static char *FormatTinyDate(char *buff,
|
|
|
int64 args[3] = { BindCString(day), BindCString(month), ymd.year };
|
|
|
return FormatString(buff, GetStringPtr(STR_DATE_TINY), args, 0, last);
|
|
|
}
|
|
|
|
|
|
static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money number, bool compact, const char* last)
|
|
|
{
|
|
|
const char* multiplier = "";
|
|
|
/* We are going to make number absolute for printing, so
|
|
|
* keep this piece of data as we need it later on */
|
|
|
bool negative = number < 0;
|
|
|
const char *multiplier = "";
|
|
|
char buf[40];
|
|
|
char* p;
|
|
|
char *p;
|
|
|
int j;
|
|
|
|
|
|
/* Multiply by exchange rate, but do it safely. */
|
|
|
CommandCost cs(number);
|
|
|
cs.MultiplyCost(spec->rate);
|
|
|
number = cs.GetCost();
|
|
|
number *= spec->rate;
|
|
|
|
|
|
/* convert from negative */
|
|
|
if (number < 0) {
|
|
|
if (buff + Utf8CharLen(SCC_RED) > last) return buff;
|
|
|
buff += Utf8Encode(buff, SCC_RED);
|
|
|
buff = strecpy(buff, "-", last);
|
|
@@ -371,24 +371,24 @@ static char *FormatGenericCurrency(char
|
|
|
j = 4;
|
|
|
do {
|
|
|
if (--j == 0) {
|
|
|
*--p = spec->separator;
|
|
|
j = 3;
|
|
|
}
|
|
|
*--p = '0' + number % 10;
|
|
|
*--p = '0' + (char)(number % 10);
|
|
|
} while ((number /= 10) != 0);
|
|
|
buff = strecpy(buff, p, last);
|
|
|
|
|
|
buff = strecpy(buff, multiplier, last);
|
|
|
|
|
|
/* Add suffix part, folowing symbol_pos specification.
|
|
|
* Here, it can can be either 1 (suffix) or 2 (both prefix anf suffix).
|
|
|
* The only remaining value is 1 (prefix), so everything that is not 0 */
|
|
|
if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last);
|
|
|
|
|
|
if (cs.GetCost() < 0) {
|
|
|
if (negative) {
|
|
|
if (buff + Utf8CharLen(SCC_PREVIOUS_COLOUR) > last) return buff;
|
|
|
buff += Utf8Encode(buff, SCC_PREVIOUS_COLOUR);
|
|
|
*buff = '\0';
|
|
|
}
|
|
|
|
|
|
return buff;
|