TrinityCore
BattlenetPackets.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 "BattlenetPackets.h"
19#include "PacketUtilities.h"
20
22{
23 data << uint64(method.Type);
24 data << uint64(method.ObjectId);
25 data << uint32(method.Token);
26 return data;
27}
28
30{
31 data >> method.Type;
32 data >> method.ObjectId;
33 data >> method.Token;
34 return data;
35}
36
38{
40 _worldPacket << uint32(Data.size());
42
43 return &_worldPacket;
44}
45
47{
48 _worldPacket << uint32(BnetStatus);
49 _worldPacket << Method;
50 _worldPacket << uint32(Data.size());
51 _worldPacket.append(Data);
52
53 return &_worldPacket;
54}
55
57{
58 _worldPacket.WriteBits(State, 2);
59 _worldPacket.WriteBit(SuppressNotification);
60 _worldPacket.FlushBits();
61
62 return &_worldPacket;
63}
64
66{
67 _worldPacket << uint32(Token);
68 _worldPacket.WriteBit(Allow);
69 _worldPacket << uint32(Ticket.size());
70 _worldPacket.append(Ticket);
71
72 return &_worldPacket;
73}
74
76{
77 uint32 protoSize;
78
79 _worldPacket >> Method;
80 _worldPacket >> protoSize;
81
82 if (protoSize > 0xFFFF)
83 throw PacketArrayMaxCapacityException(protoSize, 0xFFFF);
84
85 if (protoSize)
86 {
87 Data.Resize(protoSize);
88 _worldPacket.read(Data.GetWritePointer(), Data.GetRemainingSpace());
89 Data.WriteCompleted(protoSize);
90 }
91}
92
94{
95 _worldPacket >> Token;
96 _worldPacket.read(Secret.data(), Secret.size());
97}
ByteBuffer & operator>>(ByteBuffer &data, WorldPackets::Battlenet::MethodCall &method)
ByteBuffer & operator<<(ByteBuffer &data, WorldPackets::Battlenet::MethodCall const &method)
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
void append(T value)
Definition: ByteBuffer.h:143
void WriteBits(std::size_t value, int32 bits)
Definition: ByteBuffer.h:203
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket _worldPacket
Definition: Packet.h:43