From dcb7faec5d6ee5d02ebbfd0ed78769b312db66a4 Mon Sep 17 00:00:00 2001 From: Lapis Date: Sun, 14 Jun 2026 06:04:49 -0400 Subject: [PATCH] fix photon patches --- CannedNet.Client/Patches/PhotonPatches.cs | 87 +++++------------------ CannedNet.Client/Plugin.cs | 5 +- 2 files changed, 19 insertions(+), 73 deletions(-) diff --git a/CannedNet.Client/Patches/PhotonPatches.cs b/CannedNet.Client/Patches/PhotonPatches.cs index 83b76e2..8be8168 100644 --- a/CannedNet.Client/Patches/PhotonPatches.cs +++ b/CannedNet.Client/Patches/PhotonPatches.cs @@ -6,83 +6,30 @@ using Photon.Realtime; namespace CannedNet.Client.Patches; -[HarmonyPatch] -public class Photon_AppSettings_Patch +[HarmonyPatch(typeof(GPFPFDBGCEK), "AMOHMPKKGHL")] +public class PhotonPatches { - private static bool Prepare() - { - var type = Type.GetType("PUNNetworkManager"); - if (type == null) - { - foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) - { - type = asm.GetType("PUNNetworkManager"); - if (type != null) break; - } - } - - if (type == null) - { - Plugin.Log.LogError("Could not find PUNNetworkManager type"); - return false; - } - - var method = type.GetMethod("FJOLIPKKIBE", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); - if (method == null) - { - Plugin.Log.LogError("Could not find FJOLIPKKIBE method"); - return false; - } - - return true; - } - - private static MethodBase TargetMethod() - { - var type = Type.GetType("PUNNetworkManager"); - if (type == null) - { - foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) - { - type = asm.GetType("PUNNetworkManager"); - if (type != null) break; - } - } - - return type?.GetMethod("FJOLIPKKIBE", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); - } - + [HarmonyPostfix] private static void Postfix(ref AppSettings __result) { Plugin.Log.LogInfo("okay im patching now"); - if (Plugin.EnableAdvancedSettings.Value) + if (__result != null) { - __result = new() + __result.AppIdRealtime = Plugin.AppIdRT.Value; + __result.AppIdVoice = Plugin.AppIdVoice.Value; + __result.AppIdChat = Plugin.AppIdChat.Value; + __result.FixedRegion = "us"; + __result.UseNameServer = true; + __result.Protocol = ConnectionProtocol.Udp; + + if (Plugin.EnableAdvancedSettings.Value) { - AppVersion = __result?.AppVersion, - AppIdRealtime = Plugin.AppIdRT.Value, - AppIdVoice = Plugin.AppIdVoice.Value, - AppIdChat = Plugin.AppIdChat.Value, - FixedRegion = "us", - UseNameServer = true, - Protocol = ConnectionProtocol.Udp, - Server = Plugin.PhotonHostname.Value, - Port = Plugin.PhotonPort.Value == 0 ? 4533 : Plugin.PhotonPort.Value - }; - } - else - { - __result = new() - { - AppVersion = __result?.AppVersion, - AppIdRealtime = Plugin.AppIdRT.Value, - AppIdVoice = Plugin.AppIdVoice.Value, - AppIdChat = Plugin.AppIdChat.Value, - FixedRegion = "us", - UseNameServer = true, - Protocol = ConnectionProtocol.Udp - }; + __result.Server = Plugin.PhotonHostname.Value; + __result.Port = Plugin.PhotonPort.Value == 0 + ? 4533 + : Plugin.PhotonPort.Value; + } } } } diff --git a/CannedNet.Client/Plugin.cs b/CannedNet.Client/Plugin.cs index f8b060a..81b6f45 100644 --- a/CannedNet.Client/Plugin.cs +++ b/CannedNet.Client/Plugin.cs @@ -30,7 +30,7 @@ public class Plugin : BasePlugin public override void Load() { Log = base.Log; - + AppIdRT = Config.Bind("Photon", "App Id Realtime", "", "Photon Realtime App ID"); AppIdVoice = Config.Bind("Photon", "App Id Voice", "", "Photon Voice App ID"); AppIdChat = Config.Bind("Photon", "App Id Chat", "", "Photon Chat App ID"); @@ -40,7 +40,7 @@ public class Plugin : BasePlugin ServerHostname = Config.Bind("Server", "RecNet NameServer Host", "https://ns.lapis.codes", "Host for the RecNet NameServer."); Harmony.CreateAndPatchAll(typeof(Plugin).Assembly); - + SceneManager.sceneLoaded += (Action)OnSceneLoaded; } @@ -54,4 +54,3 @@ public class Plugin : BasePlugin } } } -