equal
deleted
inserted
replaced
231 /* Too many strings allocated, return empty */ |
231 /* Too many strings allocated, return empty */ |
232 if (id == lengthof(_grf_text)) return STR_EMPTY; |
232 if (id == lengthof(_grf_text)) return STR_EMPTY; |
233 |
233 |
234 newtext = malloc(sizeof(*newtext) + strlen(text_to_add) + 1); |
234 newtext = malloc(sizeof(*newtext) + strlen(text_to_add) + 1); |
235 newtext->next = NULL; |
235 newtext->next = NULL; |
236 newtext->langid = GB(langid_to_add, 0, 6); |
236 newtext->langid = langid_to_add; |
237 strcpy(newtext->text, text_to_add); |
237 strcpy(newtext->text, text_to_add); |
238 |
238 |
239 TranslateTTDPatchCodes(newtext->text); |
239 TranslateTTDPatchCodes(newtext->text); |
240 |
240 |
241 /* If we didn't find our stringid and grfid in the list, allocate a new id */ |
241 /* If we didn't find our stringid and grfid in the list, allocate a new id */ |
250 GRFText **ptext, *text; |
250 GRFText **ptext, *text; |
251 bool replaced = false; |
251 bool replaced = false; |
252 |
252 |
253 /* Loop through all languages and see if we can replace a string */ |
253 /* Loop through all languages and see if we can replace a string */ |
254 for (ptext = &_grf_text[id].textholder; (text = *ptext) != NULL; ptext = &text->next) { |
254 for (ptext = &_grf_text[id].textholder; (text = *ptext) != NULL; ptext = &text->next) { |
255 if (text->langid != GB(langid_to_add, 0, 6)) continue; |
255 if (text->langid != langid_to_add) continue; |
256 newtext->next = text->next; |
256 newtext->next = text->next; |
257 *ptext = newtext; |
257 *ptext = newtext; |
258 free(text); |
258 free(text); |
259 replaced = true; |
259 replaced = true; |
260 break; |
260 break; |
308 return strecpy(buff, search_text->text, last); |
308 return strecpy(buff, search_text->text, last); |
309 } |
309 } |
310 |
310 |
311 /* If the current string is English or American, set it as the |
311 /* If the current string is English or American, set it as the |
312 * fallback language if the specific language isn't available. */ |
312 * fallback language if the specific language isn't available. */ |
313 if (search_text->langid == GRFLX_ENGLISH || search_text->langid == GRFLX_AMERICAN) { |
313 if (search_text->langid == GRFLX_UNSPECIFIED || (default_text == NULL && (search_text->langid == GRFLX_ENGLISH || search_text->langid == GRFLX_AMERICAN))) { |
314 default_text = search_text; |
314 default_text = search_text; |
315 } |
315 } |
316 } |
316 } |
317 |
317 |
318 /* If there is a fallback string, return that */ |
318 /* If there is a fallback string, return that */ |