aboutsummaryrefslogtreecommitdiff
path: root/src/server/bnetserver/Packets/FriendsPackets.cpp
blob: a9d85877f93f16cba6d3f4cc84db0a03d799f8ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "Session.h"
#include "FriendsPackets.h"

void Battlenet::Friends::GetFriendsOfFriend::Read()
{
    _stream.Read<uint8>(2);
    _stream.Read<uint32>(32);
}

std::string Battlenet::Friends::GetFriendsOfFriend::ToString() const
{
    return "Battlenet::Friends::GetFriendsOfFriend";
}

void Battlenet::Friends::SocialNetworkCheckConnected::Read()
{
    SocialNetworkId = _stream.Read<uint32>(32);
}

std::string Battlenet::Friends::SocialNetworkCheckConnected::ToString() const
{
    return "Battlenet::Friends::SocialNetworkCheckConnected SocialNetworkId " + std::to_string(SocialNetworkId);
}

void Battlenet::Friends::SocialNetworkCheckConnected::CallHandler(Session* session)
{
    session->HandleSocialNetworkCheckConnected(*this);
}

void Battlenet::Friends::RealIdFriendInvite::Read()
{
    _stream.Read<uint32>(32);
    uint8 type = _stream.Read<uint8>(3);

    switch (type)
    {
        case 0:
        {
            _stream.Read<uint32>(32); // Presence Id?
            break;
        }
        case 1: // GameAccount?
        {
            _stream.Read<uint8>(8);
            _stream.Read<uint32>(32);
            _stream.Read<uint32>(32);
            uint8 size = _stream.Read<uint8>(7); // Only if *(a1 + 16) <= 0x64
            _stream.ReadBytes(size);
            break;
        }
        case 2:
            Email = _stream.ReadString(9, 3);
            break;
        case 3:
        {
            _stream.Read<uint32>(32);
            break;
        }
        case 4:
        {
            _stream.Read<uint64>(64);
            _stream.Read<uint32>(32);
            break;
        }
    }

    _stream.Read<uint8>(1);

    if (_stream.Read<uint8>(1))
        Message = _stream.ReadString(9);

    _stream.Read<uint32>(32);
}

std::string Battlenet::Friends::RealIdFriendInvite::ToString() const
{
    return "Battlenet::Friends::RealIdFriendInvite Mail: " + Email + " Message: " + Message;
}

std::string Battlenet::Friends::FriendInviteResult::ToString() const
{
    return "Battlenet::Friends::RealIdFriendInviteResult";
}

void Battlenet::Friends::FriendInviteResult::Write()
{
    bool hasNames = false;
    _stream.Write(hasNames, 1);
    if (hasNames)
    {
        _stream.WriteString("Testing1", 8);
        _stream.WriteString("Testing2", 8);
    }
    _stream.Write(5, 32);

    _stream.Write(0, 0xC); // Ignored

    _stream.Write(1, 16);

    bool moreInfo = true;
    _stream.Write(moreInfo, 1);
    if (moreInfo)
    {
        _stream.Write(0, 8);
        _stream.Write(4, 32);
        _stream.Write(3, 32);
        _stream.WriteString("Testing3", 7, 2);
    }
}

std::string Battlenet::Friends::SocialNetworkCheckConnectedResult::ToString() const
{
    return "Battlenet::Friends::SocialNetworkCheckConnectedResult";
}

void Battlenet::Friends::SocialNetworkCheckConnectedResult::Write()
{
    _stream.WriteSkip(23);
    _stream.Write(Result, 16);
    _stream.Write(SocialNetworkId, 32);
}