NewGRF: Use per-GRF text ID map in GetGRFStringID
This commit is contained in:
@@ -12461,9 +12461,6 @@ void LoadNewGRF(uint load_index, uint num_baseset)
|
|||||||
|
|
||||||
/* Pseudo sprite processing is finished; free temporary stuff */
|
/* Pseudo sprite processing is finished; free temporary stuff */
|
||||||
_cur.ClearDataForNextFile();
|
_cur.ClearDataForNextFile();
|
||||||
for (GRFFile * const file : _grf_files) {
|
|
||||||
file->string_map.clear();
|
|
||||||
}
|
|
||||||
_callback_result_cache.clear();
|
_callback_result_cache.clear();
|
||||||
|
|
||||||
/* Call any functions that should be run after GRFs have been loaded. */
|
/* Call any functions that should be run after GRFs have been loaded. */
|
||||||
|
@@ -614,10 +614,17 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
|
|||||||
*/
|
*/
|
||||||
StringID GetGRFStringID(uint32 grfid, StringID stringid)
|
StringID GetGRFStringID(uint32 grfid, StringID stringid)
|
||||||
{
|
{
|
||||||
for (uint id = 0; id < _num_grf_texts; id++) {
|
extern GRFFile *GetFileByGRFIDExpectCurrent(uint32 grfid);
|
||||||
if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) {
|
GRFFile *grf = GetFileByGRFIDExpectCurrent(grfid);
|
||||||
return MakeStringID(TEXT_TAB_NEWGRF_START, id);
|
if (unlikely(grf == nullptr)) {
|
||||||
|
for (uint id = 0; id < _num_grf_texts; id++) {
|
||||||
|
if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) {
|
||||||
|
return MakeStringID(TEXT_TAB_NEWGRF_START, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
auto iter = grf->string_map.find(stringid);
|
||||||
|
if (iter != grf->string_map.end()) return MakeStringID(TEXT_TAB_NEWGRF_START, iter->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
return STR_UNDEFINED;
|
return STR_UNDEFINED;
|
||||||
|
Reference in New Issue
Block a user