Core/Misc: Delay creating std::string objects for locale data after size validation

This commit is contained in:
Shauren
2023-04-30 14:04:28 +02:00
parent 7f5e47c396
commit 8f7a1d3c2c
7 changed files with 83 additions and 80 deletions

View File

@@ -154,17 +154,17 @@ void CreatureTextMgr::LoadCreatureTextLocales()
{
Field* fields = result->Fetch();
uint32 creatureId = fields[0].GetUInt32();
uint32 groupId = fields[1].GetUInt8();
uint32 id = fields[2].GetUInt8();
std::string localeName = fields[3].GetString();
uint32 creatureId = fields[0].GetUInt32();
uint32 groupId = fields[1].GetUInt8();
uint32 id = fields[2].GetUInt8();
std::string_view localeName = fields[3].GetStringView();
LocaleConstant locale = GetLocaleByName(localeName);
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
continue;
CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(creatureId, groupId, id)];
ObjectMgr::AddLocaleString(fields[4].GetString(), locale, data.Text);
ObjectMgr::AddLocaleString(fields[4].GetStringView(), locale, data.Text);
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded {} creature localized texts in {} ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime));