TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WorldPacket.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITYCORE_WORLDPACKET_H
20 #define TRINITYCORE_WORLDPACKET_H
21 
22 #include "Common.h"
23 #include "Opcodes.h"
24 #include "ByteBuffer.h"
25 
26 class WorldPacket : public ByteBuffer
27 {
28  public:
29  // just container for later use
31  {
32  }
33 
34  WorldPacket(uint32 opcode, size_t res = 200, ConnectionType connection = CONNECTION_TYPE_DEFAULT) : ByteBuffer(res),
35  m_opcode(opcode), _connection(connection) { }
36 
37  WorldPacket(WorldPacket&& packet) : ByteBuffer(std::move(packet)), m_opcode(packet.m_opcode), _connection(packet._connection)
38  {
39  }
40 
42  {
43  }
44 
46  {
47  if (this != &right)
48  {
49  m_opcode = right.m_opcode;
50  _connection = right._connection;
52  }
53 
54  return *this;
55  }
56 
58  {
59  if (this != &right)
60  {
61  m_opcode = right.m_opcode;
62  _connection = right._connection;
63  ByteBuffer::operator=(std::move(right));
64  }
65 
66  return *this;
67  }
68 
69  WorldPacket(uint32 opcode, MessageBuffer&& buffer, ConnectionType connection) : ByteBuffer(std::move(buffer)), m_opcode(opcode), _connection(connection) { }
70 
71  void Initialize(uint32 opcode, size_t newres = 200, ConnectionType connection = CONNECTION_TYPE_DEFAULT)
72  {
73  clear();
74  _storage.reserve(newres);
75  m_opcode = opcode;
76  _connection = connection;
77  }
78 
79  uint32 GetOpcode() const { return m_opcode; }
80  void SetOpcode(uint32 opcode) { m_opcode = opcode; }
81 
83 
84  protected:
87 };
88 
89 #endif
uint32 m_opcode
Definition: WorldPacket.h:85
ByteBuffer & operator=(ByteBuffer const &right)
Definition: ByteBuffer.h:104
Definition: ByteBuffer.h:70
WorldPacket & operator=(WorldPacket const &right)
Definition: WorldPacket.h:45
WorldPacket(WorldPacket const &right)
Definition: WorldPacket.h:41
WorldPacket(uint32 opcode, size_t res=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
Definition: WorldPacket.h:34
STL namespace.
uint32 GetOpcode() const
Definition: WorldPacket.h:79
Definition: Opcodes.h:42
std::vector< uint8 > _storage
Definition: ByteBuffer.h:707
WorldPacket & operator=(WorldPacket &&right)
Definition: WorldPacket.h:57
WorldPacket()
Definition: WorldPacket.h:30
WorldPacket(uint32 opcode, MessageBuffer &&buffer, ConnectionType connection)
Definition: WorldPacket.h:69
uint32_t uint32
Definition: Define.h:150
WorldPacket(WorldPacket &&packet)
Definition: WorldPacket.h:37
ConnectionType _connection
Definition: WorldPacket.h:86
ConnectionType GetConnection() const
Definition: WorldPacket.h:82
void Initialize(uint32 opcode, size_t newres=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
Definition: WorldPacket.h:71
void clear()
Definition: ByteBuffer.h:134
Definition: WorldPacket.h:26
void SetOpcode(uint32 opcode)
Definition: WorldPacket.h:80
Definition: MessageBuffer.h:24
ConnectionType
Definition: Opcodes.h:29
Definition: Opcodes.h:35