TrinityCore
Loading...
Searching...
No Matches
InspectPackets.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "InspectPackets.h"
19#include "AzeriteItem.h"
20#include "Item.h"
21#include "PacketOperators.h"
22#include "Player.h"
23
25{
27{
29}
30
32{
33 data << uint32(enchantData.Id);
34 data << uint8(enchantData.Index);
35
36 return data;
37}
38
39ByteBuffer& operator<<(ByteBuffer& data, AzeriteEssenceData const& azeriteEssenceData)
40{
41 data << uint32(azeriteEssenceData.Index);
42 data << uint32(azeriteEssenceData.AzeriteEssenceID);
43 data << uint32(azeriteEssenceData.Rank);
44 data << Bits<1>(azeriteEssenceData.SlotUnlocked);
45 data.FlushBits();
46
47 return data;
48}
49
51{
52 data << itemData.CreatorGUID;
53 data << itemData.Item;
54 data << uint8(itemData.Index);
55 data << Size<uint32>(itemData.AzeritePowers);
56 data << Size<uint32>(itemData.AzeriteEssences);
57
58 if (!itemData.AzeritePowers.empty())
59 data.append(itemData.AzeritePowers.data(), itemData.AzeritePowers.size());
60
61 data << Bits<1>(itemData.Usable);
62 data << BitsSize<4>(itemData.Enchants);
63 data << BitsSize<2>(itemData.Gems);
64 data.FlushBits();
65
66 for (AzeriteEssenceData const& azeriteEssenceData : itemData.AzeriteEssences)
67 data << azeriteEssenceData;
68
69 for (InspectEnchantData const& enchantData : itemData.Enchants)
70 data << enchantData;
71
72 for (Item::ItemGemData const& gem : itemData.Gems)
73 data << gem;
74
75 return data;
76}
77
79{
80 data << SizedString::BitsSize<6>(displayInfo.Name);
81 data << uint8(displayInfo.GenderID);
82 data << uint8(displayInfo.Race);
83 data << uint8(displayInfo.ClassID);
84 data << Size<uint32>(displayInfo.Customizations);
85 data << SizedString::Data(displayInfo.Name);
86
87 for (Character::ChrCustomizationChoice const& customization : displayInfo.Customizations)
88 data << customization;
89
90 return data;
91}
92
94{
95 GUID = player->GetGUID();
97 DisplayInfo.Name = player->GetName();
99 DisplayInfo.Race = player->GetRace();
100 DisplayInfo.ClassID = player->GetClass();
101
102 for (UF::ChrCustomizationChoice const& customization : player->m_playerData->Customizations)
103 DisplayInfo.Customizations.push_back(customization);
104
105 for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
106 if (::Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
107 Items.emplace_back(item, i);
108}
109
111{
112 data << displayInfo.GUID;
113 data << int32(displayInfo.SpecializationID);
114 data << displayInfo.DisplayInfo;
115 data << Size<uint32>(displayInfo.Items);
116
117 for (InspectItemData const& item : displayInfo.Items)
118 data << item;
119
120 return data;
121}
122
124{
125 data << guildData.GuildGUID;
126 data << int32(guildData.NumGuildMembers);
127 data << int32(guildData.AchievementPoints);
128
129 return data;
130}
131
133{
134 data << uint8(bracket.Bracket);
135 data << int32(bracket.RatingID);
136 data << int32(bracket.Rating);
137 data << int32(bracket.Rank);
138 data << int32(bracket.WeeklyPlayed);
139 data << int32(bracket.WeeklyWon);
140 data << int32(bracket.SeasonPlayed);
141 data << int32(bracket.SeasonWon);
142 data << int32(bracket.WeeklyBestRating);
143 data << int32(bracket.LastWeeksBestRating);
144 data << int32(bracket.Tier);
145 data << int32(bracket.WeeklyBestTier);
146 data << int32(bracket.SeasonBestRating);
147 data << uint8(bracket.SeasonBestTierEnum);
148 data << int32(bracket.RoundsSeasonPlayed);
149 data << int32(bracket.RoundsSeasonWon);
150 data << int32(bracket.RoundsWeeklyPlayed);
151 data << int32(bracket.RoundsWeeklyWon);
152 data << Bits<1>(bracket.Disqualified);
153 data.FlushBits();
154
155 return data;
156}
157
159{
160 data << int32(traits.PlayerLevel);
161 data << int32(traits.SpecID);
162 data << traits.ActiveCombatTraits;
163
164 return data;
165}
166
168{
169 CreatorGUID = item->GetCreator();
170
171 Item.Initialize(item);
172 Index = index;
173 Usable = true;
174
175 for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
176 if (uint32 enchId = item->GetEnchantmentId(EnchantmentSlot(i)))
177 Enchants.emplace_back(enchId, i);
178
179 uint8 i = 0;
180 for (UF::SocketedGem const& gemData : item->m_itemData->Gems)
181 {
182 if (gemData.ItemID)
183 {
184 Gems.emplace_back();
185
186 Item::ItemGemData& gem = Gems.back();
187 gem.Slot = i;
188 gem.Item.Initialize(&gemData);
189 }
190 ++i;
191 }
192
193 if (AzeriteItem const* azeriteItem = item->ToAzeriteItem())
194 {
195 if (UF::SelectedAzeriteEssences const* essences = azeriteItem->GetSelectedAzeriteEssences())
196 {
197 for (uint8 slot = 0; slot < essences->AzeriteEssenceID.size(); ++slot)
198 {
199 AzeriteEssences.emplace_back();
200
201 AzeriteEssenceData& essence = AzeriteEssences.back();
202 essence.Index = slot;
203 essence.AzeriteEssenceID = essences->AzeriteEssenceID[slot];
204 if (essence.AzeriteEssenceID)
205 {
206 essence.Rank = azeriteItem->GetEssenceRank(essence.AzeriteEssenceID);
207 essence.SlotUnlocked = true;
208 }
209 else
210 essence.SlotUnlocked = azeriteItem->HasUnlockedEssenceSlot(slot);
211 }
212 }
213 }
214}
215
217{
219 _worldPacket << Size<uint32>(Glyphs);
220 _worldPacket << Size<uint32>(Talents);
221 _worldPacket << Size<uint32>(PvpTalents);
224
225 for (PVPBracketData const& bracket : Bracket)
226 _worldPacket << bracket;
227
234
235 if (!Glyphs.empty())
236 _worldPacket.append(Glyphs.data(), Glyphs.size());
237 if (!Talents.empty())
238 _worldPacket.append(Talents.data(), Talents.size());
239 if (!PvpTalents.empty())
241
245
246 if (GuildData)
248
249 if (AzeriteLevel)
251
252 return &_worldPacket;
253}
254
259}
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
EnchantmentSlot
@ MAX_ENCHANTMENT_SLOT
@ EQUIPMENT_SLOT_END
Definition Player.h:734
constexpr uint8 INVENTORY_SLOT_BAG_0
Definition Player.h:706
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition Util.h:565
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void append(T value)
Definition ByteBuffer.h:131
void FlushBits()
Definition ByteBuffer.h:142
Definition Item.h:185
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition Item.h:314
AzeriteItem * ToAzeriteItem()
Definition Item.h:259
ObjectGuid GetCreator() const
Definition Item.h:207
UF::UpdateField< UF::ItemData, uint32(WowCS::EntityFragment::CGObject), TYPEID_ITEM > m_itemData
Definition Item.h:464
ChrSpecialization GetPrimarySpecialization() const
Definition Player.h:1993
UF::UpdateField< UF::PlayerData, int32(WowCS::EntityFragment::CGObject), TYPEID_PLAYER > m_playerData
Definition Player.h:3047
Gender GetNativeGender() const override
Definition Player.h:1334
Item * GetItemByPos(uint16 pos) const
Definition Player.cpp:9538
uint8 GetClass() const
Definition Unit.h:776
uint8 GetRace() const
Definition Unit.h:773
std::string const & GetName() const
Definition Object.h:342
std::array< PVPBracketData, 9 > Bracket
WorldPacket const * Write() override
std::array< uint16, MAX_PVP_TALENT_SLOTS > PvpTalents
Talent::ClassicTalentInfoUpdate TalentInfo
Optional< InspectGuildData > GuildData
WorldPacket _worldPacket
Definition Packet.h:43
ByteBuffer & operator<<(ByteBuffer &data, InspectEnchantData const &enchantData)
DataWriter< Container > Data(Container const &value)
OptionalInitWriter< T > OptionalInit(Optional< T > const &value)
std::vector< Character::ChrCustomizationChoice > Customizations
std::vector< InspectEnchantData > Enchants
std::vector< Item::ItemGemData > Gems
std::vector< AzeriteEssenceData > AzeriteEssences
InspectItemData(::Item const *item, uint8 index)
void Initialize(::Item const *item)