Skip to content

Commit 8add273

Browse files
committed
Revert betraying Reactor's rpc for anti-anti-cheat purposes
1 parent 7b007aa commit 8add273

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace CrowdedMod.Net;
2+
3+
public enum CustomRpcCalls
4+
{
5+
SetColor
6+
}

src/CrowdedMod/Net/SetColorRpc.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Hazel;
2+
using Reactor;
3+
using Reactor.Networking;
4+
5+
namespace CrowdedMod.Net;
6+
7+
[RegisterCustomRpc((uint) CustomRpcCalls.SetColor)]
8+
public class SetColorRpc : PlayerCustomRpc<CrowdedModPlugin, byte>
9+
{
10+
public SetColorRpc(CrowdedModPlugin plugin, uint id) : base(plugin, id)
11+
{
12+
}
13+
14+
public override RpcLocalHandling LocalHandling => RpcLocalHandling.After;
15+
public override void Write(MessageWriter writer, byte data)
16+
{
17+
writer.Write(data);
18+
}
19+
20+
public override byte Read(MessageReader reader)
21+
{
22+
return reader.ReadByte();
23+
}
24+
25+
public override void Handle(PlayerControl player, byte data)
26+
{
27+
player.SetColor(data);
28+
}
29+
}

src/CrowdedMod/Patches/GenericPatches.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
using System.Linq;
2+
using CrowdedMod.Net;
23
using HarmonyLib;
4+
using Reactor.Networking;
35
using UnhollowerBaseLib;
46
using UnityEngine;
57

68
namespace CrowdedMod.Patches {
79
internal static class GenericPatches {
8-
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckColor))]
9-
public static class PlayerControlCheckColorPatch {
10+
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdCheckColor))]
11+
public static class PlayerControlCmdCheckColorPatch {
1012
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte colorId) {
11-
__instance.RpcSetColor(colorId);
13+
Rpc<SetColorRpc>.Instance.Send(__instance, colorId);
1214
return false;
1315
}
1416
}

0 commit comments

Comments
 (0)