diff --git a/docs/release-notes.md b/docs/release-notes.md
index 89883f87..4de0fa66 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -10,6 +10,8 @@
## Upcoming release
* For players:
* The SMAPI installer now also detects game folders listed in Steam's `.vdf` library data on Windows (thanks to pizzaoverhead!).
+ * SMAPI now prevents mods from enabling Harmony debug mode, which impacts performance and creates a file on your desktop.
+ _You can allow debug mode by editing `smapi-internal/config.json` in your game folder._
* Optimized performance and memory usage (thanks to atravita!).
* Other internal optimizations.
* Added more file extensions to ignore when searching for mod folders: `.7z`, `.tar`, `.tar.gz`, and `.xcf` (thanks to atravita!).
diff --git a/src/SMAPI/Framework/Models/SConfig.cs b/src/SMAPI/Framework/Models/SConfig.cs
index 9444c046..b3061fba 100644
--- a/src/SMAPI/Framework/Models/SConfig.cs
+++ b/src/SMAPI/Framework/Models/SConfig.cs
@@ -23,7 +23,8 @@ namespace StardewModdingAPI.Framework.Models
[nameof(LogNetworkTraffic)] = false,
[nameof(RewriteMods)] = true,
[nameof(UseRawImageLoading)] = true,
- [nameof(UseCaseInsensitivePaths)] = Constants.Platform is Platform.Android or Platform.Linux
+ [nameof(UseCaseInsensitivePaths)] = Constants.Platform is Platform.Android or Platform.Linux,
+ [nameof(SuppressHarmonyDebugMode)] = true
};
/// The default values for , to log changes if different.
@@ -79,6 +80,9 @@ namespace StardewModdingAPI.Framework.Models
/// The colors to use for text written to the SMAPI console.
public ColorSchemeConfig ConsoleColors { get; set; }
+ /// Whether to prevent mods from enabling Harmony's debug mode, which impacts performance and creates a file on your desktop. Debug mode should never be enabled by a released mod.
+ public bool SuppressHarmonyDebugMode { get; set; }
+
/// The mod IDs SMAPI should ignore when performing update checks or validating update keys.
public HashSet SuppressUpdateChecks { get; set; }
@@ -99,8 +103,9 @@ namespace StardewModdingAPI.Framework.Models
/// >Whether to make SMAPI file APIs case-insensitive, even on Linux.
/// Whether SMAPI should log network traffic.
/// The colors to use for text written to the SMAPI console.
+ /// Whether to prevent mods from enabling Harmony's debug mode, which impacts performance and creates a file on your desktop. Debug mode should never be enabled by a released mod.
/// The mod IDs SMAPI should ignore when performing update checks or validating update keys.
- public SConfig(bool developerMode, bool? checkForUpdates, bool? paranoidWarnings, bool? useBetaChannel, string gitHubProjectName, string webApiBaseUrl, string[]? verboseLogging, bool? rewriteMods, bool? useRawImageLoading, bool? useCaseInsensitivePaths, bool? logNetworkTraffic, ColorSchemeConfig consoleColors, string[]? suppressUpdateChecks)
+ public SConfig(bool developerMode, bool? checkForUpdates, bool? paranoidWarnings, bool? useBetaChannel, string gitHubProjectName, string webApiBaseUrl, string[]? verboseLogging, bool? rewriteMods, bool? useRawImageLoading, bool? useCaseInsensitivePaths, bool? logNetworkTraffic, ColorSchemeConfig consoleColors, bool? suppressHarmonyDebugMode, string[]? suppressUpdateChecks)
{
this.DeveloperMode = developerMode;
this.CheckForUpdates = checkForUpdates ?? (bool)SConfig.DefaultValues[nameof(this.CheckForUpdates)];
@@ -114,6 +119,7 @@ namespace StardewModdingAPI.Framework.Models
this.UseCaseInsensitivePaths = useCaseInsensitivePaths ?? (bool)SConfig.DefaultValues[nameof(this.UseCaseInsensitivePaths)];
this.LogNetworkTraffic = logNetworkTraffic ?? (bool)SConfig.DefaultValues[nameof(this.LogNetworkTraffic)];
this.ConsoleColors = consoleColors;
+ this.SuppressHarmonyDebugMode = suppressHarmonyDebugMode ?? (bool)SConfig.DefaultValues[nameof(this.SuppressHarmonyDebugMode)];
this.SuppressUpdateChecks = new HashSet(suppressUpdateChecks ?? Array.Empty(), StringComparer.OrdinalIgnoreCase);
}
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index 114c4bb3..3e6cd853 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -501,6 +501,15 @@ namespace StardewModdingAPI.Framework
return;
}
+ /*********
+ ** Prevent Harmony debug mode
+ *********/
+ if (HarmonyLib.Harmony.DEBUG && this.Settings.SuppressHarmonyDebugMode)
+ {
+ HarmonyLib.Harmony.DEBUG = false;
+ this.Monitor.LogOnce("A mod enabled Harmony debug mode, which impacts performance and creates a file on your desktop. SMAPI will try to keep it disabled. (You can allow debug mode by editing the smapi-internal/config.json file.)", LogLevel.Warn);
+ }
+
#if SMAPI_DEPRECATED
/*********
** Reload assets when interceptors are added/removed
diff --git a/src/SMAPI/SMAPI.config.json b/src/SMAPI/SMAPI.config.json
index 97e8e00c..2d4239ba 100644
--- a/src/SMAPI/SMAPI.config.json
+++ b/src/SMAPI/SMAPI.config.json
@@ -54,12 +54,6 @@ copy all the settings, or you may cause bugs due to overridden changes in future
*/
"UseCaseInsensitivePaths": null,
- /**
- * Whether to use the experimental Pintail API proxying library, instead of the original
- * proxying built into SMAPI itself.
- */
- "UsePintail": true,
-
/**
* Whether to use raw image data when possible, instead of initializing an XNA Texture2D
* instance through the GPU.
@@ -138,6 +132,14 @@ copy all the settings, or you may cause bugs due to overridden changes in future
}
},
+ /**
+ * Whether to prevent mods from enabling Harmony's debug mode, which impacts performance and
+ * creates a file on your desktop. Debug mode should never be enabled by a released mod.
+ *
+ * If you actually need debug mode to test your own mod, set this to false.
+ */
+ "SuppressHarmonyDebugMode": true,
+
/**
* The mod IDs SMAPI should ignore when performing update checks or validating update keys.
*/