Changeset - r5344:713e0cc79bc9
[Not reviewed]
master
0 1 0
Darkvater - 18 years ago 2006-12-20 17:03:14
darkvater@openttd.org
(svn r7515) -Codechange [newgrf]: Ignore ascii code 0x0A in text. Newline is 0x0D.
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
newgrf_text.c
Show inline comments
 
@@ -158,49 +158,50 @@ char *TranslateTTDPatchCodes(const char 
 
{
 
	char *tmp = malloc(strlen(str) * 10 + 1); /* Allocate space to allow for expansion */
 
	char *d = tmp;
 
	bool unicode = false;
 
	WChar c;
 
	size_t len = Utf8Decode(&c, str);
 

	
 
	if (c == 0x00DE) {
 
		/* The thorn ('รพ') indicates a unicode string to TTDPatch */
 
		unicode = true;
 
		str += len;
 
	}
 

	
 
	for (;;) {
 
		const char *tmp = str; /* Used for UTF-8 decoding */
 

	
 
		c = (byte)*str++;
 
		if (c == 0) break;
 

	
 
		switch (c) {
 
			case 0x01:
 
				d += Utf8Encode(d, SCC_SETX);
 
				*d++ = *str++;
 
				break;
 
			case 0x0D: *d++ = 10; break;
 
			case 0x0A: break;
 
			case 0x0D: *d++ = 0x0A; break;
 
			case 0x0E: d += Utf8Encode(d, SCC_TINYFONT); break;
 
			case 0x0F: d += Utf8Encode(d, SCC_BIGFONT); break;
 
			case 0x1F:
 
				d += Utf8Encode(d, SCC_SETXY);
 
				*d++ = *str++;
 
				*d++ = *str++;
 
				break;
 
			case 0x7B:
 
			case 0x7C:
 
			case 0x7D:
 
			case 0x7E: d += Utf8Encode(d, SCC_NUM); break;
 
			case 0x7F: d += Utf8Encode(d, SCC_CURRENCY); break;
 
			case 0x80: d += Utf8Encode(d, SCC_STRING); break;
 
			case 0x81: {
 
				StringID string;
 
				string  = *str++;
 
				string |= *str++ << 8;
 
				d += Utf8Encode(d, SCC_STRING_ID);
 
				d += Utf8Encode(d, string);
 
				break;
 
			}
 
			case 0x82: d += Utf8Encode(d, SCC_DATE_TINY); break;
 
			case 0x83: d += Utf8Encode(d, SCC_DATE_SHORT); break;
 
			case 0x84: d += Utf8Encode(d, SCC_VELOCITY); break;
0 comments (0 inline, 0 general)