TrinityCore
EquipmentSetPackets.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 "EquipmentSetPackets.h"
19
21{
25
26 return &_worldPacket;
27}
28
30{
31 _worldPacket << uint32(SetData.size());
32
33 for (EquipmentSetInfo::EquipmentSetData const* equipSet : SetData)
34 {
35 _worldPacket << int32(equipSet->Type);
36 _worldPacket << uint64(equipSet->Guid);
37 _worldPacket << uint32(equipSet->SetID);
38 _worldPacket << uint32(equipSet->IgnoreMask);
39
40 for (std::size_t i = 0; i < EQUIPMENT_SET_SLOTS; ++i)
41 {
42 _worldPacket << equipSet->Pieces[i];
43 _worldPacket << int32(equipSet->Appearances[i]);
44 }
45
46 _worldPacket.append(equipSet->Enchants.data(), equipSet->Enchants.size());
47
48 _worldPacket << int32(equipSet->SecondaryShoulderApparanceID);
49 _worldPacket << int32(equipSet->SecondaryShoulderSlot);
50 _worldPacket << int32(equipSet->SecondaryWeaponAppearanceID);
51 _worldPacket << int32(equipSet->SecondaryWeaponSlot);
52
53 _worldPacket.WriteBit(equipSet->AssignedSpecIndex != -1);
54 _worldPacket.WriteBits(equipSet->SetName.length(), 8);
55 _worldPacket.WriteBits(equipSet->SetIcon.length(), 9);
56 _worldPacket.FlushBits();
57
58 if (equipSet->AssignedSpecIndex != -1)
59 _worldPacket << int32(equipSet->AssignedSpecIndex);
60
61 _worldPacket.WriteString(equipSet->SetName);
62 _worldPacket.WriteString(equipSet->SetIcon);
63 }
64
65 return &_worldPacket;
66}
67
69{
70 Set.Type = _worldPacket.read<EquipmentSetInfo::EquipmentSetType, int32>();
71 _worldPacket >> Set.Guid;
72 _worldPacket >> Set.SetID;
73 _worldPacket >> Set.IgnoreMask;
74
75 for (uint8 i = 0; i < EQUIPMENT_SET_SLOTS; ++i)
76 {
77 _worldPacket >> Set.Pieces[i];
78 _worldPacket >> Set.Appearances[i];
79 }
80
81 _worldPacket >> Set.Enchants[0];
82 _worldPacket >> Set.Enchants[1];
83
84 _worldPacket >> Set.SecondaryShoulderApparanceID;
85 _worldPacket >> Set.SecondaryShoulderSlot;
86 _worldPacket >> Set.SecondaryWeaponAppearanceID;
87 _worldPacket >> Set.SecondaryWeaponSlot;
88
89 bool hasSpecIndex = _worldPacket.ReadBit();
90
91 uint32 setNameLength = _worldPacket.ReadBits(8);
92 uint32 setIconLength = _worldPacket.ReadBits(9);
93
94 if (hasSpecIndex)
95 _worldPacket >> Set.AssignedSpecIndex;
96
97 Set.SetName = _worldPacket.ReadString(setNameLength);
98 Set.SetIcon = _worldPacket.ReadString(setIconLength);
99}
100
102{
103 _worldPacket >> ID;
104}
105
107{
108 _worldPacket >> Inv;
109
110 for (uint8 i = 0; i < EQUIPMENT_SET_SLOTS; ++i)
111 {
112 _worldPacket >> Items[i].Item;
113 _worldPacket >> Items[i].ContainerSlot;
114 _worldPacket >> Items[i].Slot;
115 }
116
117 _worldPacket >> GUID;
118}
119
121{
122 _worldPacket << uint64(GUID);
123 _worldPacket << uint8(Reason);
124
125 return &_worldPacket;
126}
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
#define EQUIPMENT_SET_SLOTS
Definition: EquipmentSet.h:34
WorldPacket _worldPacket
Definition: Packet.h:43
Data sent in EquipmentSet related packets.
Definition: EquipmentSet.h:46