summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-06-24 20:17:34 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-06-24 20:17:34 -0400
commit66f8920c29567de615dbcb0a06e78f774d128f6b (patch)
treed6c806f142fe691a84aa84f36979e39460b9882f /src/SMAPI
parent4df8f4a656ce68b5bb7dc76eefd6da9c27620928 (diff)
downloadSMAPI-66f8920c29567de615dbcb0a06e78f774d128f6b.tar.gz
SMAPI-66f8920c29567de615dbcb0a06e78f774d128f6b.tar.bz2
SMAPI-66f8920c29567de615dbcb0a06e78f774d128f6b.zip
log trace message if conflicting software is detected
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/SCore.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index bf88798b..2de2b21a 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -11,6 +11,9 @@ using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+#if SMAPI_FOR_WINDOWS
+using Microsoft.Win32;
+#endif
using Microsoft.Xna.Framework;
#if SMAPI_FOR_XNA
using System.Windows.Forms;
@@ -376,6 +379,9 @@ namespace StardewModdingAPI.Framework
mods = resolver.ProcessDependencies(mods, modDatabase).ToArray();
this.LoadMods(mods, this.Toolkit.JsonHelper, this.ContentCore, modDatabase);
+ // check for software likely to cause issues
+ this.CheckForSoftwareConflicts();
+
// check for updates
this.CheckForUpdatesAsync(mods);
}
@@ -1251,6 +1257,55 @@ namespace StardewModdingAPI.Framework
this.LogManager.SetConsoleTitle(consoleTitle);
}
+ /// <summary>Log a warning if software known to cause issues is installed.</summary>
+ private void CheckForSoftwareConflicts()
+ {
+#if SMAPI_FOR_WINDOWS
+ this.Monitor.Log("Checking for known software conflicts...");
+
+ try
+ {
+ string[] registryKeys = { @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" };
+
+ string[] installedNames = registryKeys
+ .SelectMany(registryKey =>
+ {
+ using RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey);
+ if (key == null)
+ return new string[0];
+
+ return key
+ .GetSubKeyNames()
+ .Select(subkeyName =>
+ {
+ using RegistryKey subkey = key.OpenSubKey(subkeyName);
+ string displayName = (string)subkey?.GetValue("DisplayName");
+ string displayVersion = (string)subkey?.GetValue("DisplayVersion");
+
+ if (displayName != null && displayVersion != null && displayName.EndsWith($" {displayVersion}"))
+ displayName = displayName.Substring(0, displayName.Length - displayVersion.Length - 1);
+
+ return displayName;
+ })
+ .ToArray();
+ })
+ .Where(name => name != null && (name.Contains("MSI Afterburner") || name.Contains("RivaTuner")))
+ .Distinct()
+ .OrderBy(name => name)
+ .ToArray();
+
+ if (installedNames.Any())
+ this.Monitor.Log($" Found {string.Join(" and ", installedNames)} installed, which can conflict with SMAPI. If you experience errors or crashes, try disabling that software or adding an exception for SMAPI / Stardew Valley.");
+ else
+ this.Monitor.Log(" None found!");
+ }
+ catch (Exception ex)
+ {
+ this.Monitor.Log($"Failed when checking for conflicting software. Technical details:\n{ex}");
+ }
+#endif
+ }
+
/// <summary>Asynchronously check for a new version of SMAPI and any installed mods, and print alerts to the console if an update is available.</summary>
/// <param name="mods">The mods to include in the update check (if eligible).</param>
private void CheckForUpdatesAsync(IModMetadata[] mods)