This repository was archived by the owner on Apr 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSplotchPatches.cs
68 lines (62 loc) · 2.62 KB
/
SplotchPatches.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
using HarmonyLib;
using BoplFixedMath
namespace Splotch.Patches
{
public static class SplotchPatches
{
public static void ApplyPatches()
{
// Harmony Harmony = new Harmony("Harmony") - Melon, 2024
Harmony harmony = new Harmony("com.Splotch.splotchpatches");
// epic patching
MethodInfo originalfix = AccessTools.Method(typeof(Client), "Awake");
MethodInfo splotchfix = AccessTools.Method(typeof(SplotchFixes), "BugFixPatch");
harmony.Patch(originalfix, new HarmonyMethod(splotchfix));
}
public class SplotchFixes
{
// Code from Client - 306-334 - Need to patch this but eh, will do that later.
public static bool UpdateInputHistoryReplacement(Client __instance, InputPacketUpdate update)
{
uint num = this.inputHistoryHeadSeqNum;
int num2 = (int)(update.seqNumber - num);
if (num2 > 32)
{
Debug.LogError("Discarded a packet because it was too new");
return true;
}
for (int i = num2 - 1; i >= 0; i--)
{
uint num = this.inputHistoryHeadSeqNum;
int num2 = (int)(update.seqNumber - num);
if (num2 > 32)
{
Debug.LogError("Discarded a packet because it was too new");
return true;
}
for (int i = num2 - 1; i >= 0; i--)
{
uint num3 = 1U << i;
InputPacket inputPacket = default(InputPacket);
inputPacket.jump = ((update.jump & num3) > 0U);
inputPacket.ab1 = ((update.ab1 & num3) > 0U);
inputPacket.ab2 = ((update.ab2 & num3) > 0U);
inputPacket.ab3 = ((update.ab3 & num3) > 0U);
inputPacket.select = ((update.select & num3) > 0U);
inputPacket.start = ((update.start & num3) > 0U);
inputPacket.w = ((update.w & num3) > 0U);
inputPacket.a = ((update.a & num3) > 0U);
inputPacket.s = ((update.s & num3) > 0U);
inputPacket.d = ((update.d & num3) > 0U);
inputPacket.joystickAngle = update.joystickAngle[i];
inputPacket.targetDelayBufferSize = update.targetDelayBufferSize;
inputPacket.seqNumber = num + 1U;
num += 1U;
this.inputHistory.Enqueue(inputPacket);
this.inputHistoryHeadSeqNum = inputPacket.seqNumber;
}
return false;
}
}
}
}