mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Misc: Delay creating std::string objects for locale data after size validation
This commit is contained in:
@@ -1360,8 +1360,8 @@ void AchievementGlobalMgr::LoadRewardLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
if (_achievementRewards.find(id) == _achievementRewards.end())
|
||||
{
|
||||
@@ -1369,13 +1369,13 @@ void AchievementGlobalMgr::LoadRewardLocales()
|
||||
continue;
|
||||
}
|
||||
|
||||
AchievementRewardLocale& data = _achievementRewardLocales[id];
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
ObjectMgr::AddLocaleString(fields[2].GetString(), locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, data.Body);
|
||||
AchievementRewardLocale& data = _achievementRewardLocales[id];
|
||||
ObjectMgr::AddLocaleString(fields[2].GetStringView(), locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetStringView(), locale, data.Body);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} achievement reward locale strings in {} ms.", uint32(_achievementRewardLocales.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Trainer
|
||||
return sSpellMgr->AssertSpellInfo(SpellId, DIFFICULTY_NONE)->HasEffect(SPELL_EFFECT_LEARN_SPELL);
|
||||
}
|
||||
|
||||
Trainer::Trainer(uint32 id, Type type, std::string greeting, std::vector<Spell> spells) : _id(id), _type(type), _spells(std::move(spells))
|
||||
Trainer::Trainer(uint32 id, Type type, std::string_view greeting, std::vector<Spell> spells) : _id(id), _type(type), _spells(std::move(spells))
|
||||
{
|
||||
_greeting[DEFAULT_LOCALE] = std::move(greeting);
|
||||
_greeting[DEFAULT_LOCALE] = greeting;
|
||||
}
|
||||
|
||||
void Trainer::SendSpells(Creature const* npc, Player* player, LocaleConstant locale) const
|
||||
@@ -226,8 +226,8 @@ namespace Trainer
|
||||
return _greeting[locale];
|
||||
}
|
||||
|
||||
void Trainer::AddGreetingLocale(LocaleConstant locale, std::string greeting)
|
||||
void Trainer::AddGreetingLocale(LocaleConstant locale, std::string_view greeting)
|
||||
{
|
||||
_greeting[locale] = std::move(greeting);
|
||||
_greeting[locale] = greeting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Trainer
|
||||
class Trainer
|
||||
{
|
||||
public:
|
||||
Trainer(uint32 id, Type type, std::string greeting, std::vector<Spell> spells);
|
||||
Trainer(uint32 id, Type type, std::string_view greeting, std::vector<Spell> spells);
|
||||
|
||||
void SendSpells(Creature const* npc, Player* player, LocaleConstant locale) const;
|
||||
void TeachSpell(Creature const* npc, Player* player, uint32 spellId) const;
|
||||
@@ -78,7 +78,7 @@ namespace Trainer
|
||||
std::string const& GetGreeting(LocaleConstant locale) const;
|
||||
|
||||
friend ObjectMgr;
|
||||
void AddGreetingLocale(LocaleConstant locale, std::string greeting);
|
||||
void AddGreetingLocale(LocaleConstant locale, std::string_view greeting);
|
||||
|
||||
uint32 _id;
|
||||
Type _type;
|
||||
|
||||
@@ -241,14 +241,17 @@ ObjectMgr::~ObjectMgr()
|
||||
{
|
||||
}
|
||||
|
||||
void ObjectMgr::AddLocaleString(std::string&& value, LocaleConstant localeConstant, std::vector<std::string>& data)
|
||||
void ObjectMgr::AddLocaleString(std::string_view value, LocaleConstant localeConstant, std::vector<std::string>& data)
|
||||
{
|
||||
if (!value.empty())
|
||||
{
|
||||
if (data.size() <= size_t(localeConstant))
|
||||
{
|
||||
data.reserve(TOTAL_LOCALES);
|
||||
data.resize(localeConstant + 1);
|
||||
}
|
||||
|
||||
data[localeConstant] = std::move(value);
|
||||
data[localeConstant] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,18 +270,18 @@ void ObjectMgr::LoadCreatureLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
CreatureLocale& data = _creatureLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.NameAlt);
|
||||
AddLocaleString(fields[4].GetString(), locale, data.Title);
|
||||
AddLocaleString(fields[5].GetString(), locale, data.TitleAlt);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.Name);
|
||||
AddLocaleString(fields[3].GetStringView(), locale, data.NameAlt);
|
||||
AddLocaleString(fields[4].GetStringView(), locale, data.Title);
|
||||
AddLocaleString(fields[5].GetStringView(), locale, data.TitleAlt);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -301,17 +304,17 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 menuId = fields[0].GetUInt32();
|
||||
uint32 optionId = fields[1].GetUInt32();
|
||||
std::string localeName = fields[2].GetString();
|
||||
uint32 menuId = fields[0].GetUInt32();
|
||||
uint32 optionId = fields[1].GetUInt32();
|
||||
std::string_view localeName = fields[2].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[std::make_pair(menuId, optionId)];
|
||||
AddLocaleString(fields[3].GetString(), locale, data.OptionText);
|
||||
AddLocaleString(fields[4].GetString(), locale, data.BoxText);
|
||||
AddLocaleString(fields[3].GetStringView(), locale, data.OptionText);
|
||||
AddLocaleString(fields[4].GetStringView(), locale, data.BoxText);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option locale strings in {} ms", _gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -332,15 +335,15 @@ void ObjectMgr::LoadPointOfInterestLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
PointOfInterestLocale& data = _pointOfInterestLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.Name);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} points_of_interest locale strings in {} ms", uint32(_pointOfInterestLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -2277,7 +2280,7 @@ void ObjectMgr::LoadTempSummons()
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} temp summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
inline std::vector<Difficulty> ParseSpawnDifficulties(std::string const& difficultyString, std::string const& table, ObjectGuid::LowType spawnId, uint32 mapId,
|
||||
inline std::vector<Difficulty> ParseSpawnDifficulties(std::string_view difficultyString, std::string_view table, ObjectGuid::LowType spawnId, uint32 mapId,
|
||||
std::set<Difficulty> const& mapDifficulties)
|
||||
{
|
||||
std::vector<Difficulty> difficulties;
|
||||
@@ -2362,7 +2365,7 @@ void ObjectMgr::LoadCreatures()
|
||||
data.curhealth = fields[12].GetUInt32();
|
||||
data.curmana = fields[13].GetUInt32();
|
||||
data.movementType = fields[14].GetUInt8();
|
||||
data.spawnDifficulties = ParseSpawnDifficulties(fields[15].GetString(), "creature", guid, data.mapId, spawnMasks[data.mapId]);
|
||||
data.spawnDifficulties = ParseSpawnDifficulties(fields[15].GetStringView(), "creature", guid, data.mapId, spawnMasks[data.mapId]);
|
||||
int16 gameEvent = fields[16].GetInt8();
|
||||
data.poolId = fields[17].GetUInt32();
|
||||
data.npcflag = fields[18].GetUInt64();
|
||||
@@ -2742,7 +2745,7 @@ void ObjectMgr::LoadGameObjects()
|
||||
}
|
||||
data.goState = GOState(go_state);
|
||||
|
||||
data.spawnDifficulties = ParseSpawnDifficulties(fields[14].GetString(), "gameobject", guid, data.mapId, spawnMasks[data.mapId]);
|
||||
data.spawnDifficulties = ParseSpawnDifficulties(fields[14].GetStringView(), "gameobject", guid, data.mapId, spawnMasks[data.mapId]);
|
||||
if (data.spawnDifficulties.empty())
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {}) that is not spawned in any difficulty, skipped.", guid);
|
||||
@@ -5531,22 +5534,22 @@ void ObjectMgr::LoadQuestTemplateLocale()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
QuestTemplateLocale& data = _questTemplateLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.LogTitle);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.LogDescription);
|
||||
AddLocaleString(fields[4].GetString(), locale, data.QuestDescription);
|
||||
AddLocaleString(fields[5].GetString(), locale, data.AreaDescription);
|
||||
AddLocaleString(fields[6].GetString(), locale, data.PortraitGiverText);
|
||||
AddLocaleString(fields[7].GetString(), locale, data.PortraitGiverName);
|
||||
AddLocaleString(fields[8].GetString(), locale, data.PortraitTurnInText);
|
||||
AddLocaleString(fields[9].GetString(), locale, data.PortraitTurnInName);
|
||||
AddLocaleString(fields[10].GetString(), locale, data.QuestCompletionLog);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.LogTitle);
|
||||
AddLocaleString(fields[3].GetStringView(), locale, data.LogDescription);
|
||||
AddLocaleString(fields[4].GetStringView(), locale, data.QuestDescription);
|
||||
AddLocaleString(fields[5].GetStringView(), locale, data.AreaDescription);
|
||||
AddLocaleString(fields[6].GetStringView(), locale, data.PortraitGiverText);
|
||||
AddLocaleString(fields[7].GetStringView(), locale, data.PortraitGiverName);
|
||||
AddLocaleString(fields[8].GetStringView(), locale, data.PortraitTurnInText);
|
||||
AddLocaleString(fields[9].GetStringView(), locale, data.PortraitTurnInName);
|
||||
AddLocaleString(fields[10].GetStringView(), locale, data.QuestCompletionLog);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} Quest Template locale strings in {} ms", _questTemplateLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -5567,14 +5570,14 @@ void ObjectMgr::LoadQuestObjectivesLocale()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
QuestObjectivesLocale& data = _questObjectivesLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Description);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.Description);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
@@ -5620,14 +5623,14 @@ void ObjectMgr::LoadQuestGreetingLocales()
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string localeName = fields[2].GetString();
|
||||
std::string_view localeName = fields[2].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
QuestGreetingLocale& data = _questGreetingLocaleStore[type][id];
|
||||
AddLocaleString(fields[3].GetString(), locale, data.Greeting);
|
||||
AddLocaleString(fields[3].GetStringView(), locale, data.Greeting);
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
@@ -5650,14 +5653,14 @@ void ObjectMgr::LoadQuestOfferRewardLocale()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
QuestOfferRewardLocale& data = _questOfferRewardLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.RewardText);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.RewardText);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward locale strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -5678,14 +5681,14 @@ void ObjectMgr::LoadQuestRequestItemsLocale()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
QuestRequestItemsLocale& data = _questRequestItemsLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.CompletionText);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.CompletionText);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} Quest Request Items locale strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -6317,14 +6320,14 @@ void ObjectMgr::LoadPageTextLocales()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
PageTextLocale& data = _pageTextLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Text);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.Text);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} PageText locale strings in {} ms", uint32(_pageTextLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -7703,16 +7706,16 @@ void ObjectMgr::LoadGameObjectLocales()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (!IsValidLocale(locale) || locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
GameObjectLocale& data = _gameObjectLocaleStore[id];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.CastBarCaption);
|
||||
AddLocaleString(fields[4].GetString(), locale, data.Unk1);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.Name);
|
||||
AddLocaleString(fields[3].GetStringView(), locale, data.CastBarCaption);
|
||||
AddLocaleString(fields[4].GetStringView(), locale, data.Unk1);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -9089,7 +9092,7 @@ bool ObjectMgr::LoadTrinityStrings()
|
||||
data.Content.resize(DEFAULT_LOCALE + 1);
|
||||
|
||||
for (int8 i = OLD_TOTAL_LOCALES - 1; i >= 0; --i)
|
||||
AddLocaleString(fields[i + 1].GetString(), LocaleConstant(i), data.Content);
|
||||
AddLocaleString(fields[i + 1].GetStringView(), LocaleConstant(i), data.Content);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
@@ -9536,7 +9539,7 @@ void ObjectMgr::LoadTrainers()
|
||||
Field* fields = trainersResult->Fetch();
|
||||
uint32 trainerId = fields[0].GetUInt32();
|
||||
Trainer::Type trainerType = Trainer::Type(fields[1].GetUInt8());
|
||||
std::string greeting = fields[2].GetString();
|
||||
std::string_view greeting = fields[2].GetStringView();
|
||||
std::vector<Trainer::Spell> spells;
|
||||
auto spellsItr = spellsByTrainer.find(trainerId);
|
||||
if (spellsItr != spellsByTrainer.end())
|
||||
@@ -9545,7 +9548,7 @@ void ObjectMgr::LoadTrainers()
|
||||
spellsByTrainer.erase(spellsItr);
|
||||
}
|
||||
|
||||
_trainers.emplace(std::piecewise_construct, std::forward_as_tuple(trainerId), std::forward_as_tuple(trainerId, trainerType, std::move(greeting), std::move(spells)));
|
||||
_trainers.emplace(std::piecewise_construct, std::forward_as_tuple(trainerId), std::forward_as_tuple(trainerId, trainerType, greeting, std::move(spells)));
|
||||
|
||||
} while (trainersResult->NextRow());
|
||||
}
|
||||
@@ -11484,8 +11487,8 @@ void ObjectMgr::LoadPlayerChoicesLocale()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 choiceId = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
uint32 choiceId = fields[0].GetUInt32();
|
||||
std::string_view localeName = fields[1].GetStringView();
|
||||
|
||||
if (!GetPlayerChoice(choiceId))
|
||||
{
|
||||
@@ -11498,7 +11501,7 @@ void ObjectMgr::LoadPlayerChoicesLocale()
|
||||
continue;
|
||||
|
||||
PlayerChoiceLocale& data = _playerChoiceLocales[choiceId];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Question);
|
||||
AddLocaleString(fields[2].GetStringView(), locale, data.Question);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} Player Choice locale strings in {} ms", _playerChoiceLocales.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -11514,9 +11517,9 @@ void ObjectMgr::LoadPlayerChoicesLocale()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
int32 choiceId = fields[0].GetInt32();
|
||||
int32 responseId = fields[1].GetInt32();
|
||||
std::string localeName = fields[2].GetString();
|
||||
int32 choiceId = fields[0].GetInt32();
|
||||
int32 responseId = fields[1].GetInt32();
|
||||
std::string_view localeName = fields[2].GetStringView();
|
||||
|
||||
auto itr = _playerChoiceLocales.find(choiceId);
|
||||
if (itr == _playerChoiceLocales.end())
|
||||
@@ -11539,12 +11542,12 @@ void ObjectMgr::LoadPlayerChoicesLocale()
|
||||
continue;
|
||||
|
||||
PlayerChoiceResponseLocale& data = itr->second.Responses[responseId];
|
||||
AddLocaleString(fields[3].GetString(), locale, data.Answer);
|
||||
AddLocaleString(fields[4].GetString(), locale, data.Header);
|
||||
AddLocaleString(fields[5].GetString(), locale, data.SubHeader);
|
||||
AddLocaleString(fields[6].GetString(), locale, data.ButtonTooltip);
|
||||
AddLocaleString(fields[7].GetString(), locale, data.Description);
|
||||
AddLocaleString(fields[8].GetString(), locale, data.Confirmation);
|
||||
AddLocaleString(fields[3].GetStringView(), locale, data.Answer);
|
||||
AddLocaleString(fields[4].GetStringView(), locale, data.Header);
|
||||
AddLocaleString(fields[5].GetStringView(), locale, data.SubHeader);
|
||||
AddLocaleString(fields[6].GetStringView(), locale, data.ButtonTooltip);
|
||||
AddLocaleString(fields[7].GetStringView(), locale, data.Description);
|
||||
AddLocaleString(fields[8].GetStringView(), locale, data.Confirmation);
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
|
||||
@@ -1705,7 +1705,7 @@ class TC_GAME_API ObjectMgr
|
||||
// for wintergrasp only
|
||||
GraveyardContainer GraveyardStore;
|
||||
|
||||
static void AddLocaleString(std::string&& value, LocaleConstant localeConstant, std::vector<std::string>& data);
|
||||
static void AddLocaleString(std::string_view value, LocaleConstant localeConstant, std::vector<std::string>& data);
|
||||
static std::string_view GetLocaleString(std::vector<std::string> const& data, LocaleConstant locale)
|
||||
{
|
||||
if (locale < data.size())
|
||||
|
||||
@@ -292,7 +292,7 @@ void Quest::LoadConditionalConditionalQuestDescription(Field* fields)
|
||||
QuestConditionalText& text = itr != _conditionalQuestDescription.end() ? *itr : _conditionalQuestDescription.emplace_back();
|
||||
text.PlayerConditionId = fields[1].GetInt32();
|
||||
text.QuestgiverCreatureId = fields[2].GetInt32();
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, text.Text);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetStringView(), locale, text.Text);
|
||||
}
|
||||
|
||||
void Quest::LoadConditionalConditionalRequestItemsText(Field* fields)
|
||||
@@ -312,7 +312,7 @@ void Quest::LoadConditionalConditionalRequestItemsText(Field* fields)
|
||||
QuestConditionalText& text = itr != _conditionalRequestItemsText.end() ? *itr : _conditionalRequestItemsText.emplace_back();
|
||||
text.PlayerConditionId = fields[1].GetInt32();
|
||||
text.QuestgiverCreatureId = fields[2].GetInt32();
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, text.Text);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetStringView(), locale, text.Text);
|
||||
}
|
||||
|
||||
void Quest::LoadConditionalConditionalOfferRewardText(Field* fields)
|
||||
@@ -332,7 +332,7 @@ void Quest::LoadConditionalConditionalOfferRewardText(Field* fields)
|
||||
QuestConditionalText& text = itr != _conditionalOfferRewardText.end() ? *itr : _conditionalOfferRewardText.emplace_back();
|
||||
text.PlayerConditionId = fields[1].GetInt32();
|
||||
text.QuestgiverCreatureId = fields[2].GetInt32();
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, text.Text);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetStringView(), locale, text.Text);
|
||||
}
|
||||
|
||||
void Quest::LoadConditionalConditionalQuestCompletionLog(Field* fields)
|
||||
@@ -352,7 +352,7 @@ void Quest::LoadConditionalConditionalQuestCompletionLog(Field* fields)
|
||||
QuestConditionalText& text = itr != _conditionalQuestCompletionLog.end() ? *itr : _conditionalQuestCompletionLog.emplace_back();
|
||||
text.PlayerConditionId = fields[1].GetInt32();
|
||||
text.QuestgiverCreatureId = fields[2].GetInt32();
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, text.Text);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetStringView(), locale, text.Text);
|
||||
}
|
||||
|
||||
uint32 Quest::XPValue(Player const* player) const
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user