diff --git a/Reactor/Networking/ModList.cs b/Reactor/Networking/ModList.cs index cab2b6a..20dcc47 100644 --- a/Reactor/Networking/ModList.cs +++ b/Reactor/Networking/ModList.cs @@ -21,7 +21,7 @@ public static Mod GetByNetId(uint netId) return _mapByNetId![netId]; } - internal static ISet Update() + internal static void Update() { var i = (uint) 0; @@ -37,8 +37,6 @@ internal static ISet Update() _mapById = Current.ToDictionary(mod => mod.Id, mod => mod); _mapByNetId = Current.ToDictionary(mod => mod.NetId, mod => mod); - - return Current; } } } diff --git a/Reactor/Networking/Patches/ClientPatches.cs b/Reactor/Networking/Patches/ClientPatches.cs index 6f3aa43..7c5bc74 100644 --- a/Reactor/Networking/Patches/ClientPatches.cs +++ b/Reactor/Networking/Patches/ClientPatches.cs @@ -165,7 +165,7 @@ public static void Prefix(ref bool useDtlsLayout) public static void Postfix(ref Il2CppStructArray __result) { - var mods = ModList.Update(); + ModList.Update(); var handshake = new MessageWriter(1000); @@ -173,7 +173,7 @@ public static void Postfix(ref Il2CppStructArray __result) ModdedHandshakeC2S.Serialize( handshake, - mods.Count + ModList.Current!.Count ); __result = handshake.ToByteArray(true); diff --git a/Reactor/Networking/Patches/HttpPatches.cs b/Reactor/Networking/Patches/HttpPatches.cs deleted file mode 100644 index d7e7ec4..0000000 --- a/Reactor/Networking/Patches/HttpPatches.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Linq; -using System.Text; -using HarmonyLib; -using UnhollowerBaseLib; -using UnityEngine.Networking; - -namespace Reactor.Networking.Patches; - -[HarmonyPatch] -internal static class HttpPatches -{ - public const int Version = 1; - - public static string BuildHeader() - { - var stringBuilder = new StringBuilder(); - - stringBuilder.Append(Version); - stringBuilder.Append(";"); - - var mods = ModList.Update().Where(m => m.Side == PluginSide.Both).OrderBy(m => m.Id, StringComparer.Ordinal).ToArray(); - - stringBuilder.Append(mods.Length); - - foreach (var mod in mods) - { - stringBuilder.Append(";"); - stringBuilder.Append(mod.Id); - stringBuilder.Append("="); - stringBuilder.Append(mod.Version); - } - - return stringBuilder.ToString(); - } - - [HarmonyPatch(typeof(UnityWebRequest), nameof(UnityWebRequest.Get), typeof(string))] - [HarmonyPatch(typeof(UnityWebRequest), nameof(UnityWebRequest.Post), typeof(string), typeof(string))] - [HarmonyPatch(typeof(UnityWebRequest), nameof(UnityWebRequest.Put), typeof(string), typeof(Il2CppStructArray))] - [HarmonyPostfix] - public static void UnityWebRequestPatch(UnityWebRequest __result) - { - var path = __result.uri.AbsolutePath; - - if (path == "/api/games") - { - __result.SetRequestHeader("Client-Mods", BuildHeader()); - } - } - - [HarmonyPatch(typeof(HttpMatchmakerManager._CoRequestGameList_d__7), nameof(HttpMatchmakerManager._CoRequestGameList_d__7.MoveNext))] - public static class CoRequestGameListPatch - { - public static void Prefix(HttpMatchmakerManager._CoRequestGameList_d__7 __instance) - { - if (__instance.__1__state == 2) - { - if (HttpUtils.IsSuccess(__instance._request_5__3.responseCode)) - { - var responseHeader = __instance._request_5__3.GetResponseHeader("Client-Mods-Processed"); - if (responseHeader == null) - { - AmongUsClient.Instance.LastDisconnectReason = DisconnectReasons.Custom; - AmongUsClient.Instance.LastCustomDisconnect = "This region doesn't support modded handshake.\nThe lobbies shown may not be compatible with your current mods.\nFor more info see https://reactor.gg/handshake"; - DisconnectPopup.Instance.Show(); - } - } - } - } - } -}