Skip to content

Commit

Permalink
Revert betraying Reactor's rpc for anti-anti-cheat purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
Galster-dev committed May 16, 2022
1 parent 7b007aa commit 8add273
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/CrowdedMod/Net/CustomRpcCalls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CrowdedMod.Net;

public enum CustomRpcCalls
{
SetColor
}
29 changes: 29 additions & 0 deletions src/CrowdedMod/Net/SetColorRpc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Hazel;
using Reactor;
using Reactor.Networking;

namespace CrowdedMod.Net;

[RegisterCustomRpc((uint) CustomRpcCalls.SetColor)]
public class SetColorRpc : PlayerCustomRpc<CrowdedModPlugin, byte>
{
public SetColorRpc(CrowdedModPlugin plugin, uint id) : base(plugin, id)
{
}

public override RpcLocalHandling LocalHandling => RpcLocalHandling.After;
public override void Write(MessageWriter writer, byte data)
{
writer.Write(data);
}

public override byte Read(MessageReader reader)
{
return reader.ReadByte();
}

public override void Handle(PlayerControl player, byte data)
{
player.SetColor(data);
}
}
8 changes: 5 additions & 3 deletions src/CrowdedMod/Patches/GenericPatches.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using System.Linq;
using CrowdedMod.Net;
using HarmonyLib;
using Reactor.Networking;
using UnhollowerBaseLib;
using UnityEngine;

namespace CrowdedMod.Patches {
internal static class GenericPatches {
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckColor))]
public static class PlayerControlCheckColorPatch {
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdCheckColor))]
public static class PlayerControlCmdCheckColorPatch {
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte colorId) {
__instance.RpcSetColor(colorId);
Rpc<SetColorRpc>.Instance.Send(__instance, colorId);
return false;
}
}
Expand Down

0 comments on commit 8add273

Please sign in to comment.