From 9b1211f505929413660b663a079e50f3e19a00ce Mon Sep 17 00:00:00 2001 From: miniduikboot Date: Thu, 3 Mar 2022 00:21:40 +0100 Subject: [PATCH] Add prefix patch to sync up useDtlsLayout argument Workaround a much deeper, yet unknown issue --- Reactor/Networking/Patches/ClientPatches.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Reactor/Networking/Patches/ClientPatches.cs b/Reactor/Networking/Patches/ClientPatches.cs index ed84649..7c5bc74 100644 --- a/Reactor/Networking/Patches/ClientPatches.cs +++ b/Reactor/Networking/Patches/ClientPatches.cs @@ -154,6 +154,15 @@ private static IEnumerator Coroutine(UdpConnection connection) [HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.GetConnectionData))] public static class HandshakePatch { + public static void Prefix(ref bool useDtlsLayout) + { + // Due to reasons currently unknown, the useDtlsLayout parameter sometimes doesn't reflect whether DTLS + // is actually supposed to be enabled. This causes a bad handshake message and a quick disconnect. + // The field on AmongUsClient appears to be more reliable, so override this parameter with what it is supposed to be. + Logger.Info($"Currently using dtls: {useDtlsLayout}. Should use dtls: {AmongUsClient.Instance.useDtls}"); + useDtlsLayout = AmongUsClient.Instance.useDtls; + } + public static void Postfix(ref Il2CppStructArray __result) { ModList.Update();