diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-11-11 01:22:45 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-11-11 01:22:45 -0500 |
commit | 0629f19698c9920e2988d96f316d227f97932df8 (patch) | |
tree | d7b2d872d482179b82616fe23eaade667a776725 /src/SMAPI/Framework/SCore.cs | |
parent | 9fd8c35b462bc19efb520da21cda66f83559a66e (diff) | |
download | SMAPI-0629f19698c9920e2988d96f316d227f97932df8.tar.gz SMAPI-0629f19698c9920e2988d96f316d227f97932df8.tar.bz2 SMAPI-0629f19698c9920e2988d96f316d227f97932df8.zip |
change new fields to hash sets & simplify sorting
This makes the mod IDs case-insensitive (like the 'SuppressUpdateChecks' field), fixes a build error in unit tests, and avoids re-scanning the mod list multiple times.
Diffstat (limited to 'src/SMAPI/Framework/SCore.cs')
-rw-r--r-- | src/SMAPI/Framework/SCore.cs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 4d1eb959..fb835002 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -424,19 +424,27 @@ namespace StardewModdingAPI.Framework mods = mods.Where(p => !p.IsIgnored).ToArray(); // warn about mods that should load early or late which are not found at all, or both - foreach (string modId in this.Settings.ModsToLoadEarly) - if (!mods.Any(m => m.Manifest.UniqueID == modId)) - this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load early, but it could not be found or was skipped.", LogLevel.Warn); - foreach (string modId in this.Settings.ModsToLoadLate) - if (!mods.Any(m => m.Manifest.UniqueID == modId)) - this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load late, but it could not be found or was skipped.", LogLevel.Warn); - foreach (string modId in this.Settings.ModsToLoadEarly) - if (this.Settings.ModsToLoadLate.Contains(modId)) - this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load both early and late - this will be ignored.", LogLevel.Warn); + { + HashSet<string> installedIds = new HashSet<string>(mods.Select(p => p.Manifest.UniqueID), StringComparer.OrdinalIgnoreCase); + + foreach (string modId in this.Settings.ModsToLoadEarly) + { + if (!installedIds.Contains(modId)) + this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load early, but it could not be found or was skipped.", LogLevel.Warn); + } + foreach (string modId in this.Settings.ModsToLoadLate) + { + if (this.Settings.ModsToLoadEarly.Contains(modId)) + this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load both early and late - this will be ignored.", LogLevel.Warn); + else if (!installedIds.Contains(modId)) + this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load late, but it could not be found or was skipped.", LogLevel.Warn); + } + } // load mods resolver.ValidateManifests(mods, Constants.ApiVersion, toolkit.GetUpdateUrl, getFileLookup: this.GetFileLookup); - mods = resolver.ProcessDependencies(mods, this.Settings.ModsToLoadEarly, this.Settings.ModsToLoadLate, modDatabase).ToArray(); + mods = resolver.ApplyLoadOrderOverrides(mods, this.Settings.ModsToLoadEarly, this.Settings.ModsToLoadLate); + mods = resolver.ProcessDependencies(mods, modDatabase).ToArray(); this.LoadMods(mods, this.Toolkit.JsonHelper, this.ContentCore, modDatabase); // check for software likely to cause issues |