mirror of
https://github.com/djdevin/recnet-plugin.git
synced 2026-09-08 14:41:30 -07:00
fix photon patches
This commit is contained in:
@@ -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
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class Plugin : BasePlugin
|
|||||||
public override void Load()
|
public override void Load()
|
||||||
{
|
{
|
||||||
Log = base.Log;
|
Log = base.Log;
|
||||||
|
|
||||||
AppIdRT = Config.Bind("Photon", "App Id Realtime", "", "Photon Realtime App ID");
|
AppIdRT = Config.Bind("Photon", "App Id Realtime", "", "Photon Realtime App ID");
|
||||||
AppIdVoice = Config.Bind("Photon", "App Id Voice", "", "Photon Voice App ID");
|
AppIdVoice = Config.Bind("Photon", "App Id Voice", "", "Photon Voice App ID");
|
||||||
AppIdChat = Config.Bind("Photon", "App Id Chat", "", "Photon Chat 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.");
|
ServerHostname = Config.Bind("Server", "RecNet NameServer Host", "https://ns.lapis.codes", "Host for the RecNet NameServer.");
|
||||||
|
|
||||||
Harmony.CreateAndPatchAll(typeof(Plugin).Assembly);
|
Harmony.CreateAndPatchAll(typeof(Plugin).Assembly);
|
||||||
|
|
||||||
SceneManager.sceneLoaded += (Action<Scene, LoadSceneMode>)OnSceneLoaded;
|
SceneManager.sceneLoaded += (Action<Scene, LoadSceneMode>)OnSceneLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,4 +54,3 @@ public class Plugin : BasePlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user