From 8bf57a71b96d76f76d5513f99590534b4d0d7efe Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Mon, 20 Dec 2021 10:16:02 +1000 Subject: [PATCH] Auto Update Tweaks Support Zip Creation - added new config settings. --- src/ARKServerManager/App.config | 30 ++++---- src/ARKServerManager/Config.Designer.cs | 56 +++++++-------- src/ARKServerManager/Config.settings | 30 ++++---- src/ARKServerManager/Lib/ServerApp.cs | 70 ++++++++++++------- src/ARKServerManager/Lib/ServerProfile.cs | 18 ++--- .../UserControls/GlobalSettingsControl.xaml | 1 - .../ServerSettingsControl.xaml.cs | 46 +++++++----- src/ARKServerManager/Utils/ModUtils.cs | 12 ++-- src/ConanServerManager/App.config | 4 +- src/ConanServerManager/Config.Designer.cs | 4 +- src/ConanServerManager/Config.settings | 4 +- src/ConanServerManager/Lib/ServerApp.cs | 68 ++++++++++++++++-- .../UserControls/GlobalSettingsControl.xaml | 1 - .../ServerSettingsControl.xaml.cs | 29 +++++--- 14 files changed, 233 insertions(+), 140 deletions(-) diff --git a/src/ARKServerManager/App.config b/src/ARKServerManager/App.config index 1a23590c..0bd56321 100644 --- a/src/ARKServerManager/App.config +++ b/src/ARKServerManager/App.config @@ -101,16 +101,16 @@ http://arkservermanager.freeforums.net/thread/1194/faq-frequently-asked - + https://survivetheark.com/index.php?/forums/forum/5-changelog-patch-notes/ - + https://survivetheark.com/index.php?/forums/forum/9-changelog-patch-notes/ - + http://store.steampowered.com/app/346110/ - + http://store.steampowered.com/app/407530/ @@ -122,7 +122,7 @@ +login {0} +workshop_download_item {1} {2} +quit - + steamapps\workshop\content\346110\ @@ -146,13 +146,13 @@ steamapps\workshop - + appworkshop_346110.acf - + appworkshop_407530.acf - + steamapps\workshop\content\407530\ @@ -191,13 +191,13 @@ http://arkservermanager.freeforums.net/board/11/beta-testers - + PlayersJoinNoCheckList.txt - + AllowedCheaterSteamIDs.txt - + PlayersExclusiveJoinList.txt @@ -299,10 +299,10 @@ __ - + appmanifest_376030.acf - + appmanifest_407530.acf @@ -604,7 +604,7 @@ True - True + False Server Update Reason: @@ -679,7 +679,7 @@ True - 0 + 10 True diff --git a/src/ARKServerManager/Config.Designer.cs b/src/ARKServerManager/Config.Designer.cs index cd49e43b..b5f70642 100644 --- a/src/ARKServerManager/Config.Designer.cs +++ b/src/ARKServerManager/Config.Designer.cs @@ -579,36 +579,36 @@ namespace ServerManagerTool { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("https://survivetheark.com/index.php?/forums/forum/5-changelog-patch-notes/")] - public string ArkSE_PatchNotesUrl { + public string AppPatchNotesUrl { get { - return ((string)(this["ArkSE_PatchNotesUrl"])); + return ((string)(this["AppPatchNotesUrl"])); } } [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("https://survivetheark.com/index.php?/forums/forum/9-changelog-patch-notes/")] - public string ArkSotF_PatchNotesUrl { + public string AppPatchNotesUrlSotF { get { - return ((string)(this["ArkSotF_PatchNotesUrl"])); + return ((string)(this["AppPatchNotesUrlSotF"])); } } [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("http://store.steampowered.com/app/346110/")] - public string ArkSEUrl { + public string AppUrl { get { - return ((string)(this["ArkSEUrl"])); + return ((string)(this["AppUrl"])); } } [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("http://store.steampowered.com/app/407530/")] - public string ArkSotfUrl { + public string AppUrl_SotF { get { - return ((string)(this["ArkSotfUrl"])); + return ((string)(this["AppUrl_SotF"])); } } @@ -752,9 +752,9 @@ namespace ServerManagerTool { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("steamapps\\workshop\\content\\346110\\")] - public string ArkSteamWorkshopFolderRelativePath { + public string AppSteamWorkshopFolderRelativePath { get { - return ((string)(this["ArkSteamWorkshopFolderRelativePath"])); + return ((string)(this["AppSteamWorkshopFolderRelativePath"])); } } @@ -1052,9 +1052,9 @@ namespace ServerManagerTool { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("appworkshop_346110.acf")] - public string ArkSteamWorkshopFile { + public string AppSteamWorkshopFile { get { - return ((string)(this["ArkSteamWorkshopFile"])); + return ((string)(this["AppSteamWorkshopFile"])); } } @@ -1121,18 +1121,18 @@ namespace ServerManagerTool { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("appworkshop_407530.acf")] - public string ArkSteamWorkshopFile_SotF { + public string AppSteamWorkshopFile_SotF { get { - return ((string)(this["ArkSteamWorkshopFile_SotF"])); + return ((string)(this["AppSteamWorkshopFile_SotF"])); } } [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("steamapps\\workshop\\content\\407530\\")] - public string ArkSteamWorkshopFolderRelativePath_SotF { + public string AppSteamWorkshopFolderRelativePath_SotF { get { - return ((string)(this["ArkSteamWorkshopFolderRelativePath_SotF"])); + return ((string)(this["AppSteamWorkshopFolderRelativePath_SotF"])); } } @@ -1250,18 +1250,18 @@ namespace ServerManagerTool { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("PlayersJoinNoCheckList.txt")] - public string ArkWhitelistFile { + public string ServerWhitelistFile { get { - return ((string)(this["ArkWhitelistFile"])); + return ((string)(this["ServerWhitelistFile"])); } } [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("AllowedCheaterSteamIDs.txt")] - public string ArkAdminFile { + public string ServerAdminFile { get { - return ((string)(this["ArkAdminFile"])); + return ((string)(this["ServerAdminFile"])); } } @@ -1280,9 +1280,9 @@ namespace ServerManagerTool { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("PlayersExclusiveJoinList.txt")] - public string ArkExclusiveFile { + public string ServerExclusiveFile { get { - return ((string)(this["ArkExclusiveFile"])); + return ((string)(this["ServerExclusiveFile"])); } } @@ -1652,7 +1652,7 @@ namespace ServerManagerTool { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] + [global::System.Configuration.DefaultSettingValueAttribute("False")] public bool AutoUpdate_ParallelUpdate { get { return ((bool)(this["AutoUpdate_ParallelUpdate"])); @@ -2108,18 +2108,18 @@ namespace ServerManagerTool { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("appmanifest_376030.acf")] - public string ArkSteamManifestFile { + public string AppSteamManifestFile { get { - return ((string)(this["ArkSteamManifestFile"])); + return ((string)(this["AppSteamManifestFile"])); } } [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("appmanifest_407530.acf")] - public string ArkSteamManifestFile_SotF { + public string AppSteamManifestFile_SotF { get { - return ((string)(this["ArkSteamManifestFile_SotF"])); + return ((string)(this["AppSteamManifestFile_SotF"])); } } @@ -2227,7 +2227,7 @@ namespace ServerManagerTool { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("0")] + [global::System.Configuration.DefaultSettingValueAttribute("10")] public int AutoUpdate_SequencialDelayPeriod { get { return ((int)(this["AutoUpdate_SequencialDelayPeriod"])); diff --git a/src/ARKServerManager/Config.settings b/src/ARKServerManager/Config.settings index b1e91d4f..fdc3cb7d 100644 --- a/src/ARKServerManager/Config.settings +++ b/src/ARKServerManager/Config.settings @@ -161,16 +161,16 @@ 1000 - + https://survivetheark.com/index.php?/forums/forum/5-changelog-patch-notes/ - + https://survivetheark.com/index.php?/forums/forum/9-changelog-patch-notes/ - + http://store.steampowered.com/app/346110/ - + http://store.steampowered.com/app/407530/ @@ -209,7 +209,7 @@ +login {0} +workshop_download_item {1} {2} +quit - + steamapps\workshop\content\346110\ @@ -290,7 +290,7 @@ steamapps\workshop - + appworkshop_346110.acf @@ -308,10 +308,10 @@ False - + appworkshop_407530.acf - + steamapps\workshop\content\407530\ @@ -350,16 +350,16 @@ http://arkservermanager.freeforums.net/board/11/beta-testers - + PlayersJoinNoCheckList.txt - + AllowedCheaterSteamIDs.txt False - + PlayersExclusiveJoinList.txt @@ -462,7 +462,7 @@ True - True + False Server Update Reason: @@ -590,10 +590,10 @@ __ - + appmanifest_376030.acf - + appmanifest_407530.acf @@ -627,7 +627,7 @@ ArkServerManager - 0 + 10 True diff --git a/src/ARKServerManager/Lib/ServerApp.cs b/src/ARKServerManager/Lib/ServerApp.cs index 5875111f..c47f3610 100644 --- a/src/ARKServerManager/Lib/ServerApp.cs +++ b/src/ARKServerManager/Lib/ServerApp.cs @@ -804,7 +804,8 @@ namespace ServerManagerTool.Lib success = false; LogProfileMessage("****************************"); LogProfileMessage("ERROR: Failed server update."); - LogProfileMessage("****************************\r\n"); + LogProfileMessage("****************************"); + LogProfileMessage("Check steamcmd logs for more information why the server update failed.\r\n"); if (Config.Default.SteamCmdRedirectOutput) LogProfileMessage($"If the server update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the settings window.\r\n"); @@ -981,6 +982,7 @@ namespace ServerManagerTool.Lib LogProfileMessage("***************************"); LogProfileMessage("ERROR: Mod download failed."); LogProfileMessage("***************************\r\n"); + LogProfileMessage("Check steamcmd logs for more information why the mod update failed.\r\n"); if (Config.Default.SteamCmdRedirectOutput) LogProfileMessage($"If the mod update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the settings window.\r\n"); @@ -1195,6 +1197,7 @@ namespace ServerManagerTool.Lib } // stop the server + LogProfileMessage(""); StopServer(CancellationToken.None); if (ExitCode != EXITCODE_NORMALEXIT) @@ -1205,6 +1208,7 @@ namespace ServerManagerTool.Lib emailMessage.AppendLine($"Server Manager version: {App.Instance.Version}"); // make a backup of the current profile and config files. + LogProfileMessage(""); CreateProfileBackupArchiveFile(_profile); if (ExitCode != EXITCODE_NORMALEXIT) @@ -1213,6 +1217,7 @@ namespace ServerManagerTool.Lib if (BackupWorldFile) { // make a backup of the current world file. + LogProfileMessage(""); CreateServerBackupArchiveFile(emailMessage, _profile); if (ExitCode != EXITCODE_NORMALEXIT) @@ -1227,6 +1232,7 @@ namespace ServerManagerTool.Lib alertMessage.AppendLine(Config.Default.Alert_UpdateResults); // check if the server needs to be updated + LogProfileMessage(""); if (updateServer) { Task.Delay(5000).Wait(); @@ -1259,16 +1265,14 @@ namespace ServerManagerTool.Lib _profile.LastInstalledVersion = GetServerVersion(GetServerVersionFile()).ToString(); LogProfileMessage("Updated server from cache. See patch notes."); - LogProfileMessage($"Server version: {_profile.LastInstalledVersion}."); - - LogProfileMessage(Config.Default.ArkSE_PatchNotesUrl); + LogProfileMessage(Config.Default.AppPatchNotesUrl); if (!string.IsNullOrWhiteSpace(Config.Default.Alert_ServerUpdate)) alertMessage.AppendLine(Config.Default.Alert_ServerUpdate); emailMessage.AppendLine(); emailMessage.AppendLine("Updated server from cache. See patch notes."); - emailMessage.AppendLine(Config.Default.ArkSE_PatchNotesUrl); + emailMessage.AppendLine(Config.Default.AppPatchNotesUrl); _profile.ServerUpdated = true; } @@ -1289,10 +1293,16 @@ namespace ServerManagerTool.Lib LogProfileMessage("Server is already up to date, no update required."); } + var serverVersion = GetServerVersion(GetServerVersionFile()).ToString(); + LogProfileMessage($"Server version: {serverVersion}"); + + emailMessage.AppendLine($"Server version: {serverVersion}"); + if (ExitCode != EXITCODE_NORMALEXIT) return; // check if the mods need to be updated + LogProfileMessage(""); if (updateModIds.Count > 0) { Task.Delay(5000).Wait(); @@ -1389,12 +1399,14 @@ namespace ServerManagerTool.Lib } else { - LogProfileMessage("Mods are already up to date, no updates required."); + if (modIdList.Count > 0) + LogProfileMessage("Mods are already up to date, no updates required."); } if (ExitCode != EXITCODE_NORMALEXIT) return; + LogProfileMessage(""); if (Config.Default.AutoUpdate_OverrideServerStartup) { if (_serverRunning) @@ -1419,13 +1431,15 @@ namespace ServerManagerTool.Lib } else { - if (updateModIds.Count > 0) + LogProfileMessage(""); + if (modIdList.Count > 0) LogProfileMessage("The server and mods files are already up to date, no updates required."); else LogProfileMessage("The server files are already up to date, no updates required."); _serverRunning = GetServerProcess() != null; + LogProfileMessage(""); if (Config.Default.AutoUpdate_OverrideServerStartup) { if (!_serverRunning) @@ -1619,7 +1633,10 @@ namespace ServerManagerTool.Lib { // failed max limit reached if (Config.Default.SteamCmdRedirectOutput) + { + LogMessage("Check steamcmd logs for more information why the mod cache update failed.\r\n"); LogMessage($"If the mod cache update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the Server Manager settings window."); + } ExitCode = EXITCODE_CACHEMODUPDATEFAILED; return; @@ -1738,7 +1755,10 @@ namespace ServerManagerTool.Lib { // failed max limit reached if (Config.Default.SteamCmdRedirectOutput) + { + LogBranchMessage(branchName, $"Check steamcmd logs for more information why the server cache update failed.\r\n"); LogBranchMessage(branchName, $"If the server cache update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the ASM settings window."); + } ExitCode = EXITCODE_CACHESERVERUPDATEFAILED; return; @@ -1762,13 +1782,13 @@ 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."); + var cacheVersion = GetServerVersion(GetServerCacheVersionFile(branchName)).ToString(); + LogBranchMessage(branchName, $"Server cache version: {cacheVersion}"); + LogBranchMessage(branchName, "-----------------------------"); LogBranchMessage(branchName, "Finished server cache update."); LogBranchMessage(branchName, "-----------------------------"); @@ -2015,13 +2035,6 @@ namespace ServerManagerTool.Lib files.Add(file.FullName); } - //var playerImageFileFilter = $"*{Config.Default.PlayerImageFileExtension}"; - //var playerImageFiles = saveFolderInfo.GetFiles(playerImageFileFilter, SearchOption.TopDirectoryOnly); - //foreach (var file in playerImageFiles) - //{ - // files.Add(file.FullName); - //} - var comment = new StringBuilder(); comment.AppendLine($"Windows Platform: {Environment.OSVersion.Platform}"); comment.AppendLine($"Windows Version: {Environment.OSVersion.VersionString}"); @@ -2378,16 +2391,23 @@ namespace ServerManagerTool.Lib { if (!string.IsNullOrWhiteSpace(versionFile) && File.Exists(versionFile)) { - var fileValue = File.ReadAllText(versionFile); - - if (!string.IsNullOrWhiteSpace(fileValue)) + try { - string versionString = fileValue.ToString(); - if (versionString.IndexOf('.') == -1) - versionString = versionString + ".0"; + var fileValue = File.ReadAllText(versionFile); - if (Version.TryParse(versionString, out Version version)) - return version; + if (!string.IsNullOrWhiteSpace(fileValue)) + { + string versionString = fileValue.ToString(); + if (versionString.IndexOf('.') == -1) + versionString = versionString + ".0"; + + if (Version.TryParse(versionString, out Version version)) + return version; + } + } + catch (Exception) + { + // do nothing, just leave } } diff --git a/src/ARKServerManager/Lib/ServerProfile.cs b/src/ARKServerManager/Lib/ServerProfile.cs index 87297bac..4b79149f 100644 --- a/src/ARKServerManager/Lib/ServerProfile.cs +++ b/src/ARKServerManager/Lib/ServerProfile.cs @@ -6399,15 +6399,15 @@ namespace ServerManagerTool.Lib var exclusiveFile = false; var whitelistFile = false; - if (e.Name.Equals(Config.Default.ArkAdminFile, StringComparison.OrdinalIgnoreCase)) + if (e.Name.Equals(Config.Default.ServerAdminFile, StringComparison.OrdinalIgnoreCase)) { adminFile = true; } - if (e.Name.Equals(Config.Default.ArkExclusiveFile, StringComparison.OrdinalIgnoreCase)) + if (e.Name.Equals(Config.Default.ServerExclusiveFile, StringComparison.OrdinalIgnoreCase)) { exclusiveFile = true; } - if (e.Name.Equals(Config.Default.ArkWhitelistFile, StringComparison.OrdinalIgnoreCase)) + if (e.Name.Equals(Config.Default.ServerWhitelistFile, StringComparison.OrdinalIgnoreCase)) { whitelistFile = true; } @@ -6499,7 +6499,7 @@ namespace ServerManagerTool.Lib if (adminFile) { - var file = Path.Combine(InstallDirectory, Config.Default.SavedRelativePath, Config.Default.ArkAdminFile); + var file = Path.Combine(InstallDirectory, Config.Default.SavedRelativePath, Config.Default.ServerAdminFile); if (File.Exists(file)) { adminSteamIds = File.ReadAllLines(file); @@ -6509,7 +6509,7 @@ namespace ServerManagerTool.Lib if (exclusiveFile) { - var file = Path.Combine(InstallDirectory, Config.Default.ServerBinaryRelativePath, Config.Default.ArkExclusiveFile); + var file = Path.Combine(InstallDirectory, Config.Default.ServerBinaryRelativePath, Config.Default.ServerExclusiveFile); if (File.Exists(file)) { exclusiveSteamIds = File.ReadAllLines(file); @@ -6519,7 +6519,7 @@ namespace ServerManagerTool.Lib if (whitelistFile) { - var file = Path.Combine(InstallDirectory, Config.Default.ServerBinaryRelativePath, Config.Default.ArkWhitelistFile); + var file = Path.Combine(InstallDirectory, Config.Default.ServerBinaryRelativePath, Config.Default.ServerWhitelistFile); if (File.Exists(file)) { whitelistSteamIds = File.ReadAllLines(file); @@ -6566,7 +6566,7 @@ namespace ServerManagerTool.Lib if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); - var file = Path.Combine(folder, Config.Default.ArkAdminFile); + var file = Path.Combine(folder, Config.Default.ServerAdminFile); File.WriteAllLines(file, this.ServerFilesAdmins.ToEnumerable()); } catch (Exception ex) @@ -6583,7 +6583,7 @@ namespace ServerManagerTool.Lib if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); - var file = Path.Combine(folder, Config.Default.ArkExclusiveFile); + var file = Path.Combine(folder, Config.Default.ServerExclusiveFile); File.WriteAllLines(file, this.ServerFilesExclusive.ToEnumerable()); } catch (Exception ex) @@ -6600,7 +6600,7 @@ namespace ServerManagerTool.Lib if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); - var file = Path.Combine(folder, Config.Default.ArkWhitelistFile); + var file = Path.Combine(folder, Config.Default.ServerWhitelistFile); File.WriteAllLines(file, this.ServerFilesWhitelisted.ToEnumerable()); } catch (Exception ex) diff --git a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml index 32f9469b..c1d6c846 100644 --- a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml +++ b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml @@ -789,7 +789,6 @@ - diff --git a/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs b/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs index 4cdbd447..792f2f34 100644 --- a/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs +++ b/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs @@ -1,15 +1,4 @@ -using Microsoft.WindowsAPICodePack.Dialogs; -using ServerManagerTool.Common; -using ServerManagerTool.Common.Lib; -using ServerManagerTool.Common.Model; -using ServerManagerTool.Common.Serialization; -using ServerManagerTool.Common.Utils; -using ServerManagerTool.Enums; -using ServerManagerTool.Lib; -using ServerManagerTool.Lib.ViewModel; -using ServerManagerTool.Plugin.Common; -using ServerManagerTool.Utils; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -24,6 +13,17 @@ using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Input; +using Microsoft.WindowsAPICodePack.Dialogs; +using ServerManagerTool.Common; +using ServerManagerTool.Common.Lib; +using ServerManagerTool.Common.Model; +using ServerManagerTool.Common.Serialization; +using ServerManagerTool.Common.Utils; +using ServerManagerTool.Enums; +using ServerManagerTool.Lib; +using ServerManagerTool.Lib.ViewModel; +using ServerManagerTool.Plugin.Common; +using ServerManagerTool.Utils; using WPFSharp.Globalizer; namespace ServerManagerTool @@ -638,19 +638,19 @@ namespace ServerManagerTool private void HelpSOTF_Click(object sender, RoutedEventArgs e) { - if (string.IsNullOrWhiteSpace(Config.Default.ArkSotfUrl)) + if (string.IsNullOrWhiteSpace(Config.Default.AppUrl_SotF)) return; - Process.Start(Config.Default.ArkSotfUrl); + Process.Start(Config.Default.AppUrl_SotF); } private void PatchNotes_Click(object sender, RoutedEventArgs e) { var url = string.Empty; if (Settings.SOTF_Enabled) - url =Config.Default.ArkSotF_PatchNotesUrl; + url =Config.Default.AppPatchNotesUrlSotF; else - url = Config.Default.ArkSE_PatchNotesUrl; + url = Config.Default.AppPatchNotesUrl; if (string.IsNullOrWhiteSpace(url)) return; @@ -791,9 +791,9 @@ namespace ServerManagerTool // \SteamCMD\steamapps\workshop\content\ if (this.Settings.SOTF_Enabled) - folder = Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.ArkSteamWorkshopFolderRelativePath_SotF); + folder = Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.AppSteamWorkshopFolderRelativePath_SotF); else - folder = Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.ArkSteamWorkshopFolderRelativePath); + folder = Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.AppSteamWorkshopFolderRelativePath); if (Directory.Exists(folder)) { foreach (var modFolder in Directory.GetDirectories(folder)) @@ -915,6 +915,9 @@ namespace ServerManagerTool comment.AppendLine($"HasDiscordBotToken: {!string.IsNullOrWhiteSpace(Config.Default.DiscordBotToken)}"); comment.AppendLine($"DiscordBotServerId: {Config.Default.DiscordBotServerId}"); comment.AppendLine($"DiscordBotPrefix: {Config.Default.DiscordBotPrefix}"); + comment.AppendLine($"DiscordBotLogLevel: {Config.Default.DiscordBotLogLevel}"); + comment.AppendLine($"DiscordBotAllowAllBots: {Config.Default.DiscordBotAllowAllBots}"); + comment.AppendLine($"DiscordBotWhitelist: {string.Join(";", Config.Default.DiscordBotWhitelist)}"); comment.AppendLine($"AllowDiscordBackup: {Config.Default.AllowDiscordBackup}"); comment.AppendLine($"AllowDiscordRestart: {Config.Default.AllowDiscordRestart}"); comment.AppendLine($"AllowDiscordShutdown: {Config.Default.AllowDiscordShutdown}"); @@ -928,10 +931,15 @@ namespace ServerManagerTool comment.AppendLine($"EmailNotify_ShutdownRestart: {Config.Default.EmailNotify_ShutdownRestart}"); comment.AppendLine($"ServerShutdown_UseShutdownCommand: {Config.Default.ServerShutdown_UseShutdownCommand}"); - comment.AppendLine($"ServerShutdown_WorldSaveDelay: {Config.Default.ServerShutdown_WorldSaveDelay}"); comment.AppendLine($"BackupWorldFile: {Config.Default.BackupWorldFile}"); + comment.AppendLine($"CloseShutdownWindowWhenFinished: {Config.Default.CloseShutdownWindowWhenFinished}"); comment.AppendLine($"AutoUpdate_VerifyServerAfterUpdate: {Config.Default.AutoUpdate_VerifyServerAfterUpdate}"); + comment.AppendLine($"SteamCmdRemoveQuit: {CommonConfig.Default.SteamCmdRemoveQuit}"); comment.AppendLine($"UpdateDirectoryPermissions: {Config.Default.UpdateDirectoryPermissions}"); + comment.AppendLine($"LoggingEnabled: {Config.Default.LoggingEnabled}"); + comment.AppendLine($"LoggingMaxArchiveDays: {Config.Default.LoggingMaxArchiveDays}"); + comment.AppendLine($"LoggingMaxArchiveFiles: {Config.Default.LoggingMaxArchiveFiles}"); + comment.AppendLine($"ServerShutdown_WorldSaveDelay: {Config.Default.ServerShutdown_WorldSaveDelay}"); var zipFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), this.Settings.ProfileID + ".zip"); if (File.Exists(zipFile)) File.Delete(zipFile); diff --git a/src/ARKServerManager/Utils/ModUtils.cs b/src/ARKServerManager/Utils/ModUtils.cs index 9ab371fe..89d6828d 100644 --- a/src/ARKServerManager/Utils/ModUtils.cs +++ b/src/ARKServerManager/Utils/ModUtils.cs @@ -231,9 +231,9 @@ namespace ServerManagerTool.Utils public static string GetModCachePath(string modId, bool isSotF) { if (isSotF) - return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.ArkSteamWorkshopFolderRelativePath_SotF, modId)); + return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.AppSteamWorkshopFolderRelativePath_SotF, modId)); - return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.ArkSteamWorkshopFolderRelativePath, modId)); + return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.AppSteamWorkshopFolderRelativePath, modId)); } public static List GetModIdList(string modIds) @@ -282,17 +282,17 @@ namespace ServerManagerTool.Utils public static string GetSteamManifestFile(string installDirectory, bool isSotF) { if (isSotF) - return IOUtils.NormalizePath(Path.Combine(installDirectory, Config.Default.SteamManifestFolderRelativePath, Config.Default.ArkSteamManifestFile_SotF)); + return IOUtils.NormalizePath(Path.Combine(installDirectory, Config.Default.SteamManifestFolderRelativePath, Config.Default.AppSteamManifestFile_SotF)); - return IOUtils.NormalizePath(Path.Combine(installDirectory, Config.Default.SteamManifestFolderRelativePath, Config.Default.ArkSteamManifestFile)); + return IOUtils.NormalizePath(Path.Combine(installDirectory, Config.Default.SteamManifestFolderRelativePath, Config.Default.AppSteamManifestFile)); } public static string GetSteamWorkshopFile(bool isSotF) { if (isSotF) - return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.SteamWorkshopFolderRelativePath, Config.Default.ArkSteamWorkshopFile_SotF)); + return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.SteamWorkshopFolderRelativePath, Config.Default.AppSteamWorkshopFile_SotF)); - return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.SteamWorkshopFolderRelativePath, Config.Default.ArkSteamWorkshopFile)); + return IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.SteamCmdDir, Config.Default.SteamWorkshopFolderRelativePath, Config.Default.AppSteamWorkshopFile)); } public static int GetSteamWorkshopLatestTime(string workshopFile, string modId) diff --git a/src/ConanServerManager/App.config b/src/ConanServerManager/App.config index b53894bb..1cbc5bc0 100644 --- a/src/ConanServerManager/App.config +++ b/src/ConanServerManager/App.config @@ -442,7 +442,7 @@ - True + False Server Update Reason: @@ -517,7 +517,7 @@ True - 0 + 10 True diff --git a/src/ConanServerManager/Config.Designer.cs b/src/ConanServerManager/Config.Designer.cs index 6cb22b49..fecd8dcd 100644 --- a/src/ConanServerManager/Config.Designer.cs +++ b/src/ConanServerManager/Config.Designer.cs @@ -1088,7 +1088,7 @@ namespace ServerManagerTool { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] + [global::System.Configuration.DefaultSettingValueAttribute("False")] public bool AutoUpdate_ParallelUpdate { get { return ((bool)(this["AutoUpdate_ParallelUpdate"])); @@ -1680,7 +1680,7 @@ namespace ServerManagerTool { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("0")] + [global::System.Configuration.DefaultSettingValueAttribute("10")] public int AutoUpdate_SequencialDelayPeriod { get { return ((int)(this["AutoUpdate_SequencialDelayPeriod"])); diff --git a/src/ConanServerManager/Config.settings b/src/ConanServerManager/Config.settings index f6b3777b..feee7ee3 100644 --- a/src/ConanServerManager/Config.settings +++ b/src/ConanServerManager/Config.settings @@ -300,7 +300,7 @@ - True + False Server Update Reason: @@ -471,7 +471,7 @@ -listen -nosteamclient -game -server -log - 0 + 10 True diff --git a/src/ConanServerManager/Lib/ServerApp.cs b/src/ConanServerManager/Lib/ServerApp.cs index 1f2f2410..36d76723 100644 --- a/src/ConanServerManager/Lib/ServerApp.cs +++ b/src/ConanServerManager/Lib/ServerApp.cs @@ -22,6 +22,7 @@ using System.Net.Mail; using System.Reflection; using System.Security.Cryptography; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using WPFSharp.Globalizer; @@ -762,7 +763,8 @@ namespace ServerManagerTool.Lib success = false; LogProfileMessage("****************************"); LogProfileMessage("ERROR: Failed server update."); - LogProfileMessage("****************************\r\n"); + LogProfileMessage("****************************"); + LogProfileMessage("Check steamcmd logs for more information why the server update failed.\r\n"); if (Config.Default.SteamCmdRedirectOutput) LogProfileMessage($"If the server update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the settings window.\r\n"); @@ -935,6 +937,7 @@ namespace ServerManagerTool.Lib LogProfileMessage("***************************"); LogProfileMessage("ERROR: Mod download failed."); LogProfileMessage("***************************\r\n"); + LogProfileMessage("Check steamcmd logs for more information why the mod update failed.\r\n"); if (Config.Default.SteamCmdRedirectOutput) LogProfileMessage($"If the mod update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the settings window.\r\n"); @@ -1152,6 +1155,7 @@ namespace ServerManagerTool.Lib } // stop the server + LogProfileMessage(""); StopServer(CancellationToken.None); if (ExitCode != EXITCODE_NORMALEXIT) @@ -1162,6 +1166,7 @@ namespace ServerManagerTool.Lib emailMessage.AppendLine($"Server Manager version: {App.Instance.Version}"); // make a backup of the current profile and config files. + LogProfileMessage(""); CreateProfileBackupArchiveFile(_profile); if (ExitCode != EXITCODE_NORMALEXIT) @@ -1170,6 +1175,7 @@ namespace ServerManagerTool.Lib if (BackupWorldFile) { // make a backup of the current world file. + LogProfileMessage(""); CreateServerBackupArchiveFile(emailMessage, _profile); if (ExitCode != EXITCODE_NORMALEXIT) @@ -1184,6 +1190,7 @@ namespace ServerManagerTool.Lib alertMessage.AppendLine(Config.Default.Alert_UpdateResults); // check if the server needs to be updated + LogProfileMessage(""); if (updateServer) { Task.Delay(5000).Wait(); @@ -1212,6 +1219,9 @@ namespace ServerManagerTool.Lib LogProfileMessage("Validated server files (*new*)."); } + // update the version number + _profile.LastInstalledVersion = GetServerVersion(GetServerVersionFile()).ToString(); + LogProfileMessage("Updated server from cache. See patch notes."); LogProfileMessage(Config.Default.AppPatchNotesUrl); @@ -1241,10 +1251,16 @@ namespace ServerManagerTool.Lib LogProfileMessage("Server is already up to date, no update required."); } + var serverVersion = GetServerVersion(GetServerVersionFile()).ToString(); + LogProfileMessage($"Server version: {serverVersion}"); + + emailMessage.AppendLine($"Server version: {serverVersion}"); + if (ExitCode != EXITCODE_NORMALEXIT) return; // check if the mods need to be updated + LogProfileMessage(""); if (updateModIds.Count > 0) { Task.Delay(5000).Wait(); @@ -1329,6 +1345,7 @@ namespace ServerManagerTool.Lib } ModUtils.CreateModListFile(_profile.InstallDirectory, _profile.ServerModIds); + LogProfileMessage(""); LogProfileMessage("Modlist file updated."); if (ExitCode == EXITCODE_NORMALEXIT) @@ -1344,12 +1361,14 @@ namespace ServerManagerTool.Lib } else { - LogProfileMessage("Mods are already up to date, no updates required."); + if (modIdList.Count > 0) + LogProfileMessage("Mods are already up to date, no updates required."); } if (ExitCode != EXITCODE_NORMALEXIT) return; + LogProfileMessage(""); if (Config.Default.AutoUpdate_OverrideServerStartup) { if (_serverRunning) @@ -1374,13 +1393,15 @@ namespace ServerManagerTool.Lib } else { - if (updateModIds.Count > 0) + LogProfileMessage(""); + if (modIdList.Count > 0) LogProfileMessage("The server and mods files are already up to date, no updates required."); else LogProfileMessage("The server files are already up to date, no updates required."); _serverRunning = GetServerProcess() != null; + LogProfileMessage(""); if (Config.Default.AutoUpdate_OverrideServerStartup) { if (!_serverRunning) @@ -1574,7 +1595,10 @@ namespace ServerManagerTool.Lib { // failed max limit reached if (Config.Default.SteamCmdRedirectOutput) + { + LogMessage("Check steamcmd logs for more information why the mod cache update failed.\r\n"); LogMessage($"If the mod cache update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the Server Manager settings window."); + } ExitCode = EXITCODE_CACHEMODUPDATEFAILED; return; @@ -1693,7 +1717,10 @@ namespace ServerManagerTool.Lib { // failed max limit reached if (Config.Default.SteamCmdRedirectOutput) + { + LogBranchMessage(branchName, $"Check steamcmd logs for more information why the server cache update failed.\r\n"); LogBranchMessage(branchName, $"If the server cache update keeps failing try disabling the '{_globalizer.GetResourceString("GlobalSettings_SteamCmdRedirectOutputLabel")}' option in the ASM settings window."); + } ExitCode = EXITCODE_CACHESERVERUPDATEFAILED; return; @@ -1721,6 +1748,9 @@ namespace ServerManagerTool.Lib else LogBranchMessage(branchName, $"Server cache does not exist."); + var cacheVersion = GetServerVersion(GetServerCacheVersionFile(branchName)).ToString(); + LogBranchMessage(branchName, $"Server cache version: {cacheVersion}"); + LogBranchMessage(branchName, "-----------------------------"); LogBranchMessage(branchName, "Finished server cache update."); LogBranchMessage(branchName, "-----------------------------"); @@ -1740,7 +1770,6 @@ namespace ServerManagerTool.Lib { _profile = profile; - // create the backup file. try { @@ -2197,6 +2226,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.ServerBinaryRelativePath, Config.Default.ServerExeFile)); + private string GetServerExecutableFile() => IOUtils.NormalizePath(Path.Combine(_profile.InstallDirectory, Config.Default.ServerBinaryRelativePath, Config.Default.ServerExeFile)); private DateTime GetServerLatestTime(string timeFile) @@ -2239,6 +2270,35 @@ namespace ServerManagerTool.Lib private string GetServerSaveFolder() => IOUtils.NormalizePath(Path.Combine(_profile.InstallDirectory, Config.Default.SavedFilesRelativePath)); + private string GetServerVersionFile() => IOUtils.NormalizePath(Path.Combine(_profile.InstallDirectory, Config.Default.ServerBinaryRelativePath, Config.Default.ServerExeFile)); + + public static Version GetServerVersion(string versionFile) + { + if (!string.IsNullOrWhiteSpace(versionFile) && File.Exists(versionFile)) + { + try + { + var info = FileVersionInfo.GetVersionInfo(versionFile); + var version = $"{info.ProductMajorPart}.{info.ProductMinorPart}"; + var name = info.ProductName; + + var match = Regex.Match(name, @"\(([0-9]*)\)"); + if (match.Success && match.Groups.Count >= 2) + { + var serverVersion = $"{version}.{match.Groups[1].Value}"; + if (!string.IsNullOrWhiteSpace(serverVersion) && Version.TryParse(serverVersion, out Version temp)) + return temp; + } + } + catch (Exception) + { + // do nothing, just leave + } + } + + return new Version(0, 0); + } + private string GetServerWorldFile() { var saveFolder = GetServerSaveFolder(); diff --git a/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml b/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml index d625ae10..108beb07 100644 --- a/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml +++ b/src/ConanServerManager/UserControls/GlobalSettingsControl.xaml @@ -737,7 +737,6 @@ - diff --git a/src/ConanServerManager/UserControls/ServerSettingsControl.xaml.cs b/src/ConanServerManager/UserControls/ServerSettingsControl.xaml.cs index 51e88bf1..8b52fa1f 100644 --- a/src/ConanServerManager/UserControls/ServerSettingsControl.xaml.cs +++ b/src/ConanServerManager/UserControls/ServerSettingsControl.xaml.cs @@ -1,12 +1,4 @@ -using Microsoft.WindowsAPICodePack.Dialogs; -using ServerManagerTool.Common; -using ServerManagerTool.Common.Lib; -using ServerManagerTool.Common.Model; -using ServerManagerTool.Common.Utils; -using ServerManagerTool.Enums; -using ServerManagerTool.Lib; -using ServerManagerTool.Plugin.Common; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -20,8 +12,15 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; +using Microsoft.WindowsAPICodePack.Dialogs; +using ServerManagerTool.Common; +using ServerManagerTool.Common.Lib; +using ServerManagerTool.Common.Model; +using ServerManagerTool.Common.Utils; +using ServerManagerTool.Enums; +using ServerManagerTool.Lib; +using ServerManagerTool.Plugin.Common; using WPFSharp.Globalizer; namespace ServerManagerTool @@ -685,6 +684,9 @@ namespace ServerManagerTool comment.AppendLine($"HasDiscordBotToken: {!string.IsNullOrWhiteSpace(Config.Default.DiscordBotToken)}"); comment.AppendLine($"DiscordBotServerId: {Config.Default.DiscordBotServerId}"); comment.AppendLine($"DiscordBotPrefix: {Config.Default.DiscordBotPrefix}"); + comment.AppendLine($"DiscordBotLogLevel: {Config.Default.DiscordBotLogLevel}"); + comment.AppendLine($"DiscordBotAllowAllBots: {Config.Default.DiscordBotAllowAllBots}"); + comment.AppendLine($"DiscordBotWhitelist: {string.Join(";", Config.Default.DiscordBotWhitelist)}"); comment.AppendLine($"AllowDiscordBackup: {Config.Default.AllowDiscordBackup}"); comment.AppendLine($"AllowDiscordRestart: {Config.Default.AllowDiscordRestart}"); comment.AppendLine($"AllowDiscordShutdown: {Config.Default.AllowDiscordShutdown}"); @@ -698,10 +700,15 @@ namespace ServerManagerTool comment.AppendLine($"EmailNotify_ShutdownRestart: {Config.Default.EmailNotify_ShutdownRestart}"); comment.AppendLine($"ServerShutdown_UseShutdownCommand: {Config.Default.ServerShutdown_UseShutdownCommand}"); - comment.AppendLine($"ServerShutdown_WorldSaveDelay: {Config.Default.ServerShutdown_WorldSaveDelay}"); comment.AppendLine($"BackupWorldFile: {Config.Default.BackupWorldFile}"); + comment.AppendLine($"CloseShutdownWindowWhenFinished: {Config.Default.CloseShutdownWindowWhenFinished}"); comment.AppendLine($"AutoUpdate_VerifyServerAfterUpdate: {Config.Default.AutoUpdate_VerifyServerAfterUpdate}"); + comment.AppendLine($"SteamCmdRemoveQuit: {CommonConfig.Default.SteamCmdRemoveQuit}"); comment.AppendLine($"UpdateDirectoryPermissions: {Config.Default.UpdateDirectoryPermissions}"); + comment.AppendLine($"LoggingEnabled: {Config.Default.LoggingEnabled}"); + comment.AppendLine($"LoggingMaxArchiveDays: {Config.Default.LoggingMaxArchiveDays}"); + comment.AppendLine($"LoggingMaxArchiveFiles: {Config.Default.LoggingMaxArchiveFiles}"); + comment.AppendLine($"ServerShutdown_WorldSaveDelay: {Config.Default.ServerShutdown_WorldSaveDelay}"); var zipFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), this.Settings.ProfileID + ".zip"); if (File.Exists(zipFile)) File.Delete(zipFile);