summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-09-14 14:31:37 +0000
committerrubidium <rubidium@openttd.org>2008-09-14 14:31:37 +0000
commit6ce4fe40f7b17dcd7a76f0b2a88038726934cd71 (patch)
tree6bb9bd6e268d2b6609498af869e15e7a681ceff2 /src/strings.cpp
parent811193e46889850d4fef3454ed7301e017c6e4a6 (diff)
downloadopenttd-6ce4fe40f7b17dcd7a76f0b2a88038726934cd71.tar.xz
(svn r14321) -Add: support for newgrfs printing bytes/words/dwords as hexadecimals.
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 d8522be25..6e9665ad9 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -267,6 +267,10 @@ static char *FormatNoCommaNumber(char *buff, int64 number, const char *last)
return buff;
}
+static char *FormatHexNumber(char *buff, int64 number, const char *last)
+{
+ return buff + snprintf(buff, last - buff, "0x%x", (uint32)number);
+}
static char *FormatYmdString(char *buff, Date date, const char* last)
{
@@ -815,6 +819,10 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
buff = FormatNoCommaNumber(buff, GetInt64(&argv), last);
break;
+ case SCC_HEX: // {HEX}
+ buff = FormatHexNumber(buff, GetInt64(&argv), last);
+ break;
+
case SCC_CURRENCY: // {CURRENCY}
buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), false, last);
break;