summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Constants.cs2
-rw-r--r--src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs4
-rw-r--r--src/SMAPI/Framework/Logging/LogManager.cs15
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs2
-rw-r--r--src/SMAPI/Framework/SCore.cs57
-rw-r--r--src/SMAPI/SMAPI.csproj2
6 files changed, 46 insertions, 36 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index 754ab295..88f79811 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -51,7 +51,7 @@ namespace StardewModdingAPI
** Public
****/
/// <summary>SMAPI's current semantic version.</summary>
- public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.7.5");
+ public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.7.6");
/// <summary>The minimum supported version of Stardew Valley.</summary>
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.1");
diff --git a/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs b/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs
index 8fdd4282..f3731d16 100644
--- a/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs
+++ b/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs
@@ -112,9 +112,9 @@ namespace StardewModdingAPI.Framework.Commands
private IEnumerable<SearchResult> GetAllPatches()
{
#if HARMONY_2
- foreach (MethodBase method in Harmony.GetAllPatchedMethods())
+ foreach (MethodBase method in Harmony.GetAllPatchedMethods().ToArray())
#else
- foreach (MethodBase method in this.HarmonyInstance.GetPatchedMethods())
+ foreach (MethodBase method in this.HarmonyInstance.GetPatchedMethods().ToArray())
#endif
{
// get metadata for method
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
/// <summary>Write an update alert marker file.</summary>
/// <param name="version">The new version found.</param>
- public void WriteUpdateMarker(string version)
+ /// <param name="url">The download URL for the update.</param>
+ public void WriteUpdateMarker(string version, string url)
{
- File.WriteAllText(Constants.UpdateMarker, version);
+ File.WriteAllText(Constants.UpdateMarker, $"{version}|{url}");
}
/// <summary>Check whether SMAPI crashed or detected an update during the last session, and display them in the SMAPI console.</summary>
@@ -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();
}
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs
index ca04205c..f59a6ab1 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs
@@ -68,7 +68,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
private bool TryRewriteToProperty(ModuleDefinition module, Instruction instruction, FieldReference fieldRef, TypeDefinition declaringType, bool isRead)
{
// get equivalent property
- PropertyDefinition property = declaringType.Properties.FirstOrDefault(p => p.Name == fieldRef.Name);
+ PropertyDefinition property = declaringType?.Properties.FirstOrDefault(p => p.Name == fieldRef.Name);
MethodDefinition method = isRead ? property?.GetMethod : property?.SetMethod;
if (method == null)
return false;
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index f07e41f0..1b4c32bb 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1195,37 +1195,42 @@ namespace StardewModdingAPI.Framework
this.Monitor.Log("Checking for updates...");
// check SMAPI version
- ISemanticVersion updateFound = null;
- try
{
- // fetch update check
- ModEntryModel response = client.GetModInfo(new[] { new ModSearchEntryModel("Pathoschild.SMAPI", Constants.ApiVersion, new[] { $"GitHub:{this.Settings.GitHubProjectName}" }) }, apiVersion: Constants.ApiVersion, gameVersion: Constants.GameVersion, platform: Constants.Platform).Single().Value;
- if (response.SuggestedUpdate != null)
- this.Monitor.Log($"You can update SMAPI to {response.SuggestedUpdate.Version}: {Constants.HomePageUrl}", LogLevel.Alert);
- else
- this.Monitor.Log(" SMAPI okay.");
-
- updateFound = response.SuggestedUpdate?.Version;
+ ISemanticVersion updateFound = null;
+ string updateUrl = null;
+ try
+ {
+ // fetch update check
+ ModEntryModel response = client.GetModInfo(new[] { new ModSearchEntryModel("Pathoschild.SMAPI", Constants.ApiVersion, new[] { $"GitHub:{this.Settings.GitHubProjectName}" }) }, apiVersion: Constants.ApiVersion, gameVersion: Constants.GameVersion, platform: Constants.Platform).Single().Value;
+ updateFound = response.SuggestedUpdate?.Version;
+ updateUrl = response.SuggestedUpdate?.Url ?? Constants.HomePageUrl;
+
+ // log message
+ if (updateFound != null)
+ this.Monitor.Log($"You can update SMAPI to {updateFound}: {updateUrl}", LogLevel.Alert);
+ else
+ this.Monitor.Log(" SMAPI okay.");
- // show errors
- if (response.Errors.Any())
+ // show errors
+ if (response.Errors.Any())
+ {
+ this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you may not be notified of new versions if this keeps happening.", LogLevel.Warn);
+ this.Monitor.Log($"Error: {string.Join("\n", response.Errors)}");
+ }
+ }
+ catch (Exception ex)
{
- this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you may not be notified of new versions if this keeps happening.", LogLevel.Warn);
- this.Monitor.Log($"Error: {string.Join("\n", response.Errors)}");
+ this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you won't be notified of new versions if this keeps happening.", LogLevel.Warn);
+ this.Monitor.Log(ex is WebException && ex.InnerException == null
+ ? $"Error: {ex.Message}"
+ : $"Error: {ex.GetLogSummary()}"
+ );
}
- }
- catch (Exception ex)
- {
- this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you won't be notified of new versions if this keeps happening.", LogLevel.Warn);
- this.Monitor.Log(ex is WebException && ex.InnerException == null
- ? $"Error: {ex.Message}"
- : $"Error: {ex.GetLogSummary()}"
- );
- }
- // show update message on next launch
- if (updateFound != null)
- this.LogManager.WriteUpdateMarker(updateFound.ToString());
+ // show update message on next launch
+ if (updateFound != null)
+ this.LogManager.WriteUpdateMarker(updateFound.ToString(), updateUrl);
+ }
// check mod versions
if (mods.Any())
diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj
index 969071cf..6344cb2f 100644
--- a/src/SMAPI/SMAPI.csproj
+++ b/src/SMAPI/SMAPI.csproj
@@ -16,7 +16,7 @@
<PackageReference Include="LargeAddressAware" Version="1.0.5" />
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
- <PackageReference Include="Platonymous.TMXTile" Version="1.5.6" />
+ <PackageReference Include="Platonymous.TMXTile" Version="1.5.8" />
</ItemGroup>
<ItemGroup>