summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 70e995ba2..ad902ead4 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -343,6 +343,8 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
/* convert from negative */
if (number < 0) {
+ if (buff + Utf8CharLen(SCC_RED) > last) return buff;
+ buff += Utf8Encode(buff, SCC_RED);
buff = strecpy(buff, "-", last);
number = -number;
}
@@ -383,6 +385,12 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
* 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 (buff + Utf8CharLen(SCC_PREVIOUS_COLOUR) > last) return buff;
+ buff += Utf8Encode(buff, SCC_PREVIOUS_COLOUR);
+ *buff = '\0';
+ }
+
return buff;
}