AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::Hyperlinks::LinkTags::item Struct Reference

#include "Hyperlinks.h"

Public Types

using value_type = ItemLinkData const &
 

Static Public Member Functions

static constexpr std::string_view tag ()
 
static bool StoreTo (ItemLinkData &val, std::string_view data)
 

Detailed Description

Member Typedef Documentation

◆ value_type

Member Function Documentation

◆ StoreTo()

bool Acore::Hyperlinks::LinkTags::item::StoreTo ( ItemLinkData val,
std::string_view  data 
)
static
122{
124 uint32 itemId, dummy;
125
126 if (!t.TryConsumeTo(itemId))
127 return false;
128
129 val.Item = sObjectMgr->GetItemTemplate(itemId);
130 val.IsBuggedInspectLink = false;
131
132 // randomPropertyId is actually a int16 in the client
133 // positive values index ItemRandomSuffix.dbc, while negative values index ItemRandomProperties.dbc
134 // however, there is also a client bug in inspect packet handling that causes a int16 to be cast to uint16, then int32 (dropping sign extension along the way)
135 // this results in the wrong value being sent in the link; DBC lookup clientside fails, so it sends the link without suffix
136 // to detect and allow these invalid links, we first read randomPropertyId as a full int32
137 int32 randomPropertyId;
138 if (!(val.Item && t.TryConsumeTo(val.EnchantId) && t.TryConsumeTo(val.GemEnchantId[0]) && t.TryConsumeTo(val.GemEnchantId[1]) &&
139 t.TryConsumeTo(val.GemEnchantId[2]) && t.TryConsumeTo(dummy) && t.TryConsumeTo(randomPropertyId) && t.TryConsumeTo(val.RandomSuffixBaseAmount) &&
140 t.TryConsumeTo(val.RenderLevel) && t.IsEmpty() && !dummy))
141 return false;
142
143 if ((static_cast<int32>(std::numeric_limits<int16>::max()) < randomPropertyId) && (randomPropertyId <= std::numeric_limits<uint16>::max()))
144 { // this is the bug case, the id we received is actually static_cast<uint16>(i16RandomPropertyId)
145 randomPropertyId = static_cast<int16>(randomPropertyId);
146 val.IsBuggedInspectLink = true;
147 }
148
149 if (randomPropertyId < 0)
150 {
151 if (!val.Item->RandomSuffix)
152 return false;
153
154 if (randomPropertyId < -static_cast<int32>(sItemRandomSuffixStore.GetNumRows()))
155 return false;
156
157 if (ItemRandomSuffixEntry const* suffixEntry = sItemRandomSuffixStore.LookupEntry(-randomPropertyId))
158 {
159 val.RandomSuffix = suffixEntry;
160 val.RandomProperty = nullptr;
161 }
162 else
163 return false;
164 }
165 else if (randomPropertyId > 0)
166 {
167 if (!val.Item->RandomProperty)
168 return false;
169
170 if (ItemRandomPropertiesEntry const* propEntry = sItemRandomPropertiesStore.LookupEntry(randomPropertyId))
171 {
172 val.RandomSuffix = nullptr;
173 val.RandomProperty = propEntry;
174 }
175 else
176 return false;
177 }
178 else
179 {
180 val.RandomSuffix = nullptr;
181 val.RandomProperty = nullptr;
182 }
183
184 if ((val.RandomSuffix && !val.RandomSuffixBaseAmount) || (val.RandomSuffixBaseAmount && !val.RandomSuffix))
185 return false;
186
187 return true;
188}
std::int32_t int32
Definition: Define.h:103
std::uint32_t uint32
Definition: Define.h:107
std::int16_t int16
Definition: Define.h:104
#define sObjectMgr
Definition: ObjectMgr.h:1635
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
Definition: HyperlinkTags.cpp:28
Definition: DBCStructure.h:1206
Definition: DBCStructure.h:1216

References Acore::Hyperlinks::ItemLinkData::EnchantId, Acore::Hyperlinks::ItemLinkData::GemEnchantId, Acore::Hyperlinks::ItemLinkData::IsBuggedInspectLink, HyperlinkDataTokenizer::IsEmpty(), Acore::Hyperlinks::ItemLinkData::Item, Acore::Hyperlinks::ItemLinkData::RandomProperty, ItemTemplate::RandomProperty, Acore::Hyperlinks::ItemLinkData::RandomSuffix, ItemTemplate::RandomSuffix, Acore::Hyperlinks::ItemLinkData::RandomSuffixBaseAmount, Acore::Hyperlinks::ItemLinkData::RenderLevel, sItemRandomPropertiesStore, sItemRandomSuffixStore, sObjectMgr, and HyperlinkDataTokenizer::TryConsumeTo().

◆ tag()

static constexpr std::string_view Acore::Hyperlinks::LinkTags::item::tag ( )
inlinestaticconstexpr
183{ return "item"; }