-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReplayParser.cs
81 lines (71 loc) · 2.5 KB
/
ReplayParser.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OsuRTDataProvider.Listen;
using OsuRTDataProvider.Mods;
namespace ReplayPPDisplayer
{
class ReplayParser
{
public OsuPlayMode Mode { get; private set; }
public int Version { get; private set; }
public string BeatmapMd5 { get; private set; }
public string Player { get; private set; }
public string ReplaypMd5 { get; private set; }
public int Count300 { get; private set; }
public int Count100 { get; private set; }
public int Count50 { get; private set; }
public int CountGeki { get; private set; }
public int CountKatu { get; private set; }
public int CountMiss { get; private set; }
public int Score { get; private set; }
public int MaxCombo { get; private set; }
public bool Perfect { get; private set; }
public uint Mods { get; set; }
public ReplayParser(string osr)
{
Parse(osr);
}
private void Parse(string osr)
{
int retryCount = 5;
while (retryCount != 0)
{
try
{
using (var br = new BinaryReader(File.OpenRead(osr)))
{
Mode = (OsuPlayMode) br.ReadByte();
Version = br.ReadInt32();
int flag = br.ReadByte();
BeatmapMd5 = br.ReadString();
flag = br.ReadByte();
Player = br.ReadString();
flag = br.ReadByte();
ReplaypMd5 = br.ReadString();
Count300 = br.ReadInt16();
Count100 = br.ReadInt16();
Count50 = br.ReadInt16();
CountGeki = br.ReadInt16();
CountKatu = br.ReadInt16();
CountMiss = br.ReadInt16();
Score = br.ReadInt32();
MaxCombo = br.ReadInt16();
Perfect = br.ReadByte() == 1;
Mods = br.ReadUInt32();
}
break;
}
catch (IOException e)
{
Thread.Sleep(100);
retryCount--;
}
}
}
}
}