From 837543f5e2866f03467a5e8cd21358abf3255dba Mon Sep 17 00:00:00 2001 From: Lapis Date: Thu, 4 Jun 2026 18:58:56 -0400 Subject: [PATCH] add advanced settings --- CannedNet.Client/CannedNet.Client.csproj | 2 +- CannedNet.Client/Patches/PhotonPatches.cs | 37 +++++++++++++++++------ CannedNet.Client/Plugin.cs | 8 ++++- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/CannedNet.Client/CannedNet.Client.csproj b/CannedNet.Client/CannedNet.Client.csproj index e7f8aa9..c69492a 100644 --- a/CannedNet.Client/CannedNet.Client.csproj +++ b/CannedNet.Client/CannedNet.Client.csproj @@ -16,7 +16,7 @@ - C:\Program Files (x86)\Steam\steamapps\content\app_471710\depot_471711 + C:\Program Files (x86)\Steam\steamapps\content\app_471710\cannednet2023 diff --git a/CannedNet.Client/Patches/PhotonPatches.cs b/CannedNet.Client/Patches/PhotonPatches.cs index 23cbe40..83b76e2 100644 --- a/CannedNet.Client/Patches/PhotonPatches.cs +++ b/CannedNet.Client/Patches/PhotonPatches.cs @@ -55,15 +55,34 @@ public class Photon_AppSettings_Patch private static void Postfix(ref AppSettings __result) { Plugin.Log.LogInfo("okay im patching now"); - __result = new() + + 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, - }; + __result = new() + { + 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 + }; + } } } diff --git a/CannedNet.Client/Plugin.cs b/CannedNet.Client/Plugin.cs index 278c3c0..f8b060a 100644 --- a/CannedNet.Client/Plugin.cs +++ b/CannedNet.Client/Plugin.cs @@ -23,6 +23,9 @@ public class Plugin : BasePlugin public static ConfigEntry AppIdVoice { get; private set; } public static ConfigEntry AppIdChat { get; private set; } public static ConfigEntry ServerHostname { get; private set; } + public static ConfigEntry EnableAdvancedSettings { get; private set; } + public static ConfigEntry PhotonHostname { get; private set; } + public static ConfigEntry PhotonPort { get; private set; } public override void Load() { @@ -31,7 +34,10 @@ public class Plugin : BasePlugin 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"); - ServerHostname = Config.Bind("Server", "NameServer Host", "https://ns.lapis.codes", "Host for the NameServer."); + EnableAdvancedSettings = Config.Bind("Advanced", "Enabled Advanced Settings", false, "Allows other fields below in the advanced section to be modified."); + PhotonHostname = Config.Bind("Advanced", "Photon NameServer", "", "Custom Photon NameServer"); + PhotonPort = Config.Bind("Advanced", "Photon NameServer Port", 0, "Custom Photon NameServer Port (if 0, it will be default)"); + ServerHostname = Config.Bind("Server", "RecNet NameServer Host", "https://ns.lapis.codes", "Host for the RecNet NameServer."); Harmony.CreateAndPatchAll(typeof(Plugin).Assembly);