diff options
author | frosch <frosch@openttd.org> | 2014-01-12 18:01:33 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2014-01-12 18:01:33 +0000 |
commit | e9c22ef16fd7043707eaee96991cb2e94b597449 (patch) | |
tree | 235fea6ae3d3ec7be71614c3c749c38d01d35d23 | |
parent | 00e7ceeca4ffa42c3837462c6444d1a7d5201a96 (diff) | |
download | openttd-e9c22ef16fd7043707eaee96991cb2e94b597449.tar.xz |
(svn r26244) -Feature: [NewGRF] Add StringCodes 9A 1B, 9A 1C and 9A 1D to display amounts of cargo.
-rw-r--r-- | src/newgrf_text.cpp | 33 | ||||
-rw-r--r-- | src/table/control_codes.h | 3 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index b14a26bbd..439a8d57f 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -22,6 +22,7 @@ #include "strings_func.h" #include "newgrf_storage.h" #include "newgrf_text.h" +#include "newgrf_cargo.h" #include "string_func.h" #include "date_type.h" #include "debug.h" @@ -520,7 +521,12 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newline case 0x17: case 0x18: case 0x19: - case 0x1A: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16); break; + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16); + break; default: grfmsg(1, "missing handler for extended format code"); @@ -993,6 +999,15 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const return 0; } break; + + case SCC_NEWGRF_PRINT_WORD_CARGO_LONG: + case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT: + case SCC_NEWGRF_PRINT_WORD_CARGO_TINY: + if (argv_size < 2) { + DEBUG(misc, 0, "Too many NewGRF string parameters."); + return 0; + } + break; } if (_newgrf_textrefstack.used && modify_argv) { @@ -1032,6 +1047,13 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const 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_WORD_CARGO_LONG: + case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT: + case SCC_NEWGRF_PRINT_WORD_CARGO_TINY: + argv[0] = GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile); + argv[1] = _newgrf_textrefstack.PopUnsignedWord(); + break; + case SCC_NEWGRF_PRINT_WORD_STRING_ID: *argv = MapGRFStringID(_newgrf_textrefstack.grffile->grfid, _newgrf_textrefstack.PopUnsignedWord()); break; @@ -1085,6 +1107,15 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const case SCC_NEWGRF_PRINT_WORD_POWER: return SCC_POWER; + case SCC_NEWGRF_PRINT_WORD_CARGO_LONG: + return SCC_CARGO_LONG; + + case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT: + return SCC_CARGO_SHORT; + + case SCC_NEWGRF_PRINT_WORD_CARGO_TINY: + return SCC_CARGO_TINY; + case SCC_NEWGRF_PRINT_WORD_STATION_NAME: return SCC_STATION_NAME; diff --git a/src/table/control_codes.h b/src/table/control_codes.h index feb4c975f..81f9950d5 100644 --- a/src/table/control_codes.h +++ b/src/table/control_codes.h @@ -140,6 +140,9 @@ enum StringControlCode { SCC_NEWGRF_PRINT_WORD_POWER, ///< Read 2 bytes from the stack as unsigned power SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT, ///< Read 2 bytes from the stack as short signed volume SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT, ///< Read 2 bytes from the stack as short unsigned weight + SCC_NEWGRF_PRINT_WORD_CARGO_LONG, ///< Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount + SCC_NEWGRF_PRINT_WORD_CARGO_SHORT, ///< Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount + SCC_NEWGRF_PRINT_WORD_CARGO_TINY, ///< Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount 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 |