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
commitfeb15bb4216cf1e51c0b67b7eb1eac6c536d4ec9 (patch)
tree6bb9bd6e268d2b6609498af869e15e7a681ceff2 /src/strings.cpp
parentefe93c527b4683d6aec2bfc688db5cef8b68ed61 (diff)
downloadopenttd-feb15bb4216cf1e51c0b67b7eb1eac6c536d4ec9.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;