TrinityCore
HotfixPackets.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 "HotfixPackets.h"
19#include "PacketUtilities.h"
20#include "Util.h"
21
22namespace WorldPackets
23{
24namespace Hotfix
25{
27{
28 data >> hotfixId.PushID;
29 data >> hotfixId.UniqueID;
30 return data;
31}
32
34{
35 data << int32(hotfixId.PushID);
36 data << uint32(hotfixId.UniqueID);
37 return data;
38}
39
41{
42 data >> hotfixRecord.ID;
43 data >> hotfixRecord.TableHash;
44 data >> hotfixRecord.RecordID;
45 return data;
46}
47
49{
50 data << hotfixRecord.ID;
51 data << uint32(hotfixRecord.TableHash);
52 data << int32(hotfixRecord.RecordID);
53 return data;
54}
55
57{
59
60 uint32 count = _worldPacket.ReadBits(13);
61
62 Queries.resize(count);
63 for (uint32 i = 0; i < count; ++i)
64 _worldPacket >> Queries[i].RecordID;
65}
66
68{
73 _worldPacket << uint32(Data.size());
75
76 return &_worldPacket;
77}
78
80{
81 _worldPacket.reserve(4 + 4 + sizeof(DB2Manager::HotfixId) * Hotfixes.size());
82
84 _worldPacket << uint32(Hotfixes.size());
85 for (DB2Manager::HotfixId const& hotfixId : Hotfixes)
86 _worldPacket << hotfixId;
87
88 return &_worldPacket;
89}
90
92{
95
96 uint32 hotfixCount = _worldPacket.read<uint32>();
97 if (hotfixCount > sDB2Manager.GetHotfixCount())
98 throw PacketArrayMaxCapacityException(hotfixCount, sDB2Manager.GetHotfixCount());
99
100 Hotfixes.resize(hotfixCount);
101 for (int32& hotfixId : Hotfixes)
102 _worldPacket >> hotfixId;
103}
104
106{
107 data << hotfixData.Record;
108 data << uint32(hotfixData.Size);
109 data.WriteBits(AsUnderlyingType(hotfixData.Record.HotfixStatus), 3);
110 data.FlushBits();
111
112 return data;
113}
114
116{
117 _worldPacket << uint32(Hotfixes.size());
118 for (HotfixData const& hotfix : Hotfixes)
119 _worldPacket << hotfix;
120
123
124 return &_worldPacket;
125}
126}
127}
#define sDB2Manager
Definition: DB2Stores.h:538
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:491
uint32 ReadBits(int32 bits)
Definition: ByteBuffer.h:209
void reserve(size_t ressize)
Definition: ByteBuffer.h:546
void append(T value)
Definition: ByteBuffer.h:143
void WriteBits(std::size_t value, int32 bits)
Definition: ByteBuffer.h:203
size_t size() const
Definition: ByteBuffer.h:536
void FlushBits()
Definition: ByteBuffer.h:155
std::set< DB2Manager::HotfixId > Hotfixes
Definition: HotfixPackets.h:68
WorldPacket const * Write() override
std::vector< DBQueryRecord > Queries
Definition: HotfixPackets.h:43
DB2Manager::HotfixRecord::Status Status
Definition: HotfixPackets.h:56
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< HotfixData > Hotfixes
Definition: HotfixPackets.h:96
WorldPacket _worldPacket
Definition: Packet.h:43
ByteBuffer & operator>>(ByteBuffer &data, DB2Manager::HotfixId &hotfixId)
ByteBuffer & operator<<(ByteBuffer &data, DB2Manager::HotfixId const &hotfixId)