mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
(svn r21178) -Codechange: pass the language_id to TranslateTTDPatchCodes as well
This commit is contained in:
parent
034eb834cc
commit
fc75b00992
@ -5373,7 +5373,7 @@ static void GRFLoadError(ByteReader *buf)
|
|||||||
if (buf->HasData()) {
|
if (buf->HasData()) {
|
||||||
const char *message = buf->ReadString();
|
const char *message = buf->ReadString();
|
||||||
|
|
||||||
error->custom_message = TranslateTTDPatchCodes(_cur_grffile->grfid, message);
|
error->custom_message = TranslateTTDPatchCodes(_cur_grffile->grfid, lang, message);
|
||||||
} else {
|
} else {
|
||||||
grfmsg(7, "GRFLoadError: No custom message supplied.");
|
grfmsg(7, "GRFLoadError: No custom message supplied.");
|
||||||
error->custom_message = strdup("");
|
error->custom_message = strdup("");
|
||||||
@ -5385,7 +5385,7 @@ static void GRFLoadError(ByteReader *buf)
|
|||||||
if (buf->HasData()) {
|
if (buf->HasData()) {
|
||||||
const char *data = buf->ReadString();
|
const char *data = buf->ReadString();
|
||||||
|
|
||||||
error->data = TranslateTTDPatchCodes(_cur_grffile->grfid, data);
|
error->data = TranslateTTDPatchCodes(_cur_grffile->grfid, lang, data);
|
||||||
} else {
|
} else {
|
||||||
grfmsg(7, "GRFLoadError: No message data supplied.");
|
grfmsg(7, "GRFLoadError: No message data supplied.");
|
||||||
error->data = strdup("");
|
error->data = strdup("");
|
||||||
@ -5926,7 +5926,7 @@ static void FeatureTownName(ByteReader *buf)
|
|||||||
|
|
||||||
const char *name = buf->ReadString();
|
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);
|
grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, lang_name);
|
||||||
free(lang_name);
|
free(lang_name);
|
||||||
|
|
||||||
@ -5972,7 +5972,7 @@ static void FeatureTownName(ByteReader *buf)
|
|||||||
townname->partlist[id][i].parts[j].data.id = ref_id;
|
townname->partlist[id][i].parts[j].data.id = ref_id;
|
||||||
} else {
|
} else {
|
||||||
const char *text = buf->ReadString();
|
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);
|
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;
|
townname->partlist[id][i].parts[j].prob = prob;
|
||||||
|
@ -196,7 +196,14 @@ static GRFTextEntry _grf_text[(1 << TABSIZE) * 3];
|
|||||||
static byte _currentLangID = GRFLX_ENGLISH; ///< by default, english is used.
|
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 *tmp = MallocT<char>(strlen(str) * 10 + 1); // Allocate space to allow for expansion
|
||||||
char *d = tmp;
|
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)
|
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);
|
GRFText *newtext = GRFText::New(langid, translatedtext);
|
||||||
free(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 */
|
/* Too many strings allocated, return empty */
|
||||||
if (id == lengthof(_grf_text)) return STR_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);
|
GRFText *newtext = GRFText::New(langid_to_add, translatedtext);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ const char *GetGRFStringFromGRFText(const struct GRFText *text);
|
|||||||
const char *GetGRFStringPtr(uint16 stringid);
|
const char *GetGRFStringPtr(uint16 stringid);
|
||||||
void CleanUpStrings();
|
void CleanUpStrings();
|
||||||
void SetCurrentGrfLangID(byte language_id);
|
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);
|
struct GRFText *DuplicateGRFText(struct GRFText *orig);
|
||||||
void AddGRFTextToList(struct GRFText **list, struct GRFText *text_to_add);
|
void AddGRFTextToList(struct GRFText **list, struct GRFText *text_to_add);
|
||||||
void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, const char *text_to_add);
|
void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, const char *text_to_add);
|
||||||
|
Loading…
Reference in New Issue
Block a user