log trace message if conflicting software is detected

This commit is contained in:
Jesse Plamondon-Willard 2021-06-24 20:17:34 -04:00
parent 4df8f4a656
commit 66f8920c29
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 56 additions and 0 deletions

View File

@ -17,6 +17,7 @@
* Added `World.FurnitureListChanged` event (thanks to DiscipleOfEris!). * Added `World.FurnitureListChanged` event (thanks to DiscipleOfEris!).
* Added asset propagation for building/house paint masks. * Added asset propagation for building/house paint masks.
* Added validation for the manifest `Dependencies` field. * Added validation for the manifest `Dependencies` field.
* Added `TRACE` message if software known to cause issues is installed (currently MSI Afterburner and RivaTuner), to simplify troubleshooting.
* Fixed [JSON schema](technical/web.md#using-a-schema-file-directly) in Visual Studio Code warning about comments or trailing commas. * Fixed [JSON schema](technical/web.md#using-a-schema-file-directly) in Visual Studio Code warning about comments or trailing commas.
* Fixed JSON schema for `i18n` files requiring the wrong value for the `$schema` field. * Fixed JSON schema for `i18n` files requiring the wrong value for the `$schema` field.
* Fixed validation for mods with version `0.0.0`. * Fixed validation for mods with version `0.0.0`.

View File

@ -11,6 +11,9 @@ using System.Security;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
#if SMAPI_FOR_WINDOWS
using Microsoft.Win32;
#endif
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
#if SMAPI_FOR_XNA #if SMAPI_FOR_XNA
using System.Windows.Forms; using System.Windows.Forms;
@ -376,6 +379,9 @@ namespace StardewModdingAPI.Framework
mods = resolver.ProcessDependencies(mods, modDatabase).ToArray(); mods = resolver.ProcessDependencies(mods, modDatabase).ToArray();
this.LoadMods(mods, this.Toolkit.JsonHelper, this.ContentCore, modDatabase); this.LoadMods(mods, this.Toolkit.JsonHelper, this.ContentCore, modDatabase);
// check for software likely to cause issues
this.CheckForSoftwareConflicts();
// check for updates // check for updates
this.CheckForUpdatesAsync(mods); this.CheckForUpdatesAsync(mods);
} }
@ -1251,6 +1257,55 @@ namespace StardewModdingAPI.Framework
this.LogManager.SetConsoleTitle(consoleTitle); 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> /// <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> /// <param name="mods">The mods to include in the update check (if eligible).</param>
private void CheckForUpdatesAsync(IModMetadata[] mods) private void CheckForUpdatesAsync(IModMetadata[] mods)