TrinityCore
WhoPackets.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 "WhoPackets.h"
19
21{
23}
24
26{
27 _worldPacket.WriteBits(AccountName.length(), 11);
28 _worldPacket.FlushBits();
29
30 _worldPacket.WriteString(AccountName);
31
32 return &_worldPacket;
33}
34
36{
37 word.Word = data.ReadString(data.ReadBits(7));
38 data.ResetBitPos();
39
40 return data;
41}
42
44{
45 serverInfo.emplace();
46
47 data >> serverInfo->FactionGroup;
48 data >> serverInfo->Locale;
49 data >> serverInfo->RequesterVirtualRealmAddress;
50
51 return data;
52}
53
55{
56 data >> request.MinLevel;
57 data >> request.MaxLevel;
58 data >> request.RaceFilter.RawValue;
59 data >> request.ClassFilter;
60
61 uint32 nameLength = data.ReadBits(6);
62 uint32 virtualRealmNameLength = data.ReadBits(9);
63 uint32 guildNameLength = data.ReadBits(7);
64 uint32 guildVirtualRealmNameLength = data.ReadBits(9);
65 request.Words.resize(data.ReadBits(3));
66
67 request.ShowEnemies = data.ReadBit();
68 request.ShowArenaPlayers = data.ReadBit();
69 request.ExactName = data.ReadBit();
70
71 bool hasWhoRequest = data.ReadBit();
72 data.ResetBitPos();
73
74 for (size_t i = 0; i < request.Words.size(); ++i)
75 data >> request.Words[i];
76
77 request.Name = data.ReadString(nameLength);
78 request.VirtualRealmName = data.ReadString(virtualRealmNameLength);
79 request.Guild = data.ReadString(guildNameLength);
80 request.GuildVirtualRealmName = data.ReadString(guildVirtualRealmNameLength);
81
82 if (hasWhoRequest)
83 data >> request.ServerInfo;
84
85 return data;
86}
87
89{
90 Areas.resize(_worldPacket.ReadBits(4));
91 IsFromAddOn = _worldPacket.ReadBit();
92
93 _worldPacket >> Request;
94 _worldPacket >> RequestID;
95 _worldPacket >> Origin;
96
97 for (size_t i = 0; i < Areas.size(); ++i)
98 _worldPacket >> Areas[i];
99}
100
102{
103 data << entry.PlayerData;
104
105 data << entry.GuildGUID;
106 data << uint32(entry.GuildVirtualRealmAddress);
107 data << int32(entry.AreaID);
108
109 data.WriteBits(entry.GuildName.length(), 7);
110 data.WriteBit(entry.IsGM);
111 data.FlushBits();
112
113 data.WriteString(entry.GuildName);
114
115 return data;
116}
117
119{
120 data.WriteBits(response.Entries.size(), 6);
121 data.FlushBits();
122
123 for (WorldPackets::Who::WhoEntry const& whoEntry : response.Entries)
124 data << whoEntry;
125
126 return data;
127}
128
130{
131 _worldPacket << uint32(RequestID);
132 _worldPacket << Response;
133
134 return &_worldPacket;
135}
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
ByteBuffer & operator>>(ByteBuffer &data, WorldPackets::Who::WhoWord &word)
Definition: WhoPackets.cpp:35
uint32 ReadBits(int32 bits)
Definition: ByteBuffer.h:209
void WriteString(std::string const &str)
Definition: ByteBuffer.h:500
void ResetBitPos()
Definition: ByteBuffer.h:166
bool WriteBit(bool bit)
Definition: ByteBuffer.h:175
void WriteBits(std::size_t value, int32 bits)
Definition: ByteBuffer.h:203
void FlushBits()
Definition: ByteBuffer.h:155
std::string ReadString(uint32 length, bool requireValidUtf8=true)
Definition: ByteBuffer.cpp:78
bool ReadBit()
Definition: ByteBuffer.h:191
WorldPacket _worldPacket
Definition: Packet.h:43
WorldPacket const * Write() override
Definition: WhoPackets.cpp:25
WorldPacket const * Write() override
Definition: WhoPackets.cpp:129
boost::beast::http::response< ResponseBody > Response
Definition: HttpCommon.h:31
boost::beast::http::request< RequestBody > Request
Definition: HttpCommon.h:30
ByteBuffer & operator<<(ByteBuffer &data, Movement::MonsterSplineFilterKey const &monsterSplineFilterKey)
Definition: Player.h:375
Query::PlayerGuidLookupData PlayerData
Definition: WhoPackets.h:95
std::vector< WhoWord > Words
Definition: WhoPackets.h:72
Trinity::RaceMask< int64 > RaceFilter
Definition: WhoPackets.h:70
Optional< WhoRequestServerInfo > ServerInfo
Definition: WhoPackets.h:76
std::string GuildVirtualRealmName
Definition: WhoPackets.h:69
std::vector< WhoEntry > Entries
Definition: WhoPackets.h:105