From 70cf63c9075a126e7254b82d2d8109a451313920 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 18 Oct 2020 15:33:27 -0400 Subject: use update URL from server instead of hardcoding it --- src/SMAPI/Framework/Logging/LogManager.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/SMAPI/Framework/Logging') diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index 094dd749..1e484709 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -195,9 +195,10 @@ namespace StardewModdingAPI.Framework.Logging /// Write an update alert marker file. /// The new version found. - public void WriteUpdateMarker(string version) + /// The download URL for the update. + public void WriteUpdateMarker(string version, string url) { - File.WriteAllText(Constants.UpdateMarker, version); + File.WriteAllText(Constants.UpdateMarker, $"{version}|{url}"); } /// Check whether SMAPI crashed or detected an update during the last session, and display them in the SMAPI console. @@ -206,13 +207,17 @@ namespace StardewModdingAPI.Framework.Logging // show update alert if (File.Exists(Constants.UpdateMarker)) { - string rawUpdateFound = File.ReadAllText(Constants.UpdateMarker); - if (SemanticVersion.TryParse(rawUpdateFound, out ISemanticVersion updateFound)) + string[] rawUpdateFound = File.ReadAllText(Constants.UpdateMarker).Split(new [] { '|' }, 2); + if (SemanticVersion.TryParse(rawUpdateFound[0], out ISemanticVersion updateFound)) { if (Constants.ApiVersion.IsPrerelease() && updateFound.IsNewerThan(Constants.ApiVersion)) { + string url = rawUpdateFound.Length > 1 + ? rawUpdateFound[1] + : Constants.HomePageUrl; + this.Monitor.Log("A new version of SMAPI was detected last time you played.", LogLevel.Error); - this.Monitor.Log($"You can update to {updateFound}: https://smapi.io.", LogLevel.Error); + this.Monitor.Log($"You can update to {updateFound}: {url}.", LogLevel.Error); this.Monitor.Log("Press any key to continue playing anyway. (This only appears when using a SMAPI beta.)", LogLevel.Info); Console.ReadKey(); } -- cgit