diff options
author | peter1138 <peter1138@openttd.org> | 2006-04-23 21:52:54 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-04-23 21:52:54 +0000 |
commit | 5bb3009dca73da8b850d954b23b8dcdfea5e6e86 (patch) | |
tree | fff3c4abc8868bd446ff8b6983fe5c234ba6267f | |
parent | 6dbc9c9ced44d98abb8759593db92910f16292e4 (diff) | |
download | openttd-5bb3009dca73da8b850d954b23b8dcdfea5e6e86.tar.xz |
(svn r4557) - NewGRF: translate from TTDPatch control codes to our own, instead of just simple validation. We still perform
validation on any unhandled character.
-rw-r--r-- | newgrf_text.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/newgrf_text.c b/newgrf_text.c index 1001ed15b..86ecec502 100644 --- a/newgrf_text.c +++ b/newgrf_text.c @@ -119,6 +119,49 @@ static GRFTextEntry _grf_text[(1 << TABSIZE) * 3]; 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 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne 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) { |