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
175 {
176 return c == ItemQualityColors[data.Item->Quality];
177 }
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
136 {
137 ItemLocale const* locale = sObjectMgr->GetItemLocale(data.Item->ItemId);
138
139 std::array<char const*, 16> const* randomSuffixes = nullptr;
140
141 if (data.RandomProperty)
142 randomSuffixes = &data.RandomProperty->Name;
143 else if (data.RandomSuffix)
144 randomSuffixes = &data.RandomSuffix->Name;
145
146 if (data.IsBuggedInspectLink) /* DBC lookup will have failed on the client, so the link should've arrived without suffix */
147 randomSuffixes = nullptr;
148
149 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
150 {
151 if (!locale && i != DEFAULT_LOCALE)
152 continue;
153
154 std::string_view name = (i == DEFAULT_LOCALE) ? data.Item->Name1 : ObjectMgr::GetLocaleString(locale->Name, i);
155 if (name.empty())
156 continue;
157
158 if (randomSuffixes)
159 {
160 std::string_view randomSuffix((*randomSuffixes)[i]);
161 if ((!randomSuffix.empty()) &&
162 (text.length() == (name.length() + 1 + randomSuffix.length())) &&
163 (text.substr(0, name.length()) == name) &&
164 (text[name.length()] == ' ') &&
165 (text.substr(name.length() + 1) == randomSuffix))
166 return true;
167 }
168 else if (text == name)
169 return true;
170 }
171 return false;
172 }
@ 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:1635
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:1407

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.