From e9aa92afcb20629c22e0cf42ba921c71da07753b Mon Sep 17 00:00:00 2001 From: js6pak Date: Tue, 6 Apr 2021 22:50:59 +0200 Subject: [PATCH] Add skid mode back --- Reactor/Networking/Patches/ClientPatches.cs | 16 ++++++++++++++++ Reactor/ReactorPlugin.cs | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/Reactor/Networking/Patches/ClientPatches.cs b/Reactor/Networking/Patches/ClientPatches.cs index 1bfce88..fdbf03f 100644 --- a/Reactor/Networking/Patches/ClientPatches.cs +++ b/Reactor/Networking/Patches/ClientPatches.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Linq; using HarmonyLib; using Hazel; using Hazel.Udp; @@ -125,6 +126,21 @@ namespace Reactor.Networking.Patches var client = AmongUsClient.Instance; if (client != null && client.connection != null && client.connection.Equals(connection) && client.connection.State == ConnectionState.Connecting) { + var reactorPlugin = PluginSingleton.Instance; + + if (reactorPlugin.AllowVanillaServers.Value) + { + if (reactorPlugin.CustomRpcManager.List.Any()) + { + Logger.Warning("Config option AllowVanillaServers was set to true, but there are custom rpcs registered!"); + } + else + { + connection.State = ConnectionState.Connected; + yield break; + } + } + client.LastDisconnectReason = DisconnectReasons.Custom; client.LastCustomDisconnect = "Server didn't respond to modded handshake"; client.HandleDisconnect(client.LastDisconnectReason, client.LastCustomDisconnect); diff --git a/Reactor/ReactorPlugin.cs b/Reactor/ReactorPlugin.cs index f449ce3..a17f6b9 100644 --- a/Reactor/ReactorPlugin.cs +++ b/Reactor/ReactorPlugin.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using BepInEx; +using BepInEx.Configuration; using BepInEx.IL2CPP; using HarmonyLib; using Reactor.Extensions; @@ -21,6 +22,8 @@ namespace Reactor public Harmony Harmony { get; } = new Harmony(Id); public CustomRpcManager CustomRpcManager { get; } = new CustomRpcManager(); + public ConfigEntry AllowVanillaServers; + private GameObject _gameObject; private RegionInfoWatcher RegionInfoWatcher { get; } = new RegionInfoWatcher(); @@ -28,6 +31,8 @@ namespace Reactor { RegisterInIl2CppAttribute.Register(); + AllowVanillaServers = Config.Bind("Features", "Allow vanilla servers", false, "Whether reactor should ignore servers not responding to modded handshake. This config is ignored if any plugin uses custom rpcs!"); + _gameObject = new GameObject(nameof(ReactorPlugin)).DontDestroy(); _gameObject.AddComponent().Plugin = this; _gameObject.AddComponent();