From 08fe4d01cfdc46c1db482f4cdb4f2a1fd84727c6 Mon Sep 17 00:00:00 2001 From: Pietro420 <77608535+Pietrodjaowjao@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:54:47 -0300 Subject: [PATCH] Disable handshake patches if Reactor is present (#586) * Change unload to deactivate only current plugin * only replicate handshake if reactor is not present * prevent server authority incompatibility --- CTA/CustomTeamAssigner/CustomRoles.cs | 4 +++- Main.cs | 4 ++++ Patches/HandshakePatch.cs | 31 +++++++++++++++------------ Patches/ServerVersionPatch.cs | 6 +++++- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/CTA/CustomTeamAssigner/CustomRoles.cs b/CTA/CustomTeamAssigner/CustomRoles.cs index 26e7db642..08dc1e7b4 100644 --- a/CTA/CustomTeamAssigner/CustomRoles.cs +++ b/CTA/CustomTeamAssigner/CustomRoles.cs @@ -270,6 +270,7 @@ public enum CustomRoles Spy, SuperStar, Swapper, + Tar, TaskManager, Telekinetic, Tether, @@ -529,8 +530,8 @@ public enum CustomRoles Commited, Compelled, Composter, - Concealer, Constricted, + Concealer, Contagious, Damocles, Deadlined, @@ -610,6 +611,7 @@ public enum CustomRoles Undead, Underdog, Unlucky, + Urgent, Venom, Warden, // Ghost role Watcher, diff --git a/Main.cs b/Main.cs index 6e2a37702..05abc0ffb 100644 --- a/Main.cs +++ b/Main.cs @@ -173,6 +173,8 @@ public class Main : BasePlugin private static readonly List NameSnacksEn = ["Ice cream", "Milk tea", "Chocolate", "Cake", "Donut", "Coke", "Lemonade", "Candied haws", "Jelly", "Candy", "Milk", "Matcha", "Burning Grass Jelly", "Pineapple Bun", "Pudding", "Coconut Jelly", "Cookies", "Red Bean Toast", "Three Color Dumplings", "Wormwood Dumplings", "Puffs", "Can be Crepe", "Peach Crisp", "Mochi", "Egg Waffle", "Macaron", "Snow Plum Niang", "Fried Yogurt", "Egg Tart", "Muffin", "Sago Dew", "panna cotta", "soufflé", "croissant", "toffee"]; private Coroutines coroutines; + public static bool HasReactorPlugin; + private static HashAuth DebugKeyAuth { get; set; } private static ConfigEntry DebugKeyInput { get; set; } @@ -304,6 +306,8 @@ public class Main : BasePlugin ShowClientControlGUI = Config.Bind("Client Options", "ShowClientControlGUI", true); UIScaleFactor = Config.Bind("Client Options", "UIScaleFactor", 1f); + HasReactorPlugin = IL2CPPChainloader.Instance.Plugins.ContainsKey("gg.reactor.api"); + AddComponent(); Log.LogInfo("ClientControlGUI registered"); diff --git a/Patches/HandshakePatch.cs b/Patches/HandshakePatch.cs index d8ab88a8e..d8721f6a7 100644 --- a/Patches/HandshakePatch.cs +++ b/Patches/HandshakePatch.cs @@ -78,23 +78,26 @@ public static class HandshakePatch public static void Postfix(ref Il2CppStructArray __result) { - var handshake = new MessageWriter(1000); + if (!Main.HasReactorPlugin) + { + var handshake = new MessageWriter(1000); - // Original data - handshake.Write(__result); + // Original data + handshake.Write(__result); - // Reactor Header - const byte version = (byte)ReactorProtocolVersion.Latest; - const ulong value = (MAGIC << 8) | version; - handshake.Write(value); + // Reactor Header + const byte version = (byte)ReactorProtocolVersion.Latest; + const ulong value = (MAGIC << 8) | version; + handshake.Write(value); - // ModdedHandshakeC2S - handshake.WritePacked(1); - handshake.Write(Main.PluginGuid); - handshake.Write(Main.PluginVersion); - handshake.Write((ushort)(ModFlags.RequireOnHost | ModFlags.DisableServerAuthority)); + // ModdedHandshakeC2S + handshake.WritePacked(1); + handshake.Write(Main.PluginGuid); + handshake.Write(Main.PluginVersion); + handshake.Write((ushort)(ModFlags.RequireOnHost | ModFlags.DisableServerAuthority)); - __result = handshake.ToByteArray(true); - handshake.Recycle(); + __result = handshake.ToByteArray(true); + handshake.Recycle(); + } } } \ No newline at end of file diff --git a/Patches/ServerVersionPatch.cs b/Patches/ServerVersionPatch.cs index 3d290ddcc..396965f8b 100644 --- a/Patches/ServerVersionPatch.cs +++ b/Patches/ServerVersionPatch.cs @@ -12,7 +12,11 @@ internal static class ServerUpdatePatch if (GameStates.IsOnlineGame) { // Changing server version for AU mods - __result += 25; + var revision = __result % 50; + if (revision < 25) + { + __result += 25; + } Logger.Info($"IsOnlineGame: {__result}", "VersionServer"); } }