summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-24 00:23:48 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-24 00:23:48 -0400
commit0863f9b7e5f165f2b1db8750b20ed35bc0c3701a (patch)
tree30f7f83e6c699c03081067b01b3fd62a2846e6fc /src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
parent33af789e2eb4da101cead531b77c29ecf4933549 (diff)
downloadSMAPI-0863f9b7e5f165f2b1db8750b20ed35bc0c3701a.tar.gz
SMAPI-0863f9b7e5f165f2b1db8750b20ed35bc0c3701a.tar.bz2
SMAPI-0863f9b7e5f165f2b1db8750b20ed35bc0c3701a.zip
revamp mod compatibility fields to allow broader use of mod data records (#361)
Diffstat (limited to 'src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs')
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs49
1 files changed, 20 insertions, 29 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
index 3674faec..31ba5bc5 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
@@ -61,14 +61,7 @@ namespace StardewModdingAPI.Framework.ModLoading
string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll;
// get data record
- dataRecord = (
- from mod in dataRecords
- where
- mod.ID.Matches(key, manifest)
- && (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion))
- && (mod.UpperVersion == null || !manifest.Version.IsNewerThan(mod.UpperVersion))
- select mod
- ).FirstOrDefault();
+ dataRecord = dataRecords.FirstOrDefault(record => record.ID.Matches(key, manifest));
}
// build metadata
@@ -98,28 +91,26 @@ namespace StardewModdingAPI.Framework.ModLoading
continue;
// validate compatibility
+ ModCompatibility compatibility = mod.DataRecord?.GetCompatibility(mod.Manifest.Version);
+ switch (compatibility?.Status)
{
- ModDataRecord dataRecord = mod.DataRecord;
- switch (dataRecord?.Status)
- {
- case ModStatus.Obsolete:
- mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {dataRecord.ReasonPhrase}");
- continue;
-
- case ModStatus.AssumeBroken:
- {
- string reasonPhrase = dataRecord.ReasonPhrase ?? "it's no longer compatible";
- string error = $"{reasonPhrase}. Please check for a ";
- if (mod.Manifest.Version.Equals(dataRecord.UpperVersion) && dataRecord.UpperVersionLabel == null)
- error += "newer version";
- else
- error += $"version newer than {dataRecord.UpperVersionLabel ?? dataRecord.UpperVersion.ToString()}";
- error += " at " + string.Join(" or ", dataRecord.UpdateUrls);
-
- mod.SetStatus(ModMetadataStatus.Failed, error);
- continue;
- }
- }
+ case ModStatus.Obsolete:
+ mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {compatibility.ReasonPhrase}");
+ continue;
+
+ case ModStatus.AssumeBroken:
+ {
+ string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
+ string error = $"{reasonPhrase}. Please check for a ";
+ if (mod.Manifest.Version.Equals(compatibility.UpperVersion))
+ error += "newer version";
+ else
+ error += $"version newer than {compatibility.UpperVersion}";
+ error += " at " + string.Join(" or ", mod.DataRecord.UpdateUrls);
+
+ mod.SetStatus(ModMetadataStatus.Failed, error);
+ }
+ continue;
}
// validate SMAPI version