TrinityCore
Loading...
Searching...
No Matches
BattlePetPackets.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 "BattlePetPackets.h"
19#include "PacketOperators.h"
20
22{
24{
25 data << (slot.Pet.Guid.IsEmpty() ? ObjectGuid::Create<HighGuid::BattlePet>(0) : slot.Pet.Guid);
26 data << uint32(slot.CollarID);
27 data << uint8(slot.Index);
28 data << Bits<1>(slot.Locked);
29 data.FlushBits();
30
31 return data;
32}
33
35{
36 data << owner.Guid;
37 data << uint32(owner.PlayerVirtualRealm);
38 data << uint32(owner.PlayerNativeRealm);
39
40 return data;
41}
42
44{
45 data << pet.Guid;
46 data << uint32(pet.Species);
47 data << uint32(pet.CreatureID);
48 data << uint32(pet.DisplayID);
49 data << uint16(pet.Breed);
50 data << uint16(pet.Level);
51 data << uint16(pet.Exp);
52 data << uint16(pet.Flags);
53 data << uint32(pet.Power);
54 data << uint32(pet.Health);
55 data << uint32(pet.MaxHealth);
56 data << uint32(pet.Speed);
57 data << uint8(pet.Quality);
58 data << SizedString::BitsSize<7>(pet.Name);
59 data << OptionalInit(pet.OwnerInfo);
60 data << Bits<1>(pet.NoRename);
61 data.FlushBits();
62
63 data << SizedString::Data(pet.Name);
64
65 if (pet.OwnerInfo)
66 data << *pet.OwnerInfo;
67
68 return data;
69}
70
72{
74 _worldPacket << Size<uint32>(Slots);
75 _worldPacket << Size<uint32>(Pets);
76
77 for (BattlePetSlot const& slot : Slots)
78 _worldPacket << slot;
79
80 for (BattlePet const& pet : Pets)
81 _worldPacket << pet;
82
83 _worldPacket << Bits<1>(HasJournalLock);
85
86 return &_worldPacket;
87}
88
90{
91 _worldPacket << Size<uint32>(Pets);
92
93 for (BattlePet const& pet : Pets)
94 _worldPacket << pet;
95
96 _worldPacket << Bits<1>(PetAdded);
98
99 return &_worldPacket;
100}
101
103{
104 _worldPacket << Size<uint32>(Slots);
105
106 for (BattlePetSlot const& slot : Slots)
107 _worldPacket << slot;
108
109 _worldPacket << Bits<1>(NewSlot);
110 _worldPacket << Bits<1>(AutoSlotted);
112
113 return &_worldPacket;
114}
115
121
123{
125 _worldPacket >> SizedString::BitsSize<7>(Name);
127
129
130 if (DeclinedNames)
131 {
132 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
133 _worldPacket >> SizedString::BitsSize<7>(DeclinedNames->name[i]);
134
135 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
137 }
138}
139
145
147{
151
152 _worldPacket << Bits<1>(Allow);
153
154 if (Allow)
155 {
156 _worldPacket << SizedString::BitsSize<8>(Name);
157 _worldPacket << Bits<1>(HasDeclined);
158
159 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
160 _worldPacket << SizedString::BitsSize<7>(DeclinedNames.name[i]);
161
163
164 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
166
168 }
169 else
171
172 return &_worldPacket;
173}
174
179
186
191
193{
195}
196
198{
200
201 return &_worldPacket;
202}
203
205{
206 _worldPacket << Bits<4>(Result);
208
209 return &_worldPacket;
210}
211
216
221}
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
#define MAX_DECLINED_NAME_CASES
void FlushBits()
Definition ByteBuffer.h:142
bool IsEmpty() const
Definition ObjectGuid.h:362
WorldPacket const * Write() override
std::vector< std::reference_wrapper< BattlePet > > Pets
std::vector< std::reference_wrapper< BattlePetSlot > > Slots
std::unique_ptr< DeclinedName > DeclinedNames
std::vector< std::reference_wrapper< BattlePet const > > Pets
WorldPacket _worldPacket
Definition Packet.h:43
ByteBuffer & operator<<(ByteBuffer &data, BattlePetSlot const &slot)
DataWriter< Container > Data(Container const &value)
OptionalInitWriter< T > OptionalInit(Optional< T > const &value)
std::string name[MAX_DECLINED_NAME_CASES]
Optional< BattlePetOwnerInfo > OwnerInfo