summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-08-20 22:06:38 +0000
committerfrosch <frosch@openttd.org>2011-08-20 22:06:38 +0000
commit8d3d7b4e012b51fcd42a423ea7b8c52ba7cffe81 (patch)
treeef2501673d8d85eed22becedc558981956d84bf8 /src
parent7394bcb813c8f98afe4936254ac72402287c2aec (diff)
downloadopenttd-8d3d7b4e012b51fcd42a423ea7b8c52ba7cffe81.tar.xz
(svn r22776) -Codechange: Unify the naming of NewGRF string codes; always include the size of the parameter on the stack. (based on patch by Hirundo)
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_text.cpp68
-rw-r--r--src/strings.cpp4
-rw-r--r--src/table/control_codes.h44
3 files changed, 58 insertions, 58 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index 8900acc28..f08a62825 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -442,7 +442,7 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, const char *str, i
case 0x7D:
case 0x7E:
case 0x7F:
- case 0x80: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD + c - 0x7B); break;
+ case 0x80: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_SIGNED + c - 0x7B); break;
case 0x81: {
if (str[0] == '\0' || str[1] == '\0') goto string_end;
StringID string;
@@ -454,7 +454,7 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, const char *str, i
}
case 0x82:
case 0x83:
- case 0x84: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DATE_LONG + c - 0x82); break;
+ case 0x84: d += Utf8Encode(d, SCC_NEWGRF_PRINT_WORD_DATE_LONG + c - 0x82); break;
case 0x85: d += Utf8Encode(d, SCC_NEWGRF_DISCARD_WORD); break;
case 0x86: d += Utf8Encode(d, SCC_NEWGRF_ROTATE_TOP_4_WORDS); break;
case 0x87: d += Utf8Encode(d, SCC_NEWGRF_PRINT_WORD_VOLUME); break;
@@ -500,11 +500,11 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, const char *str, i
d += Utf8Encode(d, SCC_NEWGRF_UNPRINT);
d += Utf8Encode(d, *str++);
break;
- case 0x06: d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_BYTE); break;
- case 0x07: d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_WORD); break;
- case 0x08: d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_DWORD); break;
+ case 0x06: d += Utf8Encode(d, SCC_NEWGRF_PRINT_BYTE_HEX); break;
+ case 0x07: d += Utf8Encode(d, SCC_NEWGRF_PRINT_WORD_HEX); break;
+ case 0x08: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_HEX); break;
/* 0x09, 0x0A are TTDPatch internal use only string codes. */
- case 0x0B: d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_QWORD); break;
+ case 0x0B: d += Utf8Encode(d, SCC_NEWGRF_PRINT_QWORD_HEX); break;
case 0x0C: d += Utf8Encode(d, SCC_NEWGRF_PRINT_WORD_STATION_NAME); break;
case 0x0D: d += Utf8Encode(d, SCC_NEWGRF_PRINT_WORD_WEIGHT); break;
case 0x0E:
@@ -1009,34 +1009,34 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
if (_newgrf_textrefstack.used) {
switch (scc) {
default: NOT_REACHED();
- case SCC_NEWGRF_PRINT_SIGNED_BYTE: *argv = _newgrf_textrefstack.PopSignedByte(); break;
- case SCC_NEWGRF_PRINT_SIGNED_WORD: *argv = _newgrf_textrefstack.PopSignedWord(); break;
- case SCC_NEWGRF_PRINT_QWORD_CURRENCY: *argv = _newgrf_textrefstack.PopUnsignedQWord(); break;
+ case SCC_NEWGRF_PRINT_BYTE_SIGNED: *argv = _newgrf_textrefstack.PopSignedByte(); break;
+ case SCC_NEWGRF_PRINT_WORD_SIGNED: *argv = _newgrf_textrefstack.PopSignedWord(); break;
+ case SCC_NEWGRF_PRINT_QWORD_CURRENCY: *argv = _newgrf_textrefstack.PopUnsignedQWord(); break;
case SCC_NEWGRF_PRINT_DWORD_CURRENCY:
- case SCC_NEWGRF_PRINT_DWORD: *argv = _newgrf_textrefstack.PopSignedDWord(); break;
+ case SCC_NEWGRF_PRINT_DWORD_SIGNED: *argv = _newgrf_textrefstack.PopSignedDWord(); break;
- case SCC_NEWGRF_PRINT_HEX_BYTE: *argv = _newgrf_textrefstack.PopUnsignedByte(); break;
- case SCC_NEWGRF_PRINT_HEX_DWORD: *argv = _newgrf_textrefstack.PopUnsignedDWord(); break;
- case SCC_NEWGRF_PRINT_HEX_QWORD: *argv = _newgrf_textrefstack.PopSignedQWord(); break;
+ case SCC_NEWGRF_PRINT_BYTE_HEX: *argv = _newgrf_textrefstack.PopUnsignedByte(); break;
+ case SCC_NEWGRF_PRINT_DWORD_HEX: *argv = _newgrf_textrefstack.PopUnsignedDWord(); break;
+ case SCC_NEWGRF_PRINT_QWORD_HEX: *argv = _newgrf_textrefstack.PopSignedQWord(); break;
- case SCC_NEWGRF_PRINT_HEX_WORD:
+ case SCC_NEWGRF_PRINT_WORD_HEX:
case SCC_NEWGRF_PRINT_WORD_SPEED:
case SCC_NEWGRF_PRINT_WORD_VOLUME:
case SCC_NEWGRF_PRINT_WORD_WEIGHT:
case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
- case SCC_NEWGRF_PRINT_UNSIGNED_WORD: *argv = _newgrf_textrefstack.PopUnsignedWord(); break;
+ case SCC_NEWGRF_PRINT_WORD_UNSIGNED: *argv = _newgrf_textrefstack.PopUnsignedWord(); break;
- case SCC_NEWGRF_PRINT_DATE_LONG:
- case SCC_NEWGRF_PRINT_DATE_SHORT: *argv = _newgrf_textrefstack.PopUnsignedWord() + DAYS_TILL_ORIGINAL_BASE_YEAR; break;
+ case SCC_NEWGRF_PRINT_WORD_DATE_LONG:
+ case SCC_NEWGRF_PRINT_WORD_DATE_SHORT: *argv = _newgrf_textrefstack.PopUnsignedWord() + DAYS_TILL_ORIGINAL_BASE_YEAR; break;
- case SCC_NEWGRF_DISCARD_WORD: _newgrf_textrefstack.PopUnsignedWord(); break;
+ case SCC_NEWGRF_DISCARD_WORD: _newgrf_textrefstack.PopUnsignedWord(); break;
- case SCC_NEWGRF_ROTATE_TOP_4_WORDS: _newgrf_textrefstack.RotateTop4Words(); break;
- case SCC_NEWGRF_PUSH_WORD: _newgrf_textrefstack.PushWord(Utf8Consume(str)); break;
- case SCC_NEWGRF_UNPRINT: *buff = max(*buff - Utf8Consume(str), buf_start); break;
+ case SCC_NEWGRF_ROTATE_TOP_4_WORDS: _newgrf_textrefstack.RotateTop4Words(); break;
+ case SCC_NEWGRF_PUSH_WORD: _newgrf_textrefstack.PushWord(Utf8Consume(str)); break;
+ case SCC_NEWGRF_UNPRINT: *buff = max(*buff - Utf8Consume(str), buf_start); break;
- case SCC_NEWGRF_PRINT_STRING_ID:
+ case SCC_NEWGRF_PRINT_WORD_STRING_ID:
*argv = TTDPStringIDToOTTDStringIDMapping(_newgrf_textrefstack.PopUnsignedWord());
break;
}
@@ -1044,29 +1044,29 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
switch (scc) {
default: NOT_REACHED();
- case SCC_NEWGRF_PRINT_DWORD:
- case SCC_NEWGRF_PRINT_SIGNED_WORD:
- case SCC_NEWGRF_PRINT_SIGNED_BYTE:
- case SCC_NEWGRF_PRINT_UNSIGNED_WORD:
+ case SCC_NEWGRF_PRINT_DWORD_SIGNED:
+ case SCC_NEWGRF_PRINT_WORD_SIGNED:
+ case SCC_NEWGRF_PRINT_BYTE_SIGNED:
+ case SCC_NEWGRF_PRINT_WORD_UNSIGNED:
return SCC_COMMA;
- case SCC_NEWGRF_PRINT_HEX_BYTE:
- case SCC_NEWGRF_PRINT_HEX_WORD:
- case SCC_NEWGRF_PRINT_HEX_DWORD:
- case SCC_NEWGRF_PRINT_HEX_QWORD:
+ case SCC_NEWGRF_PRINT_BYTE_HEX:
+ case SCC_NEWGRF_PRINT_WORD_HEX:
+ case SCC_NEWGRF_PRINT_DWORD_HEX:
+ case SCC_NEWGRF_PRINT_QWORD_HEX:
return SCC_HEX;
case SCC_NEWGRF_PRINT_DWORD_CURRENCY:
case SCC_NEWGRF_PRINT_QWORD_CURRENCY:
return SCC_CURRENCY;
- case SCC_NEWGRF_PRINT_STRING_ID:
- return SCC_NEWGRF_PRINT_STRING_ID;
+ case SCC_NEWGRF_PRINT_WORD_STRING_ID:
+ return SCC_NEWGRF_PRINT_WORD_STRING_ID;
- case SCC_NEWGRF_PRINT_DATE_LONG:
+ case SCC_NEWGRF_PRINT_WORD_DATE_LONG:
return SCC_DATE_LONG;
- case SCC_NEWGRF_PRINT_DATE_SHORT:
+ case SCC_NEWGRF_PRINT_WORD_DATE_SHORT:
return SCC_DATE_SHORT;
case SCC_NEWGRF_PRINT_WORD_SPEED:
diff --git a/src/strings.cpp b/src/strings.cpp
index 1be6855c5..09f2243c7 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -713,8 +713,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
break;
}
- case SCC_NEWGRF_PRINT_STRING_ID: {
- StringID substr = args->GetInt32(SCC_NEWGRF_PRINT_STRING_ID);
+ case SCC_NEWGRF_PRINT_WORD_STRING_ID: {
+ StringID substr = args->GetInt32(SCC_NEWGRF_PRINT_WORD_STRING_ID);
str_stack.push(GetStringPtr(substr));
break;
}
diff --git a/src/table/control_codes.h b/src/table/control_codes.h
index 2c7c9d00a..35e44f67b 100644
--- a/src/table/control_codes.h
+++ b/src/table/control_codes.h
@@ -112,30 +112,30 @@ enum StringControlCode {
* It uses a "stack" of bytes and reads from there.
*/
SCC_NEWGRF_FIRST,
- SCC_NEWGRF_PRINT_DWORD = SCC_NEWGRF_FIRST, ///< Read 4 bytes from the stack
- SCC_NEWGRF_PRINT_SIGNED_WORD, ///< Read 2 bytes from the stack as signed value
- SCC_NEWGRF_PRINT_SIGNED_BYTE, ///< Read 1 byte from the stack as signed value
- SCC_NEWGRF_PRINT_UNSIGNED_WORD, ///< Read 2 bytes from the stack as unsigned value
- SCC_NEWGRF_PRINT_DWORD_CURRENCY, ///< Read 4 bytes from the stack as currency
- SCC_NEWGRF_PRINT_STRING_ID, ///< Read 2 bytes from the stack as String ID
- SCC_NEWGRF_PRINT_DATE_LONG, ///< Read 2 bytes from the stack as base 1920 date
- SCC_NEWGRF_PRINT_DATE_SHORT, ///< Read 2 bytes from the stack as base 1920 date
- SCC_NEWGRF_PRINT_WORD_SPEED, ///< Read 2 bytes from the stack as signed speed
- SCC_NEWGRF_PRINT_WORD_VOLUME, ///< Read 2 bytes from the stack as signed volume
- SCC_NEWGRF_PRINT_WORD_WEIGHT, ///< Read 2 bytes from the stack as signed weight
- SCC_NEWGRF_PRINT_WORD_STATION_NAME, ///< Read 2 bytes from the stack as station name
- SCC_NEWGRF_PRINT_QWORD_CURRENCY, ///< Read 8 bytes from the stack as currency
- SCC_NEWGRF_PRINT_HEX_BYTE, ///< Read 1 byte from the stack and print it as hex
- SCC_NEWGRF_PRINT_HEX_WORD, ///< Read 2 bytes from the stack and print it as hex
- SCC_NEWGRF_PRINT_HEX_DWORD, ///< Read 4 bytes from the stack and print it as hex
- SCC_NEWGRF_PRINT_HEX_QWORD, ///< Read 8 bytes from the stack and print it as hex
- SCC_NEWGRF_PUSH_WORD, ///< Pushes 2 bytes onto the stack
- SCC_NEWGRF_UNPRINT, ///< "Unprints" the given number of bytes from the string
- SCC_NEWGRF_DISCARD_WORD, ///< Discard the next two bytes
- SCC_NEWGRF_ROTATE_TOP_4_WORDS, ///< Rotate the top 4 words of the stack (W4 W1 W2 W3)
+ SCC_NEWGRF_PRINT_DWORD_SIGNED = SCC_NEWGRF_FIRST, ///< Read 4 bytes from the stack
+ SCC_NEWGRF_PRINT_WORD_SIGNED, ///< Read 2 bytes from the stack as signed value
+ SCC_NEWGRF_PRINT_BYTE_SIGNED, ///< Read 1 byte from the stack as signed value
+ SCC_NEWGRF_PRINT_WORD_UNSIGNED, ///< Read 2 bytes from the stack as unsigned value
+ SCC_NEWGRF_PRINT_DWORD_CURRENCY, ///< Read 4 bytes from the stack as currency
+ SCC_NEWGRF_PRINT_WORD_STRING_ID, ///< Read 2 bytes from the stack as String ID
+ SCC_NEWGRF_PRINT_WORD_DATE_LONG, ///< Read 2 bytes from the stack as base 1920 date
+ SCC_NEWGRF_PRINT_WORD_DATE_SHORT, ///< Read 2 bytes from the stack as base 1920 date
+ SCC_NEWGRF_PRINT_WORD_SPEED, ///< Read 2 bytes from the stack as signed speed
+ SCC_NEWGRF_PRINT_WORD_VOLUME, ///< Read 2 bytes from the stack as signed volume
+ SCC_NEWGRF_PRINT_WORD_WEIGHT, ///< Read 2 bytes from the stack as signed weight
+ SCC_NEWGRF_PRINT_WORD_STATION_NAME, ///< Read 2 bytes from the stack as station name
+ SCC_NEWGRF_PRINT_QWORD_CURRENCY, ///< Read 8 bytes from the stack as currency
+ SCC_NEWGRF_PRINT_BYTE_HEX, ///< Read 1 byte from the stack and print it as hex
+ SCC_NEWGRF_PRINT_WORD_HEX, ///< Read 2 bytes from the stack and print it as hex
+ SCC_NEWGRF_PRINT_DWORD_HEX, ///< Read 4 bytes from the stack and print it as hex
+ SCC_NEWGRF_PRINT_QWORD_HEX, ///< Read 8 bytes from the stack and print it as hex
+ SCC_NEWGRF_PUSH_WORD, ///< Pushes 2 bytes onto the stack
+ SCC_NEWGRF_UNPRINT, ///< "Unprints" the given number of bytes from the string
+ SCC_NEWGRF_DISCARD_WORD, ///< Discard the next two bytes
+ SCC_NEWGRF_ROTATE_TOP_4_WORDS, ///< Rotate the top 4 words of the stack (W4 W1 W2 W3)
SCC_NEWGRF_LAST = SCC_NEWGRF_ROTATE_TOP_4_WORDS,
- SCC_NEWGRF_STRINL, ///< Inline another string at the current position, StringID is encoded in the string
+ SCC_NEWGRF_STRINL, ///< Inline another string at the current position, StringID is encoded in the string
/* Special printable symbols.
* These are mapped to the original glyphs */