TrinityCore
SocialPackets.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 "SocialPackets.h"
19#include "SocialMgr.h"
20#include "World.h"
21
23{
25}
26
28{
29 Guid = guid;
30 WowAccountGuid = friendInfo.WowAccountGuid;
31 VirtualRealmAddr = GetVirtualRealmAddress();
32 NativeRealmAddr = GetVirtualRealmAddress();
33 TypeFlags = friendInfo.Flags;
34 Notes = friendInfo.Note;
35 Status = friendInfo.Status;
36 AreaID = friendInfo.Area;
37 Level = friendInfo.Level;
38 ClassID = friendInfo.Class;
39}
40
42{
43 data << contact.Guid;
44 data << contact.WowAccountGuid;
45 data << uint32(contact.VirtualRealmAddr);
46 data << uint32(contact.NativeRealmAddr);
47 data << uint32(contact.TypeFlags);
48 data << uint8(contact.Status);
49 data << uint32(contact.AreaID);
50 data << uint32(contact.Level);
51 data << uint32(contact.ClassID);
52 data.WriteBits(contact.Notes.length(), 10);
53 data.WriteBit(contact.Mobile);
54 data.FlushBits();
55 data.WriteString(contact.Notes);
56
57 return data;
58}
59
61{
62 _worldPacket << uint32(Flags);
63 _worldPacket.WriteBits(Contacts.size(), 8);
64 _worldPacket.FlushBits();
65
66 for (ContactInfo const& contact : Contacts)
67 _worldPacket << contact;
68
69 return &_worldPacket;
70}
71
73{
74 VirtualRealmAddress = GetVirtualRealmAddress();
75 Notes = friendInfo.Note;
76 ClassID = friendInfo.Class;
77 Status = friendInfo.Status;
78 Guid = guid;
79 WowAccountGuid = friendInfo.WowAccountGuid;
80 Level = friendInfo.Level;
81 AreaID = friendInfo.Area;
82 FriendResult = result;
83}
84
86{
87 _worldPacket << uint8(FriendResult);
88 _worldPacket << Guid;
89 _worldPacket << WowAccountGuid;
90 _worldPacket << uint32(VirtualRealmAddress);
91 _worldPacket << uint8(Status);
92 _worldPacket << uint32(AreaID);
93 _worldPacket << uint32(Level);
94 _worldPacket << uint32(ClassID);
95 _worldPacket.WriteBits(Notes.length(), 10);
96 _worldPacket.WriteBit(Mobile);
97 _worldPacket.FlushBits();
98 _worldPacket.WriteString(Notes);
99
100 return &_worldPacket;
101}
102
104{
105 data >> qGuid.VirtualRealmAddress;
106 data >> qGuid.Guid;
107
108 return data;
109}
110
112{
113 uint32 nameLength = _worldPacket.ReadBits(9);
114 uint32 noteslength = _worldPacket.ReadBits(9);
115 Name = _worldPacket.ReadString(nameLength);
116 Notes = _worldPacket.ReadString(noteslength);
117}
118
120{
121 _worldPacket >> Player;
122}
123
125{
126 _worldPacket >> Player;
127 Notes = _worldPacket.ReadString(_worldPacket.ReadBits(10));
128}
129
131{
132 uint32 nameLength = _worldPacket.ReadBits(9);
133 _worldPacket >> AccountGUID;
134 Name = _worldPacket.ReadString(nameLength);
135}
136
138{
139 _worldPacket >> Player;
140}
141
143{
144 _worldPacket.WriteBit(ShowSocialContract);
145 _worldPacket.FlushBits();
146
147 return &_worldPacket;
148}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
FriendsResult
Results of friend related commands.
Definition: SocialMgr.h:68
ByteBuffer & operator>>(ByteBuffer &data, WorldPackets::Social::QualifiedGUID &qGuid)
void WriteString(std::string const &str)
Definition: ByteBuffer.h:500
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
WorldPacket _worldPacket
Definition: Packet.h:43
WorldPacket const * Write() override
WorldPacket const * Write() override
void Initialize(ObjectGuid const &guid, FriendsResult result, FriendInfo const &friendInfo)
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3968
ByteBuffer & operator<<(ByteBuffer &data, Movement::MonsterSplineFilterKey const &monsterSplineFilterKey)
ObjectGuid WowAccountGuid
Definition: SocialMgr.h:50
FriendStatus Status
Definition: SocialMgr.h:51
uint8 Level
Definition: SocialMgr.h:54
uint8 Class
Definition: SocialMgr.h:55
std::string Note
Definition: SocialMgr.h:56
uint8 Flags
Definition: SocialMgr.h:52
uint32 Area
Definition: SocialMgr.h:53
ContactInfo(ObjectGuid const &guid, FriendInfo const &friendInfo)