summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModLoading
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-11-11 21:43:42 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-11-11 21:43:42 -0500
commitc1e3b25dcaff2406fa1e3a457c1ba9c0f8ecda7f (patch)
tree954e9fcddbc2f558aaa8c6b39d1f87a958feccb7 /src/SMAPI/Framework/ModLoading
parent9771cefa6a695b9e13737ccf37222810b3de3015 (diff)
downloadSMAPI-c1e3b25dcaff2406fa1e3a457c1ba9c0f8ecda7f.tar.gz
SMAPI-c1e3b25dcaff2406fa1e3a457c1ba9c0f8ecda7f.tar.bz2
SMAPI-c1e3b25dcaff2406fa1e3a457c1ba9c0f8ecda7f.zip
fix load-early/late mods not correctly sorted relative to others in the same list
Diffstat (limited to 'src/SMAPI/Framework/ModLoading')
-rw-r--r--src/SMAPI/Framework/ModLoading/ModResolver.cs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs
index 96975e05..cb62e16f 100644
--- a/src/SMAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs
@@ -174,14 +174,20 @@ namespace StardewModdingAPI.Framework.ModLoading
if (!modIdsToLoadEarly.Any() && !modIdsToLoadLate.Any())
return mods;
+ string[] earlyArray = modIdsToLoadEarly.ToArray();
+ string[] lateArray = modIdsToLoadLate.ToArray();
+
return mods
.OrderBy(mod =>
{
string id = mod.Manifest.UniqueID;
- if (modIdsToLoadEarly.Contains(id))
- return -1;
- if (modIdsToLoadLate.Contains(id))
- return 1;
+
+ if (modIdsToLoadEarly.TryGetValue(id, out string? actualId))
+ return -int.MaxValue + Array.IndexOf(earlyArray, actualId);
+
+ if (modIdsToLoadLate.TryGetValue(id, out actualId))
+ return int.MaxValue - Array.IndexOf(lateArray, actualId);
+
return 0;
})
.ToArray();