forked from jo3bingham/TibiaAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuddyData.cs
More file actions
62 lines (51 loc) · 1.83 KB
/
BuddyData.cs
File metadata and controls
62 lines (51 loc) · 1.83 KB
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
using System;
using System.Collections.Generic;
using OXGaming.TibiaAPI.Constants;
namespace OXGaming.TibiaAPI.Network.ServerPackets
{
public class BuddyData : ServerPacket
{
public List<byte> GroupsIds { get; } = new List<byte>();
public string Description { get; set; }
public string PlayerName { get; set; }
public uint Icon { get; set; }
public uint PlayerId { get; set; }
public byte ConnectionStatus { get; set; }
public bool NotifyOnLogin { get; set; }
public BuddyData(Client client)
{
Client = client;
PacketType = ServerPacketType.BuddyData;
}
public override void ParseFromNetworkMessage(NetworkMessage message)
{
PlayerId = message.ReadUInt32();
PlayerName = message.ReadString();
Description = message.ReadString();
Icon = message.ReadUInt32();
NotifyOnLogin = message.ReadBool();
ConnectionStatus = message.ReadByte();
GroupsIds.Capacity = message.ReadByte();
for (var i = 0; i < GroupsIds.Capacity; ++i)
{
GroupsIds.Add(message.ReadByte());
}
}
public override void AppendToNetworkMessage(NetworkMessage message)
{
message.Write((byte)ServerPacketType.BuddyData);
message.Write(PlayerId);
message.Write(PlayerName);
message.Write(Description);
message.Write(Icon);
message.Write(NotifyOnLogin);
message.Write(ConnectionStatus);
var count = Math.Min(GroupsIds.Count, byte.MaxValue);
message.Write((byte)count);
for (var i = 0; i < count; ++i)
{
message.Write(GroupsIds[i]);
}
}
}
}