mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-04 13:23:46 +00:00
(svn r6623) - Codechange: When adding a NewGRF string, check to see if it can replace an existing string. Also remove string length check on load which was a quickfix for some grfs.
This commit is contained in:
parent
7be5422d83
commit
7b1053c350
2
newgrf.c
2
newgrf.c
@ -1960,7 +1960,7 @@ static void FeatureNewName(byte *buf, int len)
|
|||||||
for (; id < endid && len > 0; id++) {
|
for (; id < endid && len > 0; id++) {
|
||||||
size_t ofs = strlen(name) + 1;
|
size_t ofs = strlen(name) + 1;
|
||||||
|
|
||||||
if (ofs > 1 && ofs < 128) {
|
if (ofs < 128) {
|
||||||
DEBUG(grf, 8) ("FeatureNewName: %d <- %s", id, name);
|
DEBUG(grf, 8) ("FeatureNewName: %d <- %s", id, name);
|
||||||
|
|
||||||
switch (feature) {
|
switch (feature) {
|
||||||
|
@ -247,9 +247,21 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
|
|||||||
_grf_text[id].def_string = def_string;
|
_grf_text[id].def_string = def_string;
|
||||||
_grf_text[id].textholder = newtext;
|
_grf_text[id].textholder = newtext;
|
||||||
} else {
|
} else {
|
||||||
GRFText *textptr = _grf_text[id].textholder;
|
GRFText **ptext, *text;
|
||||||
while (textptr->next != NULL) textptr = textptr->next;
|
bool replaced = false;
|
||||||
textptr->next = newtext;
|
|
||||||
|
/* Loop through all languages and see if we can replace a string */
|
||||||
|
for (ptext = &_grf_text[id].textholder; (text = *ptext) != NULL; ptext = &text->next) {
|
||||||
|
if (text->langid != GB(langid_to_add, 0, 6)) continue;
|
||||||
|
newtext->next = text->next;
|
||||||
|
*ptext = newtext;
|
||||||
|
free(text);
|
||||||
|
replaced = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If a string wasn't replaced, then we must append the new string */
|
||||||
|
if (!replaced) *ptext = newtext;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(grf, 2)("Added 0x%X: grfid 0x%X string 0x%X lang 0x%X string %s", id, grfid, stringid, newtext->langid, newtext->text);
|
DEBUG(grf, 2)("Added 0x%X: grfid 0x%X string 0x%X lang 0x%X string %s", id, grfid, stringid, newtext->langid, newtext->text);
|
||||||
|
Loading…
Reference in New Issue
Block a user