AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
LinkValidator< LinkTags::item > Struct Reference

Static Public Member Functions

static bool IsTextValid (ItemLinkData const &data, std::string_view text)
 
static bool IsColorValid (ItemLinkData const &data, HyperlinkColor c)
 

Detailed Description

Member Function Documentation

◆ IsColorValid()

static bool LinkValidator< LinkTags::item >::IsColorValid ( ItemLinkData const &  data,
HyperlinkColor  c 
)
inlinestatic
174 {
175 return c == ItemQualityColors[data.Item->Quality];
176 }
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition: SharedDefines.h:353

References Acore::Hyperlinks::ItemLinkData::Item, ItemQualityColors, and ItemTemplate::Quality.

◆ IsTextValid()

static bool LinkValidator< LinkTags::item >::IsTextValid ( ItemLinkData const &  data,
std::string_view  text 
)
inlinestatic
135 {
136 ItemLocale const* locale = sObjectMgr->GetItemLocale(data.Item->ItemId);
137
138 std::array<char const*, 16> const* randomSuffixes = nullptr;
139
140 if (data.RandomProperty)
141 randomSuffixes = &data.RandomProperty->Name;
142 else if (data.RandomSuffix)
143 randomSuffixes = &data.RandomSuffix->Name;
144
145 if (data.IsBuggedInspectLink) /* DBC lookup will have failed on the client, so the link should've arrived without suffix */
146 randomSuffixes = nullptr;
147
148 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
149 {
150 if (!locale && i != DEFAULT_LOCALE)
151 continue;
152
153 std::string_view name = (i == DEFAULT_LOCALE) ? data.Item->Name1 : ObjectMgr::GetLocaleString(locale->Name, i);
154 if (name.empty())
155 continue;
156
157 if (randomSuffixes)
158 {
159 std::string_view randomSuffix((*randomSuffixes)[i]);
160 if ((!randomSuffix.empty()) &&
161 (text.length() == (name.length() + 1 + randomSuffix.length())) &&
162 (text.substr(0, name.length()) == name) &&
163 (text[name.length()] == ' ') &&
164 (text.substr(name.length() + 1) == randomSuffix))
165 return true;
166 }
167 else if (text == name)
168 return true;
169 }
170 return false;
171 }
@ TOTAL_LOCALES
Definition: Common.h:76
#define DEFAULT_LOCALE
Definition: Common.h:79
std::uint8_t uint8
Definition: Define.h:109
#define sObjectMgr
Definition: ObjectMgr.h:1623
Definition: ItemTemplate.h:838
std::vector< std::string > Name
Definition: ItemTemplate.h:839
static std::string_view GetLocaleString(std::vector< std::string > const &data, std::size_t locale)
Definition: ObjectMgr.h:1405

References DEFAULT_LOCALE, ObjectMgr::GetLocaleString(), Acore::Hyperlinks::ItemLinkData::IsBuggedInspectLink, Acore::Hyperlinks::ItemLinkData::Item, ItemTemplate::ItemId, ItemLocale::Name, ItemRandomPropertiesEntry::Name, ItemRandomSuffixEntry::Name, ItemTemplate::Name1, Acore::Hyperlinks::ItemLinkData::RandomProperty, Acore::Hyperlinks::ItemLinkData::RandomSuffix, sObjectMgr, and TOTAL_LOCALES.