From 99438f54e38ca36e16e06b72a842ead7e6102415 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Tue, 23 Nov 2021 16:56:54 +1000 Subject: [PATCH] Added setting 'TheMaxStructuresInRange' to command line. Changed to int data type. --- src/ARKServerManager/Lib/ServerProfile.cs | 14 +++-- src/ARKServerManager/VersionFeed.xml | 5 ++ src/ARKServerManager/VersionFeedBeta.xml | 5 ++ .../Windows/ServerSettingsControl.xaml | 2 +- src/ServerManager.Common/Utils/StringUtils.cs | 55 +++++++++++++------ 5 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/ARKServerManager/Lib/ServerProfile.cs b/src/ARKServerManager/Lib/ServerProfile.cs index 07131072..7c90d4d6 100644 --- a/src/ARKServerManager/Lib/ServerProfile.cs +++ b/src/ARKServerManager/Lib/ServerProfile.cs @@ -2744,12 +2744,12 @@ namespace ServerManagerTool.Lib set { SetValue(PvPZoneStructureDamageMultiplierProperty, value); } } - public static readonly DependencyProperty MaxStructuresVisibleProperty = DependencyProperty.Register(nameof(MaxStructuresVisible), typeof(float), typeof(ServerProfile), new PropertyMetadata(10500f)); + public static readonly DependencyProperty MaxStructuresInRangeProperty = DependencyProperty.Register(nameof(MaxStructuresInRange), typeof(int), typeof(ServerProfile), new PropertyMetadata(10500)); [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_ServerSettings, ServerProfileCategory.Structures, "TheMaxStructuresInRange")] - public float MaxStructuresVisible + public int MaxStructuresInRange { - get { return (float)GetValue(MaxStructuresVisibleProperty); } - set { SetValue(MaxStructuresVisibleProperty, value); } + get { return (int)GetValue(MaxStructuresInRangeProperty); } + set { SetValue(MaxStructuresInRangeProperty, value); } } public static readonly DependencyProperty PerPlatformMaxStructuresMultiplierProperty = DependencyProperty.Register(nameof(PerPlatformMaxStructuresMultiplier), typeof(float), typeof(ServerProfile), new PropertyMetadata(1.0f)); @@ -3648,6 +3648,8 @@ namespace ServerManagerTool.Lib serverArgs.Append("?ClampItemStats=true"); } + serverArgs.Append($"?TheMaxStructuresInRange={this.MaxStructuresInRange}"); + if (Config.Default.SectionSOTFEnabled && this.SOTF_Enabled) { serverArgs.Append("?EvoEventInterval=").Append(this.SOTF_EvoEventInterval); @@ -5531,7 +5533,7 @@ namespace ServerManagerTool.Lib this.ClearValue(StructureDamageRepairCooldownProperty); this.ClearValue(PvPStructureDecayProperty); this.ClearValue(PvPZoneStructureDamageMultiplierProperty); - this.ClearValue(MaxStructuresVisibleProperty); + this.ClearValue(MaxStructuresInRangeProperty); this.ClearValue(PerPlatformMaxStructuresMultiplierProperty); this.ClearValue(MaxPlatformSaddleStructureLimitProperty); this.ClearValue(OverrideStructurePlatformPreventionProperty); @@ -6231,7 +6233,7 @@ namespace ServerManagerTool.Lib this.SetValue(StructureDamageRepairCooldownProperty, sourceProfile.StructureDamageRepairCooldown); this.SetValue(PvPStructureDecayProperty, sourceProfile.PvPStructureDecay); this.SetValue(PvPZoneStructureDamageMultiplierProperty, sourceProfile.PvPZoneStructureDamageMultiplier); - this.SetValue(MaxStructuresVisibleProperty, sourceProfile.MaxStructuresVisible); + this.SetValue(MaxStructuresInRangeProperty, sourceProfile.MaxStructuresInRange); this.SetValue(PerPlatformMaxStructuresMultiplierProperty, sourceProfile.PerPlatformMaxStructuresMultiplier); this.SetValue(MaxPlatformSaddleStructureLimitProperty, sourceProfile.MaxPlatformSaddleStructureLimit); this.SetValue(OverrideStructurePlatformPreventionProperty, sourceProfile.OverrideStructurePlatformPrevention); diff --git a/src/ARKServerManager/VersionFeed.xml b/src/ARKServerManager/VersionFeed.xml index c61e5869..13f767a3 100644 --- a/src/ARKServerManager/VersionFeed.xml +++ b/src/ARKServerManager/VersionFeed.xml @@ -27,6 +27,11 @@
  • Global Settings - Added option to set the Main Window start mode - Normal, Maximized, Minimized.
  • Main Window - now sotres the Left and Top positions of the window, when in Normal mode. Will restore the window position when started. Defaults to 50,50.
  • + CHANGE +
    +

    diff --git a/src/ARKServerManager/VersionFeedBeta.xml b/src/ARKServerManager/VersionFeedBeta.xml index 6c0b333c..78b9652c 100644 --- a/src/ARKServerManager/VersionFeedBeta.xml +++ b/src/ARKServerManager/VersionFeedBeta.xml @@ -27,6 +27,11 @@
  • Global Settings - Added option to set the Main Window start mode - Normal, Maximized, Minimized.
  • Main Window - now sotres the Left and Top positions of the window, when in Normal mode. Will restore the window position when started. Defaults to 50,50.
  • + CHANGE +
    +

    diff --git a/src/ARKServerManager/Windows/ServerSettingsControl.xaml b/src/ARKServerManager/Windows/ServerSettingsControl.xaml index bbeb37ea..5f2b99f2 100644 --- a/src/ARKServerManager/Windows/ServerSettingsControl.xaml +++ b/src/ARKServerManager/Windows/ServerSettingsControl.xaml @@ -3164,7 +3164,7 @@ - + diff --git a/src/ServerManager.Common/Utils/StringUtils.cs b/src/ServerManager.Common/Utils/StringUtils.cs index 2d6fa05d..0d4a8e72 100644 --- a/src/ServerManager.Common/Utils/StringUtils.cs +++ b/src/ServerManager.Common/Utils/StringUtils.cs @@ -57,28 +57,38 @@ namespace ServerManagerTool.Common.Utils { if (property.PropertyType == typeof(bool) || property.PropertyType == typeof(bool?)) { - bool boolValue; - bool.TryParse(value, out boolValue); + bool.TryParse(value, out bool boolValue); property.SetValue(obj, boolValue); } else if (property.PropertyType == typeof(int) || property.PropertyType == typeof(int?)) { - int intValue; - int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue); + string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator; + var tempValue = value; + if (tempValue.Contains(decimalSeparator)) + { + tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator)); + } + + int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue); property.SetValue(obj, intValue); } else if (property.PropertyType == typeof(float) || property.PropertyType == typeof(float?)) { var tempValue = value.Replace("f", ""); - float floatValue; - float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue); + float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue); property.SetValue(obj, floatValue); } else if (property.PropertyType == typeof(NullableValue)) { - int intValue; - int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue); + string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator; + var tempValue = value; + if (tempValue.Contains(decimalSeparator)) + { + tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator)); + } + + int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue); var field = property.GetValue(obj) as NullableValue; property.SetValue(obj, field.SetValue(true, intValue)); } @@ -86,8 +96,7 @@ namespace ServerManagerTool.Common.Utils { var tempValue = value.Replace("f", ""); - float floatValue; - float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue); + float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue); var field = property.GetValue(obj) as NullableValue; property.SetValue(obj, field.SetValue(true, floatValue)); } @@ -121,8 +130,14 @@ namespace ServerManagerTool.Common.Utils } if (property.PropertyType == typeof(int) || property.PropertyType == typeof(int?)) { - int intValue; - int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue); + string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator; + var tempValue = value; + if (tempValue.Contains(decimalSeparator)) + { + tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator)); + } + + int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue); property.SetValue(obj, intValue); return true; } @@ -130,15 +145,20 @@ namespace ServerManagerTool.Common.Utils { var tempValue = value.Replace("f", ""); - float floatValue; - float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue); + float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue); property.SetValue(obj, floatValue); return true; } if (property.PropertyType == typeof(NullableValue)) { - int intValue; - int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue); + string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator; + var tempValue = value; + if (tempValue.Contains(decimalSeparator)) + { + tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator)); + } + + int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue); var field = property.GetValue(obj) as NullableValue; property.SetValue(obj, field.SetValue(true, intValue)); return true; @@ -147,8 +167,7 @@ namespace ServerManagerTool.Common.Utils { var tempValue = value.Replace("f", ""); - float floatValue; - float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue); + float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue); var field = property.GetValue(obj) as NullableValue; property.SetValue(obj, field.SetValue(true, floatValue)); return true;