revert to old value if fail to set the transport

This commit is contained in:
JohnCorby 2023-05-06 20:00:53 -07:00
parent 55e2898c97
commit 84ee48ecb2
2 changed files with 10 additions and 3 deletions

View File

@ -255,8 +255,14 @@ public class QSBCore : ModBehaviour
public override void Configure(IModConfig config)
{
var useKcpTransport = UseKcpTransport;
UseKcpTransport = config.GetSettingsValue<bool>("useKcpTransport") || DebugSettings.AutoStart;
QSBNetworkManager.UpdateTransport();
if (!QSBNetworkManager.UpdateTransport())
{
UseKcpTransport = useKcpTransport;
config.SetSettingsValue("useKcpTransport", useKcpTransport);
Helper.Storage.Save(config, Constants.ModConfigFileName);
}
DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
IncompatibleModsAllowed = config.GetSettingsValue<bool>("incompatibleModsAllowed");

View File

@ -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() =>