equal
deleted
inserted
replaced
255 DEBUG(grf, 2)("Added 0x%X: grfid 0x%X string 0x%X lang 0x%X string %s", id, grfid, stringid, newtext->langid, newtext->text); |
255 DEBUG(grf, 2)("Added 0x%X: grfid 0x%X string 0x%X lang 0x%X string %s", id, grfid, stringid, newtext->langid, newtext->text); |
256 |
256 |
257 return (GRFTAB << TABSIZE) + id; |
257 return (GRFTAB << TABSIZE) + id; |
258 } |
258 } |
259 |
259 |
|
260 /* Used to remember the grfid that the last retrieved string came from */ |
|
261 static uint32 _last_grfid = 0; |
260 |
262 |
261 /** |
263 /** |
262 * Returns the index for this stringid associated with its grfID |
264 * Returns the index for this stringid associated with its grfID |
263 */ |
265 */ |
264 StringID GetGRFStringID(uint32 grfid, uint16 stringid) |
266 StringID GetGRFStringID(uint32 grfid, uint16 stringid) |
265 { |
267 { |
266 uint id; |
268 uint id; |
|
269 |
|
270 /* grfid is zero when we're being called via an include */ |
|
271 if (grfid == 0) grfid = _last_grfid; |
|
272 |
267 for (id = 0; id < _num_grf_texts; id++) { |
273 for (id = 0; id < _num_grf_texts; id++) { |
268 if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) { |
274 if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) { |
269 return (GRFTAB << TABSIZE) + id; |
275 return (GRFTAB << TABSIZE) + id; |
270 } |
276 } |
271 } |
277 } |
278 { |
284 { |
279 const GRFText *default_text = NULL; |
285 const GRFText *default_text = NULL; |
280 const GRFText *search_text; |
286 const GRFText *search_text; |
281 |
287 |
282 assert(_grf_text[stringid].grfid != 0); |
288 assert(_grf_text[stringid].grfid != 0); |
|
289 |
|
290 /* Remember this grfid in case the string has included text */ |
|
291 _last_grfid = _grf_text[stringid].grfid; |
|
292 |
283 /*Search the list of lang-strings of this stringid for current lang */ |
293 /*Search the list of lang-strings of this stringid for current lang */ |
284 for (search_text = _grf_text[stringid].textholder; search_text != NULL; search_text = search_text->next) { |
294 for (search_text = _grf_text[stringid].textholder; search_text != NULL; search_text = search_text->next) { |
285 if (search_text->langid == _currentLangID) { |
295 if (search_text->langid == _currentLangID) { |
286 return strecpy(buff, search_text->text, NULL); |
296 return strecpy(buff, search_text->text, NULL); |
287 } |
297 } |