From 84ee48ecb2841e3e4a1d9434ff9ca569873c1ad0 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 6 May 2023 20:00:53 -0700 Subject: [PATCH] revert to old value if fail to set the transport --- QSB/QSBCore.cs | 8 +++++++- QSB/QSBNetworkManager.cs | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 995e1ec8..81c853a5 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -255,8 +255,14 @@ public class QSBCore : ModBehaviour public override void Configure(IModConfig config) { + var useKcpTransport = UseKcpTransport; UseKcpTransport = config.GetSettingsValue("useKcpTransport") || DebugSettings.AutoStart; - QSBNetworkManager.UpdateTransport(); + if (!QSBNetworkManager.UpdateTransport()) + { + UseKcpTransport = useKcpTransport; + config.SetSettingsValue("useKcpTransport", useKcpTransport); + Helper.Storage.Save(config, Constants.ModConfigFileName); + } DefaultServerIP = config.GetSettingsValue("defaultServerIP"); IncompatibleModsAllowed = config.GetSettingsValue("incompatibleModsAllowed"); diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 04b4e12d..becb4348 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -164,11 +164,11 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart ConfigureNetworkManager(); } - public static void UpdateTransport() + public static bool UpdateTransport() { if (QSBCore.IsInMultiplayer) { - return; + return false; } if (singleton != null) { @@ -178,6 +178,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart { MenuManager.Instance.OnLanguageChanged(); // hack to update text } + return true; } private void InitPlayerName() =>