(svn r19570) -Add: [NewGRF] support for extended text code 0x9A 11, print qword

pull/155/head
yexo 15 years ago
parent 043ff01b4a
commit 5d37ff11ba

@ -291,6 +291,9 @@ char *TranslateTTDPatchCodes(uint32 grfid, const char *str)
case 8: case 8:
d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_DWORD); d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_DWORD);
break; break;
case 0x0B:
d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_QWORD);
break;
default: default:
grfmsg(1, "missing handler for extended format code"); grfmsg(1, "missing handler for extended format code");
@ -650,6 +653,7 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
case SCC_NEWGRF_PRINT_HEX_BYTE: *argv = _newgrf_textrefstack->PopUnsignedByte(); 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_DWORD: *argv = _newgrf_textrefstack->PopUnsignedDWord(); break;
case SCC_NEWGRF_PRINT_HEX_QWORD: *argv = _newgrf_textrefstack->PopSignedQWord(); break;
case SCC_NEWGRF_PRINT_HEX_WORD: case SCC_NEWGRF_PRINT_HEX_WORD:
case SCC_NEWGRF_PRINT_WORD_SPEED: case SCC_NEWGRF_PRINT_WORD_SPEED:
@ -682,6 +686,7 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
case SCC_NEWGRF_PRINT_HEX_BYTE: case SCC_NEWGRF_PRINT_HEX_BYTE:
case SCC_NEWGRF_PRINT_HEX_WORD: case SCC_NEWGRF_PRINT_HEX_WORD:
case SCC_NEWGRF_PRINT_HEX_DWORD: case SCC_NEWGRF_PRINT_HEX_DWORD:
case SCC_NEWGRF_PRINT_HEX_QWORD:
return SCC_HEX; return SCC_HEX;
case SCC_NEWGRF_PRINT_DWORD_CURRENCY: case SCC_NEWGRF_PRINT_DWORD_CURRENCY:

@ -276,9 +276,11 @@
/* MSVCRT of course has to have a different syntax for long long *sigh* */ /* MSVCRT of course has to have a different syntax for long long *sigh* */
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__)
#define OTTD_PRINTF64 "%I64d" #define OTTD_PRINTF64 "%I64d"
#define OTTD_PRINTFHEX64 "%I64x"
#define PRINTF_SIZE "%Iu" #define PRINTF_SIZE "%Iu"
#else #else
#define OTTD_PRINTF64 "%lld" #define OTTD_PRINTF64 "%lld"
#define OTTD_PRINTFHEX64 "%llx"
#define PRINTF_SIZE "%zu" #define PRINTF_SIZE "%zu"
#endif #endif

@ -233,9 +233,9 @@ static char *FormatZerofillNumber(char *buff, int64 number, int64 count, const c
return FormatNumber(buff, number, last, "", 20 - count); return FormatNumber(buff, number, last, "", 20 - count);
} }
static char *FormatHexNumber(char *buff, int64 number, const char *last) static char *FormatHexNumber(char *buff, uint64 number, const char *last)
{ {
return buff + seprintf(buff, last, "0x%x", (uint32)number); return buff + seprintf(buff, last, "0x" OTTD_PRINTFHEX64, number);
} }
/** /**
@ -859,7 +859,7 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei,
} break; } break;
case SCC_HEX: // {HEX} case SCC_HEX: // {HEX}
buff = FormatHexNumber(buff, GetInt64(&argv), last); buff = FormatHexNumber(buff, (uint64)GetInt64(&argv), last);
break; break;
case SCC_BYTES: // {BYTES} case SCC_BYTES: // {BYTES}

@ -123,6 +123,7 @@ enum StringControlCode {
SCC_NEWGRF_PRINT_HEX_BYTE, ///< Read 1 byte from the stack and print it as hex 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_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_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_PUSH_WORD, ///< Pushes 2 bytes onto the stack
SCC_NEWGRF_UNPRINT, ///< "Unprints" the given number of bytes from the string SCC_NEWGRF_UNPRINT, ///< "Unprints" the given number of bytes from the string
SCC_NEWGRF_DISCARD_WORD, ///< Discard the next two bytes SCC_NEWGRF_DISCARD_WORD, ///< Discard the next two bytes

Loading…
Cancel
Save