diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-17 15:44:18 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-17 15:44:18 -0400 |
commit | bc1e17bc8c0ab23420e000d06a99289bbfe9b530 (patch) | |
tree | 4be8c86bdcbc12a7d208169d2ae5fc7ccea21b84 | |
parent | 228f84eea60e9a2c0eb6abd167ae173a7332974d (diff) | |
download | SMAPI-bc1e17bc8c0ab23420e000d06a99289bbfe9b530.tar.gz SMAPI-bc1e17bc8c0ab23420e000d06a99289bbfe9b530.tar.bz2 SMAPI-bc1e17bc8c0ab23420e000d06a99289bbfe9b530.zip |
fix mod-loading code not accounting for metadata failure
-rw-r--r-- | src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs | 10 | ||||
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs index 53c28ace..2c68a639 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs @@ -131,9 +131,19 @@ namespace StardewModdingAPI.Framework.ModLoading /// <param name="mods">The mods to process.</param> public IEnumerable<IModMetadata> ProcessDependencies(IEnumerable<IModMetadata> mods) { + // initialise metadata mods = mods.ToArray(); var sortedMods = new Stack<IModMetadata>(); var states = mods.ToDictionary(mod => mod, mod => ModDependencyStatus.Queued); + + // handle failed mods + foreach (IModMetadata mod in mods.Where(m => m.Status == ModMetadataStatus.Failed)) + { + states[mod] = ModDependencyStatus.Failed; + sortedMods.Push(mod); + } + + // sort mods foreach (IModMetadata mod in mods) this.ProcessDependencies(mods.ToArray(), mod, states, sortedMods, new List<IModMetadata>()); diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 7a8189bd..3a7cb9ce 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -322,7 +322,7 @@ namespace StardewModdingAPI // check for deprecated metadata IList<Action> deprecationWarnings = new List<Action>(); - foreach (IModMetadata mod in mods) + foreach (IModMetadata mod in mods.Where(m => m.Status != ModMetadataStatus.Failed)) { // missing fields that will be required in SMAPI 2.0 { |