-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.as
63 lines (52 loc) · 1.37 KB
/
Main.as
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
IPatch@ g_patchEmbedLimit;
IntPtr g_ptrMaxChallengeSize = 0;
IntPtr g_ptrNetConfig = 0;
void Main()
{
@g_patchEmbedLimit = CreateEmbedLimitPatch();
g_ptrMaxChallengeSize = GetMaxChallengeSizePtr();
g_ptrNetConfig = GetNetConfigPtr();
ApplySettings();
}
void ApplySettings()
{
if (Setting_EmbedLimitPatch && !g_patchEmbedLimit.IsApplied()) {
g_patchEmbedLimit.Apply();
} else if (!Setting_EmbedLimitPatch && g_patchEmbedLimit.IsApplied()) {
g_patchEmbedLimit.Revert();
}
uint maxBytes = Setting_MaximumSize * 1024 * 1024;
if (g_ptrMaxChallengeSize != 0) {
// Substract 0xC00 to match Nadeo's amounts
Dev::Write(g_ptrMaxChallengeSize, uint(maxBytes - 0xC00));
}
if (g_ptrNetConfig != 0) {
IntSize offset = GetNetConfigTcpLimitOffset();
if (offset == 0) {
warn("This game doesn't support the net config patch yet");
trace("Todo: " + Text::FormatPointer(g_ptrNetConfig));
} else {
Dev::Write(g_ptrNetConfig + offset, uint(maxBytes));
}
}
}
void OnSettingsChanged()
{
ApplySettings();
}
void OnDestroyed()
{
if (g_patchEmbedLimit !is null && g_patchEmbedLimit.IsApplied()) {
g_patchEmbedLimit.Revert();
}
}
void RenderMenu()
{
if (g_patchEmbedLimit is null) {
return;
}
if (UI::MenuItem("\\$fc9" + Icons::Archive + "\\$z Infinite embed size", "", Setting_EmbedLimitPatch)) {
Setting_EmbedLimitPatch = !Setting_EmbedLimitPatch;
ApplySettings();
}
}