33inline uint8 toHex(
char c) {
return (c >=
'0' && c <=
'9') ? c -
'0' + 0x10 : (c >=
'a' && c <=
'f') ? c -
'a' + 0x1a : 0x00; }
39 std::string_view data;
40 std::string_view text;
43 if (str.substr(0, 2) !=
"|c")
50 for (
uint8 i = 0; i < 8; ++i)
53 color = (color << 4) | (hex & 0xf);
59 if (str.substr(0, 2) !=
"|H")
64 if (
size_t delimPos = str.find(
'|'); delimPos != std::string_view::npos)
66 tag = str.substr(0, delimPos);
67 str.remove_prefix(delimPos+1);
73 if (
size_t dataStart = tag.find(
':'); dataStart != std::string_view::npos)
75 data = tag.substr(dataStart+1);
76 tag = tag.substr(0, dataStart);
80 if (str.substr(0, 1) !=
"h")
84 if (
size_t end = str.find(
'|'); end != std::string_view::npos)
87 if (str.substr(end, 4) !=
"|h|r")
90 if ((str[0] !=
'[') || (str[end - 1] !=
']'))
92 text = str.substr(1, end - 2);
94 str = str.substr(end + 4);
100 return { str, color, tag, data, text };
106 static bool IsTextValid(
typename T::value_type, std::string_view) {
return true; }
116 return creatureTemplate->Name == text;
120 std::string
const& name = (i ==
DEFAULT_LOCALE) ? creatureTemplate->Name : locale->
Name[i];
259 if ((*name)[i] == text)
278 if (bounds.first == bounds.second)
281 for (
auto pair = bounds.first; pair != bounds.second; ++pair)
284 ? pair->second->SkillupSkillLineID
285 : pair->second->SkillLine);
291 std::string_view skillName = skill->
DisplayName[i];
292 std::string_view spellName = (*info->
SpellName)[i];
293 if ((text.length() == (skillName.length() + 2 + spellName.length())) &&
294 (text.substr(0, skillName.length()) == skillName) &&
295 (text.substr(skillName.length(), 2) ==
": ") &&
296 (text.substr(skillName.length() + 2) == spellName))
330 if (ability->
Name[i] == text)
391 std::string_view name = itemTemplate->
GetName(i);
396 std::string_view suffix = (*suffixStrings)[i];
399 (text.length() == (name.length() + 1 + suffix.length())) &&
400 (text.substr(0, name.length()) == name) &&
401 (text[name.length()] ==
' ') &&
402 (text.substr(name.length() + 1) == suffix)
406 else if (text == name)
441 size_t validateStartPos = text.find(
": ");
442 if (validateStartPos == std::string_view::npos)
445 text.remove_prefix(validateStartPos);
446 text.remove_prefix(2);
451 if (expectedText == text)
484 if (!name.empty() && (text == name))
612 if (enchantment->
Name[i] == text)
636 if (expectedText.c_str() == text)
639 else if (set->
Name[i] == text)
665template <
typename TAG>
668 std::decay_t<typename TAG::value_type> t;
669 if (!TAG::StoreTo(t, info.
data))
686#define TryValidateAs(T) do { if (info.tag == T::tag()) return ValidateAs<T>(info); } while (0)
690 using namespace LinkTags;
744 std::string_view::size_type pos = 0;
745 while ((pos = str.find(
'|', pos)) != std::string::npos)
748 if (pos == str.length())
750 char next = str[pos];
751 if (next ==
'H' || next ==
'h' || next ==
'c' || next ==
'r' || next ==
'|')
765 std::string::size_type pos;
766 while ((pos = str.find(
'|')) != std::string::npos)
768 if (str[pos + 1] ==
'|')
770 str = str.substr(pos + 2);
DB2Storage< ItemNameDescriptionEntry > sItemNameDescriptionStore("ItemNameDescription.db2", &ItemNameDescriptionLoadInfo::Instance)
DB2Storage< SkillLineEntry > sSkillLineStore("SkillLine.db2", &SkillLineLoadInfo::Instance)
static bool ValidateAs(HyperlinkInfo const &info)
static bool ValidateLinkInfo(HyperlinkInfo const &info)
static bool IsCreatureNameValid(uint32 creatureId, std::string_view text)
@ ITEM_FLAG3_HIDE_NAME_SUFFIX
if(posix_memalign(&__mallocedMemory, __align, __size)) return NULL
uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY]
@ 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)
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)
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
std::string_view const data
std::string_view const text
std::string_view const tail
HyperlinkColor const color
ItemNameDescriptionEntry const * Suffix
ItemTemplate const * Item
LocalizedString const * ExpectedText
MapChallengeModeEntry const * Map