From ae55d0d1c05455fd74ff5dd15e02516c35afea71 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Sun, 6 Jun 2021 18:49:08 +1000 Subject: [PATCH] Server Version Changes --- src/ARKServerManager/App.config | 3 ++ src/ARKServerManager/Config.Designer.cs | 11 ++++- src/ARKServerManager/Config.settings | 3 ++ src/ARKServerManager/Lib/ServerApp.cs | 38 +++++++++++++-- src/ARKServerManager/Lib/ServerProfile.cs | 10 ++++ src/ARKServerManager/Lib/ServerRuntime.cs | 6 +++ .../Windows/ServerSettingsControl.xaml.cs | 4 ++ .../Model/IntegerIniValueArray.cs | 46 +++++++++++++++++++ 8 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 src/ServerManager.Common/Model/IntegerIniValueArray.cs diff --git a/src/ARKServerManager/App.config b/src/ARKServerManager/App.config index b6d6edf0..56eb9eca 100644 --- a/src/ARKServerManager/App.config +++ b/src/ARKServerManager/App.config @@ -341,6 +341,9 @@ Engine.ini + + version.txt + diff --git a/src/ARKServerManager/Config.Designer.cs b/src/ARKServerManager/Config.Designer.cs index 85efa6f5..764390b4 100644 --- a/src/ARKServerManager/Config.Designer.cs +++ b/src/ARKServerManager/Config.Designer.cs @@ -12,7 +12,7 @@ namespace ServerManagerTool { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] public sealed partial class Config : global::System.Configuration.ApplicationSettingsBase { private static Config defaultInstance = ((Config)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Config()))); @@ -2530,5 +2530,14 @@ namespace ServerManagerTool { this["ManagePublicIPAutomatically"] = value; } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("version.txt")] + public string VersionFile { + get { + return ((string)(this["VersionFile"])); + } + } } } diff --git a/src/ARKServerManager/Config.settings b/src/ARKServerManager/Config.settings index 0c4d1f40..a99d4ecf 100644 --- a/src/ARKServerManager/Config.settings +++ b/src/ARKServerManager/Config.settings @@ -707,5 +707,8 @@ True + + version.txt + \ No newline at end of file diff --git a/src/ARKServerManager/Lib/ServerApp.cs b/src/ARKServerManager/Lib/ServerApp.cs index a1f409b3..718376d3 100644 --- a/src/ARKServerManager/Lib/ServerApp.cs +++ b/src/ARKServerManager/Lib/ServerApp.cs @@ -1244,7 +1244,14 @@ namespace ServerManagerTool.Lib LogProfileMessage("Validated server files (*new*)."); } - LogProfileMessage("Updated server from cache. See ARK patch notes."); + // update the version number + _profile.LastInstalledVersion = GetServerVersion(GetServerVersionFile()).ToString(); + _profile.ServerUpdated = true; + + LogProfileMessage("Updated server from cache."); + LogProfileMessage($"Server version: {_profile.LastInstalledVersion}."); + + LogProfileMessage("See ARK patch notes."); LogProfileMessage(Config.Default.ArkSE_PatchNotesUrl); if (!string.IsNullOrWhiteSpace(Config.Default.Alert_ServerUpdate)) @@ -1253,8 +1260,6 @@ namespace ServerManagerTool.Lib emailMessage.AppendLine(); emailMessage.AppendLine("Updated server from cache. See ARK patch notes."); emailMessage.AppendLine(Config.Default.ArkSE_PatchNotesUrl); - - _profile.ServerUpdated = true; } else { @@ -1747,6 +1752,9 @@ namespace ServerManagerTool.Lib } else LogBranchMessage(branchName, "No new version."); + + var cacheVersion = GetServerVersion(GetServerCacheVersionFile(branchName)).ToString(); + LogMessage($"Server cache version: {cacheVersion}"); } else LogBranchMessage(branchName, $"Server cache does not exist."); @@ -2271,6 +2279,8 @@ namespace ServerManagerTool.Lib private static string GetServerCacheTimeFile(string branchName) => IOUtils.NormalizePath(Path.Combine(GetServerCacheFolder(branchName), Config.Default.LastUpdatedTimeFile)); + private static string GetServerCacheVersionFile(string branchName) => IOUtils.NormalizePath(Path.Combine(GetServerCacheFolder(branchName), Config.Default.VersionFile)); + private string GetServerExecutableFile() => IOUtils.NormalizePath(Path.Combine(_profile.InstallDirectory, Config.Default.ServerBinaryRelativePath, Config.Default.ServerExe)); private DateTime GetServerLatestTime(string timeFile) @@ -2313,6 +2323,28 @@ namespace ServerManagerTool.Lib private string GetServerSaveFolder() => IOUtils.NormalizePath(ServerProfile.GetProfileSavePath(_profile.InstallDirectory, _profile.AltSaveDirectoryName, _profile.PGM_Enabled, _profile.PGM_Name)); + private string GetServerVersionFile() => IOUtils.NormalizePath(Path.Combine(_profile.InstallDirectory, Config.Default.VersionFile)); + + public static Version GetServerVersion(string versionFile) + { + if (!string.IsNullOrWhiteSpace(versionFile) && File.Exists(versionFile)) + { + var fileValue = File.ReadAllText(versionFile); + + if (!string.IsNullOrWhiteSpace(fileValue)) + { + string versionString = fileValue.ToString(); + if (versionString.IndexOf('.') == -1) + versionString = versionString + ".0"; + + if (Version.TryParse(versionString, out Version version)) + return version; + } + } + + return new Version(0, 0); + } + private string GetServerWorldFile() { var profileSaveFolder = GetServerSaveFolder(); diff --git a/src/ARKServerManager/Lib/ServerProfile.cs b/src/ARKServerManager/Lib/ServerProfile.cs index c8e4525f..ccbc64fa 100644 --- a/src/ARKServerManager/Lib/ServerProfile.cs +++ b/src/ARKServerManager/Lib/ServerProfile.cs @@ -5052,6 +5052,7 @@ namespace ServerManagerTool.Lib this.ClearValue(EnableAllowCaveFlyersProperty); this.ClearValue(AllowFlyingStaminaRecoveryProperty); + this.ClearValue(AllowFlyerSpeedLevelingProperty); this.ClearValue(PreventMateBoostProperty); this.ClearValue(DisableDinoDecayPvEProperty); @@ -5300,6 +5301,7 @@ namespace ServerManagerTool.Lib this.ClearValue(AllowTekSuitPowersInGenesisProperty); this.ClearValue(DisableGenesisMissionsProperty); + this.ClearValue(DisableDefaultMapItemSetsProperty); this.ClearValue(EnableCryoSicknessPVEProperty); this.ClearValue(EnableCryopodNerfProperty); @@ -5308,7 +5310,10 @@ namespace ServerManagerTool.Lib this.ClearValue(CryopodNerfIncomingDamageMultiplierPercentProperty); this.ClearValue(MaxHexagonsPerCharacterProperty); + this.ClearValue(DisableHexagonStoreProperty); + this.ClearValue(HexStoreAllowOnlyEngramTradeOptionProperty); this.ClearValue(HexagonRewardMultiplierProperty); + this.ClearValue(HexagonCostMultiplierProperty); } public void ResetSOTFSection() @@ -5650,6 +5655,8 @@ namespace ServerManagerTool.Lib this.SetValue(EnableAllowCaveFlyersProperty, sourceProfile.EnableAllowCaveFlyers); this.SetValue(AllowFlyingStaminaRecoveryProperty, sourceProfile.AllowFlyingStaminaRecovery); + this.SetValue(AllowFlyerSpeedLevelingProperty, sourceProfile.AllowFlyerSpeedLeveling); + this.SetValue(PreventMateBoostProperty, sourceProfile.PreventMateBoost); this.SetValue(DisableDinoDecayPvEProperty, sourceProfile.DisableDinoDecayPvE); this.SetValue(DisableDinoDecayPvPProperty, sourceProfile.DisableDinoDecayPvP); @@ -5959,7 +5966,10 @@ namespace ServerManagerTool.Lib this.SetValue(CryopodNerfIncomingDamageMultiplierPercentProperty, sourceProfile.CryopodNerfIncomingDamageMultiplierPercent); this.SetValue(MaxHexagonsPerCharacterProperty, sourceProfile.MaxHexagonsPerCharacter); + this.SetValue(DisableHexagonStoreProperty, sourceProfile.DisableHexagonStore); + this.SetValue(HexStoreAllowOnlyEngramTradeOptionProperty, sourceProfile.HexStoreAllowOnlyEngramTradeOption); this.SetValue(HexagonRewardMultiplierProperty, sourceProfile.HexagonRewardMultiplier); + this.SetValue(HexagonCostMultiplierProperty, sourceProfile.HexagonCostMultiplier); } private void SyncServerFiles(ServerProfile sourceProfile) diff --git a/src/ARKServerManager/Lib/ServerRuntime.cs b/src/ARKServerManager/Lib/ServerRuntime.cs index 64b3e1cc..420cde9f 100644 --- a/src/ARKServerManager/Lib/ServerRuntime.cs +++ b/src/ARKServerManager/Lib/ServerRuntime.cs @@ -619,6 +619,12 @@ namespace ServerManagerTool.Lib gotNewVersion = ServerApp.HasNewServerVersion(this.ProfileSnapshot.InstallDirectory, startTime); progressCallback?.Invoke(0, $"{SteamCmdUpdater.OUTPUT_PREFIX} New server version - {gotNewVersion.ToString().ToUpperInvariant()}."); + + // update the version number of the server. + var versionFile = Path.Combine(this.ProfileSnapshot.InstallDirectory, Config.Default.VersionFile); + this.Version = ServerApp.GetServerVersion(versionFile); + + progressCallback?.Invoke(0, $"{SteamCmdUpdater.OUTPUT_PREFIX} Server version: {this.Version}\r\n"); } progressCallback?.Invoke(0, "\r\n"); diff --git a/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs b/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs index 75d31887..a17fb9cc 100644 --- a/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs +++ b/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs @@ -72,6 +72,7 @@ namespace ServerManagerTool DinoTamedPerLevelStatMultipliers, DinoTamedAddPerLevelStatMultipliers, DinoTamedAffinityPerLevelStatMultipliers, + ItemStatClamps, RCONWindowExtents, ServerOptions, ServerLogOptions, @@ -3991,6 +3992,9 @@ namespace ServerManagerTool this.Settings.PerLevelStatsMultiplier_DinoTamed_Affinity.Reset(); break; + case ServerSettingsResetAction.ItemStatClamps: + break; + case ServerSettingsResetAction.RCONWindowExtents: this.Settings.ResetRCONWindowExtents(); break; diff --git a/src/ServerManager.Common/Model/IntegerIniValueArray.cs b/src/ServerManager.Common/Model/IntegerIniValueArray.cs new file mode 100644 index 00000000..55d9697a --- /dev/null +++ b/src/ServerManager.Common/Model/IntegerIniValueArray.cs @@ -0,0 +1,46 @@ +using ServerManagerTool.Common.Interfaces; +using ServerManagerTool.Common.Utils; +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace ServerManagerTool.Common.Model +{ + public class IntegerIniValueArray : IniValueList, IIniValuesList + { + public IntegerIniValueArray(string iniKeyName, Func> resetFunc) : + base(iniKeyName, resetFunc, (a, b) => a == b, m => m, ToIniValueInternal, FromIniValueInternal) + { + } + + public override bool IsArray => false; + + private static string ToIniValueInternal(int val) + { + return val.ToString("0", CultureInfo.GetCultureInfo(StringUtils.DEFAULT_CULTURE_CODE)); + } + + private static int FromIniValueInternal(string iniVal) + { + return int.Parse(iniVal, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(StringUtils.DEFAULT_CULTURE_CODE)); + } + + public IEnumerable ToIniValues(object excludeIfValue) + { + var excludeIfIntegerValue = excludeIfValue is int ? (int)excludeIfValue : int.MinValue; + + var values = new List(); + for (var i = 0; i < this.Count; i++) + { + if (!EquivalencyFunc(this[i], excludeIfIntegerValue)) + { + if (string.IsNullOrWhiteSpace(IniCollectionKey)) + values.Add(this.ToIniValue(this[i])); + else + values.Add($"{this.IniCollectionKey}[{i}]={this.ToIniValue(this[i])}"); + } + } + return values; + } + } +}