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 << uint8(itemData.Index);
54 data << Size<uint32>(itemData.AzeritePowers);
55 data << Size<uint32>(itemData.AzeriteEssences);
56
57 if (!itemData.AzeritePowers.empty())
58 data.append(itemData.AzeritePowers.data(), itemData.AzeritePowers.size());
59
60 data << itemData.Item;
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 GUID = player->GetGUID();
82 Name = player->GetName();
83 GenderID = player->GetNativeGender();
84 Race = player->GetRace();
85 ClassID = player->GetClass();
86
87 for (UF::ChrCustomizationChoice const& customization : player->m_playerData->Customizations)
88 Customizations.push_back(customization);
89
90 for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
91 if (::Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
92 Items.emplace_back(item, i);
93}
94
96{
97 data << displayInfo.GUID;
98 data << int32(displayInfo.SpecializationID);
99 data << Size<uint32>(displayInfo.Items);
100 data << SizedString::BitsSize<6>(displayInfo.Name);
101 data << uint8(displayInfo.GenderID);
102 data << uint8(displayInfo.Race);
103 data << uint8(displayInfo.ClassID);
104 data << Size<uint32>(displayInfo.Customizations);
105 data << SizedString::Data(displayInfo.Name);
106
107 for (Character::ChrCustomizationChoice const& customization : displayInfo.Customizations)
108 data << customization;
109
110 for (InspectItemData const& item : displayInfo.Items)
111 data << item;
112
113 return data;
114}
115
117{
118 data << guildData.GuildGUID;
119 data << int32(guildData.NumGuildMembers);
120 data << int32(guildData.AchievementPoints);
121
122 return data;
123}
124
126{
127 data << uint8(bracket.Bracket);
128 data << int32(bracket.RatingID);
129 data << int32(bracket.Rating);
130 data << int32(bracket.Rank);
131 data << int32(bracket.WeeklyPlayed);
132 data << int32(bracket.WeeklyWon);
133 data << int32(bracket.SeasonPlayed);
134 data << int32(bracket.SeasonWon);
135 data << int32(bracket.WeeklyBestRating);
136 data << int32(bracket.LastWeeksBestRating);
137 data << int32(bracket.Tier);
138 data << int32(bracket.WeeklyBestTier);
139 data << int32(bracket.SeasonBestRating);
140 data << uint8(bracket.SeasonBestTierEnum);
141 data << int32(bracket.RoundsSeasonPlayed);
142 data << int32(bracket.RoundsSeasonWon);
143 data << int32(bracket.RoundsWeeklyPlayed);
144 data << int32(bracket.RoundsWeeklyWon);
145 data << Bits<1>(bracket.Disqualified);
146 data.FlushBits();
147
148 return data;
149}
150
152{
153 data << int32(traits.PlayerLevel);
154 data << int32(traits.SpecID);
155 data << traits.ActiveCombatTraits;
156
157 return data;
158}
159
161{
162 CreatorGUID = item->GetCreator();
163
164 Item.Initialize(item);
165 Index = index;
166 Usable = true;
167
168 for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
169 if (uint32 enchId = item->GetEnchantmentId(EnchantmentSlot(i)))
170 Enchants.emplace_back(enchId, i);
171
172 uint8 i = 0;
173 for (UF::SocketedGem const& gemData : item->m_itemData->Gems)
174 {
175 if (gemData.ItemID)
176 {
177 Gems.emplace_back();
178
179 Item::ItemGemData& gem = Gems.back();
180 gem.Slot = i;
181 gem.Item.Initialize(&gemData);
182 }
183 ++i;
184 }
185
186 if (AzeriteItem const* azeriteItem = item->ToAzeriteItem())
187 {
188 if (UF::SelectedAzeriteEssences const* essences = azeriteItem->GetSelectedAzeriteEssences())
189 {
190 for (uint8 slot = 0; slot < essences->AzeriteEssenceID.size(); ++slot)
191 {
192 AzeriteEssences.emplace_back();
193
194 AzeriteEssenceData& essence = AzeriteEssences.back();
195 essence.Index = slot;
196 essence.AzeriteEssenceID = essences->AzeriteEssenceID[slot];
197 if (essence.AzeriteEssenceID)
198 {
199 essence.Rank = azeriteItem->GetEssenceRank(essence.AzeriteEssenceID);
200 essence.SlotUnlocked = true;
201 }
202 else
203 essence.SlotUnlocked = azeriteItem->HasUnlockedEssenceSlot(slot);
204 }
205 }
206 }
207}
208
210{
212 _worldPacket << Size<uint32>(Glyphs);
213 _worldPacket << Size<uint32>(Talents);
214 _worldPacket << Size<uint32>(PvpTalents);
221 if (!Glyphs.empty())
222 _worldPacket.append(Glyphs.data(), Glyphs.size());
223 if (!Talents.empty())
224 _worldPacket.append(Talents.data(), Talents.size());
225 if (!PvpTalents.empty())
227
229
233
234 for (PVPBracketData const& bracket : Bracket)
235 _worldPacket << bracket;
236
237 if (GuildData)
239
240 if (AzeriteLevel)
242
244
245 return &_worldPacket;
246}
247
252}
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:748
#define INVENTORY_SLOT_BAG_0
Definition Player.h:723
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:130
void FlushBits()
Definition ByteBuffer.h:141
Definition Item.h:179
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition Item.h:308
AzeriteItem * ToAzeriteItem()
Definition Item.h:253
ObjectGuid GetCreator() const
Definition Item.h:201
UF::UpdateField< UF::ItemData, uint32(WowCS::EntityFragment::CGObject), TYPEID_ITEM > m_itemData
Definition Item.h:459
ChrSpecialization GetPrimarySpecialization() const
Definition Player.h:2008
UF::UpdateField< UF::PlayerData, int32(WowCS::EntityFragment::CGObject), TYPEID_PLAYER > m_playerData
Definition Player.h:3061
Gender GetNativeGender() const override
Definition Player.h:1350
Item * GetItemByPos(uint16 pos) const
Definition Player.cpp:9630
uint8 GetClass() const
Definition Unit.h:764
uint8 GetRace() const
Definition Unit.h:761
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< InspectEnchantData > Enchants
std::vector< Item::ItemGemData > Gems
std::vector< AzeriteEssenceData > AzeriteEssences
InspectItemData(::Item const *item, uint8 index)
std::vector< Character::ChrCustomizationChoice > Customizations
void Initialize(::Item const *item)