Changeset - r14952:14ece20bc0d1
[Not reviewed]
master
0 4 0
yexo - 14 years ago 2010-04-06 23:45:10
yexo@openttd.org
(svn r19570) -Add: [NewGRF] support for extended text code 0x9A 11, print qword
4 files changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/newgrf_text.cpp
Show inline comments
 
@@ -288,12 +288,15 @@ char *TranslateTTDPatchCodes(uint32 grfi
 
					case 7:
 
						d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_WORD);
 
						break;
 
					case 8:
 
						d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_DWORD);
 
						break;
 
					case 0x0B:
 
						d += Utf8Encode(d, SCC_NEWGRF_PRINT_HEX_QWORD);
 
						break;
 

	
 
					default:
 
						grfmsg(1, "missing handler for extended format code");
 
						break;
 
				}
 
				break;
 
@@ -647,12 +650,13 @@ uint RemapNewGRFStringControlCode(uint s
 

	
 
			case SCC_NEWGRF_PRINT_DWORD_CURRENCY:
 
			case SCC_NEWGRF_PRINT_DWORD:          *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_HEX_WORD:
 
			case SCC_NEWGRF_PRINT_WORD_SPEED:
 
			case SCC_NEWGRF_PRINT_WORD_LITRES:
 
			case SCC_NEWGRF_PRINT_UNSIGNED_WORD:  *argv = _newgrf_textrefstack->PopUnsignedWord();  break;
 

	
 
@@ -679,12 +683,13 @@ uint RemapNewGRFStringControlCode(uint s
 
		case SCC_NEWGRF_PRINT_UNSIGNED_WORD:
 
			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:
 
			return SCC_HEX;
 

	
 
		case SCC_NEWGRF_PRINT_DWORD_CURRENCY:
 
		case SCC_NEWGRF_PRINT_QWORD_CURRENCY:
 
			return SCC_CURRENCY;
 

	
src/stdafx.h
Show inline comments
 
@@ -273,15 +273,17 @@
 
	#define PATHSEPCHAR '/'
 
#endif
 

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

	
 
typedef unsigned char byte;
 

	
 
/* This is already defined in unix, but not in QNX Neutrino (6.x)*/
src/strings.cpp
Show inline comments
 
@@ -230,15 +230,15 @@ static char *FormatNoCommaNumber(char *b
 

	
 
static char *FormatZerofillNumber(char *buff, int64 number, int64 count, const char *last)
 
{
 
	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);
 
}
 

	
 
/**
 
 * Format a given number as a number of bytes with the SI prefix.
 
 * @param buff   the buffer to write to
 
 * @param number the number of bytes to write down
 
@@ -856,13 +856,13 @@ static char *FormatString(char *buff, co
 
			case SCC_ZEROFILL_NUM: { // {ZEROFILL_NUM}
 
				int64 num = GetInt64(&argv);
 
				buff = FormatZerofillNumber(buff, num, GetInt64(&argv), last);
 
			} break;
 

	
 
			case SCC_HEX: // {HEX}
 
				buff = FormatHexNumber(buff, GetInt64(&argv), last);
 
				buff = FormatHexNumber(buff, (uint64)GetInt64(&argv), last);
 
				break;
 

	
 
			case SCC_BYTES: // {BYTES}
 
				buff = FormatBytes(buff, GetInt64(&argv), last);
 
				break;
 

	
src/table/control_codes.h
Show inline comments
 
@@ -120,12 +120,13 @@ enum StringControlCode {
 
	SCC_NEWGRF_PRINT_WORD_SPEED,               ///< Read 2 bytes from the stack as signed speed
 
	SCC_NEWGRF_PRINT_WORD_LITRES,              ///< Read 2 bytes from the stack as signed litres
 
	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_LAST = SCC_NEWGRF_ROTATE_TOP_4_WORDS,
 

	
0 comments (0 inline, 0 general)