Mercurial > hg > openttd
changeset 3646:a4e54e88cd98 draft
(svn r4557) - NewGRF: translate from TTDPatch control codes to our own, instead of just simple validation. We still perform
validation on any unhandled character.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sun, 23 Apr 2006 21:52:54 +0000 |
parents | 42fd7728359e |
children | 461147884aab |
files | newgrf_text.c |
diffstat | 1 files changed, 44 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf_text.c +++ b/newgrf_text.c @@ -119,6 +119,49 @@ static byte _currentLangID = GRFLX_ENGLISH; //by default, english is used. +static void TranslateTTDPatchCodes(char *str) +{ + char *c; + + for (c = str; *c != '\0'; c++) { + switch ((byte)*c) { + case 0x01: c++; break; + case 0x0D: *c = 10; break; + case 0x0E: *c = 8; break; + case 0x0F: *c = 9; break; + case 0x1F: *c = 2; c += 2; break; + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: *c = 0x8E; break; + case 0x81: c += 2; break; + case 0x85: *c = 0x86; break; + case 0x88: *c = 15; break; + case 0x89: *c = 16; break; + case 0x8A: *c = 17; break; + case 0x8B: *c = 18; break; + case 0x8C: *c = 19; break; + case 0x8D: *c = 20; break; + case 0x8E: *c = 21; break; + case 0x8F: *c = 22; break; + case 0x90: *c = 23; break; + case 0x91: *c = 24; break; + case 0x92: *c = 25; break; + case 0x93: *c = 26; break; + case 0x94: *c = 27; break; + case 0x95: *c = 28; break; + case 0x96: *c = 29; break; + case 0x97: *c = 30; break; + case 0x98: *c = 31; break; + default: + /* Validate any unhandled character */ + if (!IsValidAsciiChar(*c)) *c = '?'; + break; + } + } +} + + /** * Add the new read string into our structure. */ @@ -150,7 +193,7 @@ newtext->text = strdup(text_to_add); newtext->next = NULL; - str_validate(newtext->text); + TranslateTTDPatchCodes(newtext->text); for (id = 0; id < _num_grf_texts; id++) { if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) {