Changeset - r17956:7f6e5b2426ea
[Not reviewed]
master
0 2 0
frosch - 13 years ago 2011-08-20 21:42:05
frosch@openttd.org
(svn r22775) -Fix: [NewGRF] Stringcodes 82 and 83 are the same as the date codes in old OpenTTD. (Hirundo)
2 files changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/newgrf_text.cpp
Show inline comments
 
@@ -433,49 +433,49 @@ char *TranslateTTDPatchCodes(uint32 grfi
 
			case 0x0F: d += Utf8Encode(d, SCC_BIGFONT); break;
 
			case 0x1F:
 
				if (str[0] == '\0' || str[1] == '\0') goto string_end;
 
				d += Utf8Encode(d, SCC_SETXY);
 
				*d++ = *str++;
 
				*d++ = *str++;
 
				break;
 
			case 0x7B:
 
			case 0x7C:
 
			case 0x7D:
 
			case 0x7E:
 
			case 0x7F:
 
			case 0x80: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD + c - 0x7B); break;
 
			case 0x81: {
 
				if (str[0] == '\0' || str[1] == '\0') goto string_end;
 
				StringID string;
 
				string  = ((uint8)*str++);
 
				string |= ((uint8)*str++) << 8;
 
				d += Utf8Encode(d, SCC_NEWGRF_STRINL);
 
				d += Utf8Encode(d, MapGRFStringID(grfid, string));
 
				break;
 
			}
 
			case 0x82:
 
			case 0x83:
 
			case 0x84: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DATE + c - 0x82); break;
 
			case 0x84: d += Utf8Encode(d, SCC_NEWGRF_PRINT_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 0x88: d += Utf8Encode(d, SCC_BLUE);    break;
 
			case 0x89: d += Utf8Encode(d, SCC_SILVER);  break;
 
			case 0x8A: d += Utf8Encode(d, SCC_GOLD);    break;
 
			case 0x8B: d += Utf8Encode(d, SCC_RED);     break;
 
			case 0x8C: d += Utf8Encode(d, SCC_PURPLE);  break;
 
			case 0x8D: d += Utf8Encode(d, SCC_LTBROWN); break;
 
			case 0x8E: d += Utf8Encode(d, SCC_ORANGE);  break;
 
			case 0x8F: d += Utf8Encode(d, SCC_GREEN);   break;
 
			case 0x90: d += Utf8Encode(d, SCC_YELLOW);  break;
 
			case 0x91: d += Utf8Encode(d, SCC_DKGREEN); break;
 
			case 0x92: d += Utf8Encode(d, SCC_CREAM);   break;
 
			case 0x93: d += Utf8Encode(d, SCC_BROWN);   break;
 
			case 0x94: d += Utf8Encode(d, SCC_WHITE);   break;
 
			case 0x95: d += Utf8Encode(d, SCC_LTBLUE);  break;
 
			case 0x96: d += Utf8Encode(d, SCC_GRAY);    break;
 
			case 0x97: d += Utf8Encode(d, SCC_DKBLUE);  break;
 
			case 0x98: d += Utf8Encode(d, SCC_BLACK);   break;
 
			case 0x9A: {
 
				int code = *str++;
 
				switch (code) {
 
					case 0x00: goto string_end;
 
@@ -1006,85 +1006,85 @@ void RewindTextRefStack()
 
 */
 
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv)
 
{
 
	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_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_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_DATE:
 
			case SCC_NEWGRF_PRINT_MONTH_YEAR:     *argv = _newgrf_textrefstack.PopUnsignedWord() + DAYS_TILL_ORIGINAL_BASE_YEAR; 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_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_PRINT_STRING_ID:
 
				*argv = TTDPStringIDToOTTDStringIDMapping(_newgrf_textrefstack.PopUnsignedWord());
 
				break;
 
		}
 
	}
 

	
 
	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:
 
			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;
 

	
 
		case SCC_NEWGRF_PRINT_STRING_ID:
 
			return SCC_NEWGRF_PRINT_STRING_ID;
 

	
 
		case SCC_NEWGRF_PRINT_DATE:
 
		case SCC_NEWGRF_PRINT_DATE_LONG:
 
			return SCC_DATE_LONG;
 

	
 
		case SCC_NEWGRF_PRINT_MONTH_YEAR:
 
			return SCC_DATE_TINY;
 
		case SCC_NEWGRF_PRINT_DATE_SHORT:
 
			return SCC_DATE_SHORT;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_SPEED:
 
			return SCC_VELOCITY;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_VOLUME:
 
			return SCC_VOLUME;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_WEIGHT:
 
			return SCC_WEIGHT;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
 
			return SCC_STATION_NAME;
 

	
 
		case SCC_NEWGRF_DISCARD_WORD:
 
		case SCC_NEWGRF_ROTATE_TOP_4_WORDS:
 
		case SCC_NEWGRF_PUSH_WORD:
 
		case SCC_NEWGRF_UNPRINT:
 
			return 0;
 
	}
 
}
src/table/control_codes.h
Show inline comments
 
@@ -97,50 +97,50 @@ enum StringControlCode {
 
	SCC_ORANGE,
 
	SCC_GREEN,
 
	SCC_YELLOW,
 
	SCC_DKGREEN,
 
	SCC_CREAM,
 
	SCC_BROWN,
 
	SCC_WHITE,
 
	SCC_LTBLUE,
 
	SCC_GRAY,
 
	SCC_DKBLUE,
 
	SCC_BLACK,
 
	SCC_PREVIOUS_COLOUR,
 

	
 
	/**
 
	 * The next variables are part of a NewGRF subsystem for creating text strings.
 
	 * 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,                     ///< Read 2 bytes from the stack as base 1920 date
 
	SCC_NEWGRF_PRINT_MONTH_YEAR,               ///< Read 2 bytes from the stack as base 1920 date
 
	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_LAST = SCC_NEWGRF_ROTATE_TOP_4_WORDS,
 

	
 
	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 */
 
	SCC_LESSTHAN       = SCC_SPRITE_START + 0x3C,
 
	SCC_GREATERTHAN    = SCC_SPRITE_START + 0x3E,
 
	SCC_UPARROW        = SCC_SPRITE_START + 0xA0,
 
	SCC_DOWNARROW      = SCC_SPRITE_START + 0xAA,
 
	SCC_CHECKMARK      = SCC_SPRITE_START + 0xAC,
0 comments (0 inline, 0 general)