summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md3
-rw-r--r--src/SMAPI/Framework/Logging/LogManager.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs4
-rw-r--r--src/SMAPI/Framework/Models/SConfig.cs9
-rw-r--r--src/SMAPI/Metadata/InstructionMetadata.cs7
-rw-r--r--src/SMAPI/SMAPI.config.json12
6 files changed, 25 insertions, 20 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 7347560e..fabe7572 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -8,6 +8,9 @@
-->
## Upcoming release
+* For modders:
+ * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This may prevent older mods from loading, but bypasses a Visual Studio crash when debugging.
+
* For the Error Handler mod:
* Added in SMAPI 3.9. This has vanilla error-handling that was previously added by SMAPI directly. That simplifies the core SMAPI logic, and lets players or modders disable it if needed.
diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs
index cc573427..ff00cff7 100644
--- a/src/SMAPI/Framework/Logging/LogManager.cs
+++ b/src/SMAPI/Framework/Logging/LogManager.cs
@@ -208,7 +208,7 @@ namespace StardewModdingAPI.Framework.Logging
// show update alert
if (File.Exists(Constants.UpdateMarker))
{
- string[] rawUpdateFound = File.ReadAllText(Constants.UpdateMarker).Split(new [] { '|' }, 2);
+ 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))
@@ -286,15 +286,15 @@ namespace StardewModdingAPI.Framework.Logging
/// <summary>Log details for settings that don't match the default.</summary>
/// <param name="isDeveloperMode">Whether to enable full console output for developers.</param>
/// <param name="checkForUpdates">Whether to check for newer versions of SMAPI and mods on startup.</param>
- /// ///<param name="rewriteMods">Whether to rewrite mods, might need to be false to hook up to the Visual Studio Debugger.</param>
+ /// <param name="rewriteMods">Whether to rewrite mods for compatibility.</param>
public void LogSettingsHeader(bool isDeveloperMode, bool checkForUpdates, bool rewriteMods)
{
if (isDeveloperMode)
- this.Monitor.Log($"You have SMAPI for developers, so the console will be much more verbose. You can disable developer mode by installing the non-developer version of SMAPI, or by editing {Constants.ApiConfigPath}.", LogLevel.Info);
+ this.Monitor.Log("You have SMAPI for developers, so the console will be much more verbose. You can disable developer mode by installing the non-developer version of SMAPI.", LogLevel.Info);
if (!checkForUpdates)
- this.Monitor.Log($"You configured SMAPI to not check for updates. Running an old version of SMAPI is not recommended. You can enable update checks by reinstalling SMAPI or editing {Constants.ApiConfigPath}.", LogLevel.Warn);
+ this.Monitor.Log("You configured SMAPI to not check for updates. Running an old version of SMAPI is not recommended. You can enable update checks by reinstalling SMAPI.", LogLevel.Warn);
if (!rewriteMods)
- this.Monitor.Log($"You configured SMAPI to not rewrite potentially broken mods. This is not reccomended except in certain circumstances such as attaching to the Visual Studio debugger. You can enable mod rewrites by reinstalling SMAPI or editing {Constants.ApiConfigPath}.", LogLevel.Warn);
+ this.Monitor.Log("You configured SMAPI to not rewrite broken mods. Many older mods may fail to load. You can undo this by reinstalling SMAPI.", LogLevel.Warn);
if (!this.Monitor.WriteToConsole)
this.Monitor.Log("Writing to the terminal is disabled because the --no-terminal argument was received. This usually means launching the terminal failed.", LogLevel.Warn);
this.Monitor.VerboseLog("Verbose logging enabled.");
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
index d6a32621..4fae0f44 100644
--- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
+++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
@@ -37,7 +37,7 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <summary>The objects to dispose as part of this instance.</summary>
private readonly HashSet<IDisposable> Disposables = new HashSet<IDisposable>();
- /// <summary>Whether mods should be re-writen for compatibility.</summary>
+ /// <summary>Whether to rewrite mods for compatibility.</summary>
private readonly bool RewriteMods;
@@ -48,7 +48,7 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <param name="targetPlatform">The current game platform.</param>
/// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="paranoidMode">Whether to detect paranoid mode issues.</param>
- /// <param name="rewriteMods">Whether to rewrite potentially broken mods or not.</param>
+ /// <param name="rewriteMods">Whether to rewrite mods for compatibility.</param>
public AssemblyLoader(Platform targetPlatform, IMonitor monitor, bool paranoidMode, bool rewriteMods)
{
this.Monitor = monitor;
diff --git a/src/SMAPI/Framework/Models/SConfig.cs b/src/SMAPI/Framework/Models/SConfig.cs
index a5b27c17..dea08717 100644
--- a/src/SMAPI/Framework/Models/SConfig.cs
+++ b/src/SMAPI/Framework/Models/SConfig.cs
@@ -28,6 +28,7 @@ namespace StardewModdingAPI.Framework.Models
private static readonly HashSet<string> DefaultSuppressUpdateChecks = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"SMAPI.ConsoleCommands",
+ "SMAPI.ErrorHandler",
"SMAPI.SaveBackup"
};
@@ -56,6 +57,9 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>Whether SMAPI should log more information about the game context.</summary>
public bool VerboseLogging { get; set; }
+ /// <summary>Whether SMAPI should rewrite mods for compatibility.</summary>
+ public bool RewriteMods { get; set; } = (bool)SConfig.DefaultValues[nameof(SConfig.RewriteMods)];
+
/// <summary>Whether SMAPI should log network traffic. Best combined with <see cref="VerboseLogging"/>, which includes network metadata.</summary>
public bool LogNetworkTraffic { get; set; }
@@ -65,14 +69,11 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>The mod IDs SMAPI should ignore when performing update checks or validating update keys.</summary>
public string[] SuppressUpdateChecks { get; set; }
- /// <summary>Whether to rewrite mods for compatibility. Should only be set to false to facilitate joining to the Visual Studio Debugger.</summary>
- public bool RewriteMods { get; set; } = (bool)SConfig.DefaultValues[nameof(SConfig.RewriteMods)];
-
/********
** Public methods
********/
- /// <summary>Get the settings which have been customised by the player.</summary>
+ /// <summary>Get the settings which have been customized by the player.</summary>
public IDictionary<string, object> GetCustomSettings()
{
IDictionary<string, object> custom = new Dictionary<string, object>();
diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs
index 1816e7f9..d1699636 100644
--- a/src/SMAPI/Metadata/InstructionMetadata.cs
+++ b/src/SMAPI/Metadata/InstructionMetadata.cs
@@ -27,7 +27,7 @@ namespace StardewModdingAPI.Metadata
/// <summary>Get rewriters which detect or fix incompatible CIL instructions in mod assemblies.</summary>
/// <param name="paranoidMode">Whether to detect paranoid mode issues.</param>
/// <param name="platformChanged">Whether the assembly was rewritten for crossplatform compatibility.</param>
- /// <param name="rewriteMods">Whether to return Rewriters</param>
+ /// <param name="rewriteMods">Whether to get handlers which rewrite mods for compatibility.</param>
public IEnumerable<IInstructionHandler> GetHandlers(bool paranoidMode, bool platformChanged, bool rewriteMods)
{
/****
@@ -49,10 +49,11 @@ namespace StardewModdingAPI.Metadata
yield return new HeuristicMethodRewriter(this.ValidateReferencesToAssemblies);
#if HARMONY_2
- // rewrite for SMAPI 3.6 (Harmony 1.x => 2.0 update)
- yield return new Harmony1AssemblyRewriter();
+ // rewrite for SMAPI 3.x (Harmony 1.x => 2.0 update)
+ yield return new Harmony1AssemblyRewriter();
#endif
}
+
/****
** detect mod issues
****/
diff --git a/src/SMAPI/SMAPI.config.json b/src/SMAPI/SMAPI.config.json
index 7b9f76d4..7a710f14 100644
--- a/src/SMAPI/SMAPI.config.json
+++ b/src/SMAPI/SMAPI.config.json
@@ -34,6 +34,12 @@ copy all the settings, or you may cause bugs due to overridden changes in future
"DeveloperMode": true,
/**
+ * Whether SMAPI should rewrite mods for compatibility. This may prevent older mods from
+ * loading, but bypasses a Visual Studio crash when debugging.
+ */
+ "RewriteMods": true,
+
+ /**
* Whether to add a section to the 'mod issues' list for mods which directly use potentially
* sensitive .NET APIs like file or shell access. Note that many mods do this legitimately as
* part of their normal functionality, so these warnings are meaningless without further
@@ -69,12 +75,6 @@ copy all the settings, or you may cause bugs due to overridden changes in future
"LogNetworkTraffic": false,
/**
- * Whether SMAPI should rewrite mods for compatibility.
- * Note: This is best left to true unless you are attempting to hook into the Visual Studio Debugger
- */
- "RewriteMods": true,
-
- /**
* The colors to use for text written to the SMAPI console.
*
* The possible values for 'UseScheme' are: