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 _worldPacket << Bits<1>(HasJournalLock);
78
79 for (BattlePetSlot const& slot : Slots)
80 _worldPacket << slot;
81
82 for (BattlePet const& pet : Pets)
83 _worldPacket << pet;
84
85 return &_worldPacket;
86}
87
89{
90 _worldPacket << Size<uint32>(Pets);
91 _worldPacket << Bits<1>(PetAdded);
93
94 for (BattlePet const& pet : Pets)
95 _worldPacket << pet;
96
97 return &_worldPacket;
98}
99
101{
102 _worldPacket << Size<uint32>(Slots);
103 _worldPacket << Bits<1>(NewSlot);
104 _worldPacket << Bits<1>(AutoSlotted);
106
107 for (BattlePetSlot const& slot : Slots)
108 _worldPacket << slot;
109
110 return &_worldPacket;
111}
112
118
120{
122 _worldPacket >> SizedString::BitsSize<7>(Name);
124
125 if (DeclinedNames)
126 {
127 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
128 _worldPacket >> SizedString::BitsSize<7>(DeclinedNames->name[i]);
129
130 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
132 }
133
135}
136
142
144{
148
149 _worldPacket << Bits<1>(Allow);
150
151 if (Allow)
152 {
153 _worldPacket << SizedString::BitsSize<8>(Name);
154 _worldPacket << Bits<1>(HasDeclined);
155
156 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
157 _worldPacket << SizedString::BitsSize<7>(DeclinedNames.name[i]);
158
160
161 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
163
165 }
166 else
168
169 return &_worldPacket;
170}
171
176
183
188
190{
192}
193
195{
197
198 return &_worldPacket;
199}
200
202{
203 _worldPacket << Bits<4>(Result);
205
206 return &_worldPacket;
207}
208
213
218}
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:141
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