35 return data.starts_with(
"IQ") && q < MAX_ITEM_QUALITY && Trinity::StringTo<uint32>(
data.substr(2)) ==
uint32(q);
41 std::string_view color;
43 std::string_view data;
44 std::string_view text;
47 if (!str.starts_with(
"|c"sv))
59 if (
size_t endOfColor = str.find(
":"sv); endOfColor != std::string_view::npos)
61 color = str.substr(0, endOfColor);
62 str.remove_prefix(endOfColor + 1);
70 color = str.substr(0, 8);
74 if (!str.starts_with(
"|H"sv))
79 if (
size_t delimPos = str.find(
'|'); delimPos != std::string_view::npos)
81 tag = str.substr(0, delimPos);
82 str.remove_prefix(delimPos+1);
88 if (
size_t dataStart = tag.find(
':'); dataStart != std::string_view::npos)
90 data = tag.substr(dataStart+1);
91 tag = tag.substr(0, dataStart);
95 if (!str.starts_with(
'h'))
103 size_t openBrackets = 0;
104 for (
size_t nameItr = 0; nameItr < str.length(); ++nameItr)
106 switch (str[nameItr])
120 text = str.substr(1, nameItr - 1);
121 str.remove_prefix(nameItr + 1);
127 if (!str.starts_with(
"|h|r"sv))
129 str.remove_prefix(4);
132 return { str, color, tag, data, text };
138 static bool IsTextValid(
typename T::value_type, std::string_view) {
return true; }
148 return creatureTemplate->
Name == text;
152 std::string
const& name = (i ==
DEFAULT_LOCALE) ? creatureTemplate->Name : locale->
Name[i];
168 return IsTextValid(data.
Spell, text);
315 if ((*name)[i] == text)
341 if (bounds.first == bounds.second)
344 for (
auto pair = bounds.first; pair != bounds.second; ++pair)
347 ? pair->second->SkillupSkillLineID
348 : pair->second->SkillLine);
354 std::string_view skillName = skill->
DisplayName[i];
355 std::string_view spellName = (*info->
SpellName)[i];
356 if ((text.length() == (skillName.length() + 2 + spellName.length())) &&
357 (text.substr(0, skillName.length()) == skillName) &&
358 (text.substr(skillName.length(), 2) ==
": ") &&
359 (text.substr(skillName.length() + 2) == spellName))
399 if (ability->
Name[i] == text)
447 static constexpr std::array<std::string_view, 6> CRAFTING_QUALITY_ICON =
450 " |A:Professions-ChatIcon-Quality-Tier1:17:15::1|a",
451 " |A:Professions-ChatIcon-Quality-Tier2:17:23::1|a",
452 " |A:Professions-ChatIcon-Quality-Tier3:17:18::1|a",
453 " |A:Professions-ChatIcon-Quality-Tier4:17:17::1|a",
454 " |A:Professions-ChatIcon-Quality-Tier5:17:17::1|a",
465 if (craftingQualityIdItr != data.
Modifiers.end())
466 craftingQualityId = craftingQualityIdItr->Value;
468 return IsTextValid(data.
Item, suffixStrings, craftingQualityId, text);
474 if (!craftingQualityId)
476 craftingQualityId = modifiedCraftingItemEntry->CraftingQualityID;
478 std::string_view craftingQualityIcon = CRAFTING_QUALITY_ICON[0];
479 if (craftingQualityId)
481 if (craftingQualityEntry->QualityTier < std::ranges::ssize(CRAFTING_QUALITY_ICON))
482 craftingQualityIcon = CRAFTING_QUALITY_ICON[craftingQualityEntry->QualityTier];
496 if (!toValidate.starts_with(name))
499 toValidate.remove_prefix(name.length());
502 if (toValidate.length() < suffix->length() + 1)
505 if (toValidate[0] !=
' ')
508 toValidate.remove_prefix(1);
509 if (!toValidate.starts_with(*suffix))
512 toValidate.remove_prefix(suffix->length());
515 if (!toValidate.starts_with(craftingQualityIcon))
518 toValidate.remove_prefix(craftingQualityIcon.length());
519 return toValidate.empty();
557 size_t validateStartPos = text.find(
": ");
558 if (validateStartPos == std::string_view::npos)
561 text.remove_prefix(validateStartPos);
562 text.remove_prefix(2);
567 if (expectedText == text)
683 if (!name.empty() && (text == name))
751 if (enchantment->
Name[i] == text)
775 if (expectedText.c_str() == text)
778 else if (set->
Name[i] == text)
804template <
typename TAG>
807 std::decay_t<typename TAG::value_type> t;
808 if (!TAG::StoreTo(t, info.
data))
825#define TryValidateAs(T) do { if (info.tag == T::tag()) return ValidateAs<T>(info); } while (0)
829 using namespace LinkTags;
885 std::string_view::size_type pos = 0;
886 while ((pos = str.find(
'|', pos)) != std::string::npos)
889 if (pos == str.length())
891 char next = str[pos];
892 if (next ==
'H' || next ==
'h' || next ==
'c' || next ==
'A' || next ==
'a' || next ==
'r' || next ==
'|')
906 std::string::size_type pos;
907 while ((pos = str.find(
'|')) != std::string::npos)
909 if (str[pos + 1] ==
'|')
911 str = str.substr(pos + 2);
DB2Storage< ItemNameDescriptionEntry > sItemNameDescriptionStore("ItemNameDescription.db2", &ItemNameDescriptionLoadInfo::Instance)
DB2Storage< SkillLineEntry > sSkillLineStore("SkillLine.db2", &SkillLineLoadInfo::Instance)
DB2Storage< ModifiedCraftingItemEntry > sModifiedCraftingItemStore("ModifiedCraftingItem.db2", &ModifiedCraftingItemLoadInfo::Instance)
DB2Storage< CraftingQualityEntry > sCraftingQualityStore("CraftingQuality.db2", &CraftingQualityLoadInfo::Instance)
static bool ValidateAs(HyperlinkInfo const &info)
static bool ValidateLinkInfo(HyperlinkInfo const &info)
static bool IsCreatureNameValid(uint32 creatureId, std::string_view text)
@ ITEM_MODIFIER_CRAFTING_QUALITY_ID
@ ITEM_FLAG3_HIDE_NAME_SUFFIX
std::optional< T > Optional
Optional helper class to wrap optional values within.
uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY]
@ CHAT_LINK_COLOR_NEUTRAL
@ CHAT_LINK_COLOR_JOURNAL
@ CHAT_LINK_COLOR_TRANSMOG
@ CHAT_LINK_COLOR_ACHIEVEMENT
@ CHAT_LINK_COLOR_ARTIFACT_POWER
@ CHAT_LINK_COLOR_GARR_ABILITY
@ CHAT_LINK_COLOR_BATTLE_PET_ABIL
@ CHAT_LINK_COLOR_INSTANCE_LOCK
@ CHAT_LINK_COLOR_ENCHANT
uint32 constexpr QuestDifficultyColors[MAX_QUEST_DIFFICULTY]
size_t constexpr MAX_QUEST_DIFFICULTY
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
static std::string_view GetLocaleString(std::vector< std::string > const &data, LocaleConstant locale)
std::string const & GetLogTitle() const
uint32 GetQuestId() const
LocalizedString const * SpellName
@ CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY
bool TC_GAME_API CheckAllLinks(std::string_view str)
HyperlinkInfo TC_GAME_API ParseSingleHyperlink(std::string_view str)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.
std::vector< std::string > Name
LocalizedString ContainerName
LocalizedString Description
bool HasFlag(ItemFlags flag) const
char const * GetName(LocaleConstant locale) const
static bool IsTextValid(typename T::value_type, std::string_view)
static bool IsColorValid(typename T::value_type, HyperlinkColor)
LocalizedString ActivityName
std::vector< std::string > LogTitle
LocalizedString DisplayName
LocalizedString HordeName
int32 ItemNameDescriptionID
AchievementEntry const * Achievement
ArtifactPowerRankEntry const * ArtifactPower
AzeriteEssenceEntry const * Essence
BattlePetAbilityEntry const * Ability
BattlePetSpeciesEntry const * Species
CurrencyContainerEntry const * Container
CurrencyTypesEntry const * Currency
GarrFollowerEntry const * Follower
GarrMissionEntry const * Mission
bool operator==(uint32 c) const
std::string_view const data
std::string_view const text
std::string_view const tail
HyperlinkColor const color
std::vector< Modifier > Modifiers
ItemNameDescriptionEntry const * Suffix
ItemTemplate const * Item
LocalizedString const * ExpectedText
MapChallengeModeEntry const * Map