diff --git a/ValheimPlus/Configurations/BaseConfig.cs b/ValheimPlus/Configurations/BaseConfig.cs index 115cba77..490dd21d 100644 --- a/ValheimPlus/Configurations/BaseConfig.cs +++ b/ValheimPlus/Configurations/BaseConfig.cs @@ -87,7 +87,7 @@ public void LoadIniData(KeyDataCollection data) continue; } - if (prop.PropertyType == typeof(KeyCode)) + if (prop.PropertyType == typeof(KeyCode) && !RPC.VPlusConfigSync.isConnecting) { prop.SetValue(this, data.GetKeyCode(keyName, (KeyCode)existingValue), null); continue; diff --git a/ValheimPlus/Configurations/Sections/ServerConfiguration.cs b/ValheimPlus/Configurations/Sections/ServerConfiguration.cs index 492bbbe6..d57225a1 100644 --- a/ValheimPlus/Configurations/Sections/ServerConfiguration.cs +++ b/ValheimPlus/Configurations/Sections/ServerConfiguration.cs @@ -6,6 +6,7 @@ public class ServerConfiguration : BaseConfig public bool disableServerPassword { get; set; } = false; public bool enforceMod { get; internal set; } = true; public bool serverSyncsConfig { get; internal set; } = true; + public bool serverSyncHotkeys { get; internal set; } = true; public int dataRate { get; internal set; } = 60; // Code that applies this multiplies by 1024, so the default is 60(KB) } diff --git a/ValheimPlus/RPC/VPlusConfigSync.cs b/ValheimPlus/RPC/VPlusConfigSync.cs index 1a4b312d..a1fe2611 100644 --- a/ValheimPlus/RPC/VPlusConfigSync.cs +++ b/ValheimPlus/RPC/VPlusConfigSync.cs @@ -7,6 +7,8 @@ namespace ValheimPlus.RPC { public class VPlusConfigSync { + + static public bool isConnecting = false; public static void RPC_VPlusConfigSync(long sender, ZPackage configPkg) { if (ZNet.m_isServer) //Server @@ -75,8 +77,18 @@ public static void RPC_VPlusConfigSync(long sender, ZPackage configPkg) ValheimPlusPlugin.harmony.UnpatchSelf(); - Configuration.Current = ConfigurationExtra.LoadFromIni(memStream); - + // Sync HotKeys when connecting ? + if(Configuration.Current.Server.IsEnabled && Configuration.Current.Server.serverSyncHotkeys) + { + isConnecting = true; + Configuration.Current = ConfigurationExtra.LoadFromIni(memStream); + isConnecting = false; + } + else + { + Configuration.Current = ConfigurationExtra.LoadFromIni(memStream); + } + ValheimPlusPlugin.harmony.PatchAll(); ZLog.Log("Successfully synced VPlus configuration from server."); diff --git a/valheim_plus.cfg b/valheim_plus.cfg index bb5bc8f9..e57941d0 100644 --- a/valheim_plus.cfg +++ b/valheim_plus.cfg @@ -505,6 +505,9 @@ enforceMod=true ; Changes whether the server will force it's config on clients that connect. Only affects servers. serverSyncsConfig=true +; If false allows you to keep your own defined hotkeys instead of synchronising the ones declared for the server. Sections need to be enabled in your local configuration to load hotkeys. This is a client side setting and not affected by server settings. +serverSyncHotkeys=false + ; The total amount of data that the server and client can send per second in kilobyte, do not set this value higher than 200-300 if you don't exactly know what you are doing. dataRate=60 diff --git a/vplusconfig.json b/vplusconfig.json index 9823975c..886a0930 100644 --- a/vplusconfig.json +++ b/vplusconfig.json @@ -1061,6 +1061,11 @@ "defaultValue": "true", "defaultType": "bool" }, + "serverSyncHotkeys": { + "description": "If false allows you to keep your own defined hotkeys instead of synchronising the ones declared for the server. Sections need to be enabled in your local configuration to load hotkeys. This is a client side setting and not affected by server settings.", + "defaultValue": "false", + "defaultType": "bool" + }, "dataRate": { "description": "The total amount of data that the server and client can send per second in kilobyte", "defaultValue": "60",