mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r23063) -Add: [NewGRF] stringscodes 9A 19 and 9A 20 to print 'short volume' and 'short weight' respectively
This commit is contained in:
parent
8732e328c4
commit
307ca24427
|
@ -377,7 +377,7 @@ struct UnmappedChoiceList : ZeroedMemoryAllocator {
|
|||
const char *str = this->strings[this->strings.Contains(idx) ? idx : 0];
|
||||
/* Limit the length of the string we copy to 0xFE. The length is written above
|
||||
* as a byte and we need room for the final '\0'. */
|
||||
size_t len = min(0xFE, strlen(str));
|
||||
size_t len = min<size_t>(0xFE, strlen(str));
|
||||
memcpy(d, str, len);
|
||||
d += len;
|
||||
*d++ = '\0';
|
||||
|
@ -470,7 +470,7 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newline
|
|||
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;
|
||||
case 0x87: d += Utf8Encode(d, SCC_NEWGRF_PRINT_WORD_VOLUME_LONG); break;
|
||||
case 0x88: d += Utf8Encode(d, SCC_BLUE); break;
|
||||
case 0x89: d += Utf8Encode(d, SCC_SILVER); break;
|
||||
case 0x8A: d += Utf8Encode(d, SCC_GOLD); break;
|
||||
|
@ -519,7 +519,7 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newline
|
|||
/* 0x09, 0x0A are TTDPatch internal use only string codes. */
|
||||
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 0x0D: d += Utf8Encode(d, SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG); break;
|
||||
case 0x0E:
|
||||
case 0x0F: {
|
||||
if (str[0] == '\0') goto string_end;
|
||||
|
@ -582,7 +582,9 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newline
|
|||
|
||||
case 0x16:
|
||||
case 0x17:
|
||||
case 0x18: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16); break;
|
||||
case 0x18:
|
||||
case 0x19:
|
||||
case 0x20: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16); break;
|
||||
|
||||
default:
|
||||
grfmsg(1, "missing handler for extended format code");
|
||||
|
@ -1038,11 +1040,13 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
|
|||
case SCC_NEWGRF_PRINT_QWORD_HEX: *argv = _newgrf_textrefstack.PopUnsignedQWord(); break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_SPEED:
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME:
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME_LONG:
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT:
|
||||
case SCC_NEWGRF_PRINT_WORD_SIGNED: *argv = _newgrf_textrefstack.PopSignedWord(); break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_HEX:
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT:
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG:
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT:
|
||||
case SCC_NEWGRF_PRINT_WORD_POWER:
|
||||
case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
|
||||
case SCC_NEWGRF_PRINT_WORD_UNSIGNED: *argv = _newgrf_textrefstack.PopUnsignedWord(); break;
|
||||
|
@ -1098,12 +1102,18 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
|
|||
case SCC_NEWGRF_PRINT_WORD_SPEED:
|
||||
return SCC_VELOCITY;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME:
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME_LONG:
|
||||
return SCC_VOLUME;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT:
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT:
|
||||
return SCC_VOLUME_SHORT;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG:
|
||||
return SCC_WEIGHT;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT:
|
||||
return SCC_WEIGHT_SHORT;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_POWER:
|
||||
return SCC_POWER;
|
||||
|
||||
|
|
|
@ -121,8 +121,8 @@ enum StringControlCode {
|
|||
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 unsigned weight
|
||||
SCC_NEWGRF_PRINT_WORD_VOLUME_LONG, ///< Read 2 bytes from the stack as long signed volume
|
||||
SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG, ///< Read 2 bytes from the stack as long unsigned 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
|
||||
|
@ -132,6 +132,8 @@ enum StringControlCode {
|
|||
SCC_NEWGRF_PRINT_DWORD_DATE_LONG, ///< Read 4 bytes from the stack as base 0 date
|
||||
SCC_NEWGRF_PRINT_DWORD_DATE_SHORT, ///< Read 4 bytes from the stack as base 0 date
|
||||
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_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
|
||||
|
|
Loading…
Reference in New Issue