TrinityCore
PetPackets.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 "PetPackets.h"
19
21{
29 _worldPacket << uint32(Actions.size());
30 _worldPacket << uint32(Cooldowns.size());
32
33 for (uint32 action : Actions)
34 _worldPacket << uint32(action);
35
36 for (PetSpellCooldown const& cooldown : Cooldowns)
37 {
38 _worldPacket << int32(cooldown.SpellID);
39 _worldPacket << int32(cooldown.Duration);
40 _worldPacket << int32(cooldown.CategoryDuration);
41 _worldPacket << float(cooldown.ModRate);
42 _worldPacket << uint16(cooldown.Category);
43 }
44
45 for (PetSpellHistory const& history : SpellHistory)
46 {
47 _worldPacket << int32(history.CategoryID);
48 _worldPacket << int32(history.RecoveryTime);
49 _worldPacket << float(history.ChargeModRate);
50 _worldPacket << int8(history.ConsumedCharges);
51 }
52
53 return &_worldPacket;
54}
55
57{
58 _worldPacket << uint8(Result);
59
60 return &_worldPacket;
61}
62
64{
65 _worldPacket << uint32(Spells.size());
66 for (uint32 spell : Spells)
67 _worldPacket << int32(spell);
68 return &_worldPacket;
69}
70
72{
73 _worldPacket << uint32(Spells.size());
74 for (uint32 spell : Spells)
75 _worldPacket << int32(spell);
76 return &_worldPacket;
77}
78
80{
81 _worldPacket << uint8(Result);
82 _worldPacket << RenameData.PetGUID;
83 _worldPacket << int32(RenameData.PetNumber);
84
85 _worldPacket << uint8(RenameData.NewName.length());
86
87 _worldPacket.WriteBit(RenameData.DeclinedNames.has_value());
88
89 if (RenameData.DeclinedNames)
90 {
91 for (int32 i = 0; i < MAX_DECLINED_NAME_CASES; i++)
92 _worldPacket.WriteBits(RenameData.DeclinedNames->name[i].length(), 7);
93
94 for (int32 i = 0; i < MAX_DECLINED_NAME_CASES; i++)
95 _worldPacket << RenameData.DeclinedNames->name[i];
96 }
97
98 _worldPacket.WriteString(RenameData.NewName);
99 return &_worldPacket;
100}
101
103{
104 _worldPacket >> RenameData.PetGUID;
105 _worldPacket >> RenameData.PetNumber;
106
107 uint8 nameLen = _worldPacket.ReadBits(8);
108
109 if (_worldPacket.ReadBit())
110 {
111 RenameData.DeclinedNames.emplace();
113 for (int32 i = 0; i < MAX_DECLINED_NAME_CASES; i++)
114 count[i] = _worldPacket.ReadBits(7);
115
116 for (int32 i = 0; i < MAX_DECLINED_NAME_CASES; i++)
117 RenameData.DeclinedNames->name[i] = _worldPacket.ReadString(count[i]);
118 }
119
120 RenameData.NewName = _worldPacket.ReadString(nameLen);
121}
122
124{
125 _worldPacket >> PetGUID;
126
127 _worldPacket >> Action;
128 _worldPacket >> TargetGUID;
129
130 _worldPacket >> ActionPosition;
131}
132
134{
135 _worldPacket >> PetGUID;
136}
137
139{
140 _worldPacket >> PetGUID;
141
142 _worldPacket >> Index;
143 _worldPacket >> Action;
144}
145
147{
148 _worldPacket >> Pet;
149}
150
152{
153 _worldPacket >> PetGUID;
154 _worldPacket >> SpellID;
155 AutocastEnabled = _worldPacket.ReadBit();
156}
157
159{
160 _worldPacket >> CritterGUID;
161}
162
164{
165 _worldPacket >> PetGUID;
166 _worldPacket >> SpellID;
167}
168
170{
171 _worldPacket << uint16(SpecID);
172
173 return &_worldPacket;
174}
175
177{
178 _worldPacket << int32(SpellID);
179 _worldPacket << uint8(Response);
180
181 return &_worldPacket;
182}
183
185{
186 _worldPacket << UnitGUID;
187 _worldPacket << int32(Action);
188
189 return &_worldPacket;
190}
191
193{
194 _worldPacket << uint8(Result);
195
196 return &_worldPacket;
197}
198
200{
201 _worldPacket << PetGUID;
202 _worldPacket << uint16(CommandState | Flag << 8);
203 _worldPacket << uint8(ReactState);
204
205 return &_worldPacket;
206}
Actions
uint8_t uint8
Definition: Define.h:144
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
Spells
Definition: PlayerAI.cpp:32
#define MAX_DECLINED_NAME_CASES
Definition: UnitDefines.h:484
Action
void append(T value)
Definition: ByteBuffer.h:143
Definition: Pet.h:40
WorldPacket _worldPacket
Definition: Packet.h:43
WorldPacket const * Write() override
WorldPacket const * Write() override
Definition: PetPackets.cpp:184
WorldPacket const * Write() override
Definition: PetPackets.cpp:63
WorldPacket const * Write() override
Definition: PetPackets.cpp:199
WorldPacket const * Write() override
Definition: PetPackets.cpp:79
std::array< int, 10 > ActionButtons
Definition: PetPackets.h:115
std::vector< PetSpellCooldown > Cooldowns
Definition: PetPackets.h:118
WorldPacket const * Write() override
Definition: PetPackets.cpp:20
WorldPacket const * Write() override
Definition: PetPackets.cpp:56
WorldPacket const * Write() override
Definition: PetPackets.cpp:192
WorldPacket const * Write() override
Definition: PetPackets.cpp:71
WorldPacket const * Write() override
Definition: PetPackets.cpp:169
boost::beast::http::response< ResponseBody > Response
Definition: HttpCommon.h:31