fix photon patches

This commit is contained in:
Lapis
2026-06-14 06:04:49 -04:00
parent 837543f5e2
commit dcb7faec5d
2 changed files with 19 additions and 73 deletions
+17 -70
View File
@@ -6,83 +6,30 @@ using Photon.Realtime;
namespace CannedNet.Client.Patches; namespace CannedNet.Client.Patches;
[HarmonyPatch] [HarmonyPatch(typeof(GPFPFDBGCEK), "AMOHMPKKGHL")]
public class Photon_AppSettings_Patch public class PhotonPatches
{ {
private static bool Prepare() [HarmonyPostfix]
{
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);
}
private static void Postfix(ref AppSettings __result) private static void Postfix(ref AppSettings __result)
{ {
Plugin.Log.LogInfo("okay im patching now"); 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, __result.Server = Plugin.PhotonHostname.Value;
AppIdRealtime = Plugin.AppIdRT.Value, __result.Port = Plugin.PhotonPort.Value == 0
AppIdVoice = Plugin.AppIdVoice.Value, ? 4533
AppIdChat = Plugin.AppIdChat.Value, : Plugin.PhotonPort.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
};
} }
} }
} }
-1
View File
@@ -54,4 +54,3 @@ public class Plugin : BasePlugin
} }
} }
} }