forked from jo3bingham/TibiaAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHighscores.cs
More file actions
82 lines (74 loc) · 3.37 KB
/
Highscores.cs
File metadata and controls
82 lines (74 loc) · 3.37 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System.Collections.Generic;
using OXGaming.TibiaAPI.Constants;
namespace OXGaming.TibiaAPI.Network.ServerPackets
{
public class Highscores : ServerPacket
{
public List<(byte Id, string Category)> Categories { get; } = new List<(byte Id, string Category)>();
public List<(uint Rank, string Character, byte Unknown1, byte Unknown2, byte VocationId, string World, ushort Level, byte Unknown3, ulong Points)> Entries { get; } =
new List<(uint Rank, string Character, byte Unknown1, byte Unknown2, byte VocationId, string World, ushort Level, byte Unknown3, ulong Points)>();
public List<string> GameWorlds { get; } = new List<string>();
public List<(uint Id, string Vocation)> VocationOptions { get; } = new List<(uint Id, string Text)>();
public string SelectedWorld { get; set; }
public uint LastUpdateTimestamp { get; set; }
public uint SelectedVocation { get; set; }
public byte NumberOfPages { get; set; }
public byte SelectedCategory { get; set; }
public Highscores(Client client)
{
Client = client;
PacketType = ServerPacketType.Highscores;
}
public override void ParseFromNetworkMessage(NetworkMessage message)
{
// TODO
message.ReadByte(); // 00
GameWorlds.Capacity = message.ReadByte();
for (var i = 0; i < GameWorlds.Capacity; i++)
{
GameWorlds.Add(message.ReadString());
}
SelectedWorld = message.ReadString();
VocationOptions.Capacity = message.ReadByte();
for (var i = 0; i < VocationOptions.Capacity; i++)
{
var id = message.ReadUInt32();
var vocation = message.ReadString();
VocationOptions.Add((id, vocation));
}
SelectedVocation = message.ReadUInt32();
Categories.Capacity = message.ReadByte();
for (var i = 0; i < Categories.Capacity; i++)
{
var id = message.ReadByte();
var category = message.ReadString();
Categories.Add((id, category));
}
SelectedCategory = message.ReadByte();
message.ReadBytes(2); // 01 00
NumberOfPages = message.ReadByte();
message.ReadByte(); // 00 (current page?)
Entries.Capacity = message.ReadByte();
for (var i = 0; i < Entries.Capacity; i++)
{
var rank = message.ReadUInt32();
var character = message.ReadString();
var unknown1 = message.ReadByte(); // 00
var unknown2 = message.ReadByte(); // 00
var vocationId = message.ReadByte();
var world = message.ReadString();
var level = message.ReadUInt16();
var unknown3 = message.ReadByte(); // 00
var points = message.ReadUInt64();
Entries.Add((rank, character, unknown1, unknown2, vocationId, world, level, unknown3, points));
}
message.ReadBytes(3); // FF 00 01
LastUpdateTimestamp = message.ReadUInt32();
}
public override void AppendToNetworkMessage(NetworkMessage message)
{
// TODO
// message.Write((byte)ServerPacketType.Highscores);
}
}
}