Pathoschild / SMAPI

The modding API for Stardew Valley.
https://smapi.io/
GNU Lesser General Public License v3.0
1.72k stars 259 forks source link

Better handle duplicate mods #321

Closed Pathoschild closed 7 years ago

Pathoschild commented 7 years ago

When the player has multiple copies of the same mod, SMAPI loads the first one and then shows an error like this for the second:

Skipped Trainer Mod because its DLL 'TrainerMod.dll' couldn't be loaded:
System.InvalidOperationException: Could not load 'C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods\TrainerMod\TrainerMod.dll' because it doesn't exist.
   at StardewModdingAPI.Framework.ModLoading.AssemblyLoader.Load(String assemblyPath, Boolean assumeCompatible) in D:\source\_Stardew\SMAPI\src\StardewModdingAPI\Framework\ModLoading\AssemblyLoader.cs:line 69
   at StardewModdingAPI.Program.LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, SContentManager contentManager, IList`1 deprecationWarnings) in D:\source\_Stardew\SMAPI\src\StardewModdingAPI\Program.cs:line 598

Improve how duplicate mods are handled.

Pathoschild commented 7 years ago

Proposed solution:

If the mods have the same UniqueID in their manifest, load the one with the highest version; otherwise load the first one. For mods not loaded, show an error like this:

Skipped Trainer Mod in Mods/TrainerMod-copy because its assembly is already loaded from Mods/TrainerMod.

spacechase0 commented 7 years ago

Would maybe an error in the console (similar to dependency problems) be better? I'm mainly thinking for if the user goes to edit a config file, and it ends up being the one that isn't loaded.

Pathoschild commented 7 years ago

Yep, the error I mentioned would be shown in the console for the duplicates. The error would mention which one was loaded.

spacechase0 commented 7 years ago

Sorry, I meant an error instead of either being loaded.

Pathoschild commented 7 years ago

Yes, I might do that. The mods themselves might be the same, but as you said they may have configured them differently.

Pathoschild commented 7 years ago

Every mod in SMAPI 2.0 must have a unique ID. After #323, SMAPI will refuse to load mods which share a unique ID. That pretty much implements this ticket too, since duplicate mods will have the same ID.