-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopilot.cs
More file actions
95 lines (86 loc) · 3.2 KB
/
Copilot.cs
File metadata and controls
95 lines (86 loc) · 3.2 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
83
84
85
86
87
88
89
90
91
92
93
94
95
using ModLib;
// File that should not be referenced in Release builds, purely for debugging/RE etc.
namespace SEEditor
{
internal static class Copilot
{
public static Dictionary<byte, int> count = new();
public static Dictionary<byte, List<string>> examples = new();
public static void Type(byte type, string path)
{
if (count.ContainsKey(type))
{
count[type]++;
}
else
{
count[type] = 1;
examples.Add(type, new List<string>());
}
examples[type].Add(path);
}
public static void AggressiveCompare()
{
foreach (string path in Directory.EnumerateFiles(@"G:\", "*.*"))
{
using (ModFile file = ModFile.Open(path))
{
int offset = 0;
bool found = false;
while (true)
{
if (offset + 5 > file.fileStream.Length) break;
file.Seek(offset, SeekOrigin.Begin);
if (file.ReadByte() == 0x4d) // m
{
if (file.ReadByte() == 0x69) // i
{
if (file.ReadByte() == 0x78) // x
{
if (file.ReadByte() == 0x53) // S
{
if (file.ReadByte() == 0x6f) // o
{
found = true;
break;
}
}
}
}
}
offset++;
}
if (found)
{
file.Seek(offset + 15, SeekOrigin.Begin);
if (file.ReadString(4) != "TVES")
{
file.Seek(offset + 15, SeekOrigin.Begin);
Console.WriteLine(BitConverter.ToString(file.ReadArray(9)).Replace("-", ""));
}
}
}
}
}
public static void FilesStartWith()
{
foreach (string path in Directory.EnumerateFiles(@"G:\", "*.*"))
{
using (ModFile file = ModFile.Open(path))
{
file.Seek(15, SeekOrigin.Begin);
Copilot.Type(file.ReadByte(), path);
}
}
Random rand = new Random();
foreach (KeyValuePair<byte, int> entry in Copilot.count)
{
Console.WriteLine(entry.Key + " - " + entry.Value + ":");
for (int i = 0; i < Math.Min(10, entry.Value); i++)
{
Logger.Log(new LogSeg(" {0}", ConsoleColor.Green, Copilot.examples[entry.Key][rand.Next(entry.Value)].ToString()));
}
}
}
}
}