diff options
author | rubidium <rubidium@openttd.org> | 2010-11-13 19:15:26 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-11-13 19:15:26 +0000 |
commit | fc75b00992dbf6f86a39aca1a2cda4e6378b6bba (patch) | |
tree | 2b9c10b294d39bc0bd667ac26696d44a49ec93e2 | |
parent | 034eb834cc277048e296bf1297f56e1667ab9881 (diff) | |
download | openttd-fc75b00992dbf6f86a39aca1a2cda4e6378b6bba.tar.xz |
(svn r21178) -Codechange: pass the language_id to TranslateTTDPatchCodes as well
-rw-r--r-- | src/newgrf.cpp | 8 | ||||
-rw-r--r-- | src/newgrf_text.cpp | 13 | ||||
-rw-r--r-- | src/newgrf_text.h | 2 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 0cdeb6178..bb77635d8 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5373,7 +5373,7 @@ static void GRFLoadError(ByteReader *buf) if (buf->HasData()) { const char *message = buf->ReadString(); - error->custom_message = TranslateTTDPatchCodes(_cur_grffile->grfid, message); + error->custom_message = TranslateTTDPatchCodes(_cur_grffile->grfid, lang, message); } else { grfmsg(7, "GRFLoadError: No custom message supplied."); error->custom_message = strdup(""); @@ -5385,7 +5385,7 @@ static void GRFLoadError(ByteReader *buf) if (buf->HasData()) { const char *data = buf->ReadString(); - error->data = TranslateTTDPatchCodes(_cur_grffile->grfid, data); + error->data = TranslateTTDPatchCodes(_cur_grffile->grfid, lang, data); } else { grfmsg(7, "GRFLoadError: No message data supplied."); error->data = strdup(""); @@ -5926,7 +5926,7 @@ static void FeatureTownName(ByteReader *buf) const char *name = buf->ReadString(); - char *lang_name = TranslateTTDPatchCodes(grfid, name); + char *lang_name = TranslateTTDPatchCodes(grfid, lang, name); grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, lang_name); free(lang_name); @@ -5972,7 +5972,7 @@ static void FeatureTownName(ByteReader *buf) townname->partlist[id][i].parts[j].data.id = ref_id; } else { const char *text = buf->ReadString(); - townname->partlist[id][i].parts[j].data.text = TranslateTTDPatchCodes(grfid, text); + townname->partlist[id][i].parts[j].data.text = TranslateTTDPatchCodes(grfid, 0, text); grfmsg(6, "FeatureTownName: part %d, text %d, '%s' (with probability %d)", i, j, townname->partlist[id][i].parts[j].data.text, prob); } townname->partlist[id][i].parts[j].prob = prob; diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index ae48aa3eb..167e27b9a 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -196,7 +196,14 @@ static GRFTextEntry _grf_text[(1 << TABSIZE) * 3]; static byte _currentLangID = GRFLX_ENGLISH; ///< by default, english is used. -char *TranslateTTDPatchCodes(uint32 grfid, const char *str) +/** + * Translate TTDPatch string codes into something OpenTTD can handle (better). + * @param grfid The (NewGRF) ID associated with this string + * @param language_id The (NewGRF) language ID associated with this string. + * @param str The string to translate. + * @return The translated string. + */ +char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, const char *str) { char *tmp = MallocT<char>(strlen(str) * 10 + 1); // Allocate space to allow for expansion char *d = tmp; @@ -380,7 +387,7 @@ void AddGRFTextToList(GRFText **list, GRFText *text_to_add) */ void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, const char *text_to_add) { - char *translatedtext = TranslateTTDPatchCodes(grfid, text_to_add); + char *translatedtext = TranslateTTDPatchCodes(grfid, langid, text_to_add); GRFText *newtext = GRFText::New(langid, translatedtext); free(translatedtext); @@ -449,7 +456,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne /* Too many strings allocated, return empty */ if (id == lengthof(_grf_text)) return STR_EMPTY; - translatedtext = TranslateTTDPatchCodes(grfid, text_to_add); + translatedtext = TranslateTTDPatchCodes(grfid, langid_to_add, text_to_add); GRFText *newtext = GRFText::New(langid_to_add, translatedtext); diff --git a/src/newgrf_text.h b/src/newgrf_text.h index e6e3b9e16..e86487c21 100644 --- a/src/newgrf_text.h +++ b/src/newgrf_text.h @@ -20,7 +20,7 @@ const char *GetGRFStringFromGRFText(const struct GRFText *text); const char *GetGRFStringPtr(uint16 stringid); void CleanUpStrings(); void SetCurrentGrfLangID(byte language_id); -char *TranslateTTDPatchCodes(uint32 grfid, const char *str); +char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, const char *str); struct GRFText *DuplicateGRFText(struct GRFText *orig); void AddGRFTextToList(struct GRFText **list, struct GRFText *text_to_add); void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, const char *text_to_add); |