Mod requirement warnings not triggering for disabled mods

Discuss modding questions and implementation details.
Post Reply
User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Mod requirement warnings not triggering for disabled mods

Post by Ralzar »

Say you have two mods: Mod1 and Mod2.

Mod2 has a requirement that Mod1 must be present.

If you have both mods in your mod list but deactivate Mod1, when you click Save&Exit, there is no warning from Mod2 that you do not have the required Mod1. As long as it is present in the mod list, it is all fine. Except when you load the game of course, and Mod2 produces errors because its required companion mod has not been loaded in.

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Mod requirement warnings not triggering for disabled mods

Post by pango »

Adding extra warnings seems easy to fix:

Code: Select all

diff --git a/Assets/Game/Addons/ModSupport/ModManager.cs b/Assets/Game/Addons/ModSupport/ModManager.cs
index 5ba88dff9..0a15add81 100644
--- a/Assets/Game/Addons/ModSupport/ModManager.cs
+++ b/Assets/Game/Addons/ModSupport/ModManager.cs
@@ -1051,6 +1051,12 @@ namespace DaggerfallWorkshop.Game.Utility.ModSupport
                         continue;
                     }
 
+                    if (!target.Enabled)
+                    {
+                        errorMessages.Add(string.Format(GetText("dependencyNotEnabled"), dependency.Name));
+                        continue;
+                    }
+
                     // Check load order priority
                     if (!dependency.IsPeer && mod.LoadPriority < target.LoadPriority)
                     {
diff --git a/Assets/StreamingAssets/Text/ModSystem.txt b/Assets/StreamingAssets/Text/ModSystem.txt
index 6e33346c9..bf8b455b5 100644
--- a/Assets/StreamingAssets/Text/ModSystem.txt
+++ b/Assets/StreamingAssets/Text/ModSystem.txt
@@ -63,6 +63,7 @@ titleOrDescriptionMissing,  Title and Description are mandatory fields.
 
 dependencyErrorMessage,                 One or more mods might not work correctly:
 dependencyIsMissing,                    Failed to retrieve mod {0}
+dependencyNotEnabled,                   Mod dependency {0} is not enabled
 dependencyWithIncorrectPosition,        {0} must be positioned above in the load order
 dependencyWithIncompatibleVersion,      {0} has version {1} but {2} or higher is requested
 sortModsQuestion,                       Do you want to sort mods automatically?
I don't know if we want anything more fancy, like propose to enable all needed dependencies (possibly recursively), that could quickly add substantial complexity...
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Mod requirement warnings not triggering for disabled mods

Post by Ralzar »

This has worked fine, but I just discovered one glitch:

If you code your mod with a dependency like this:

Code: Select all

        {
            "Name": "ironman options",
            "IsOptional": true,
            "IsPeer": false,
            "Version": "1.1.2"
        }
And you disable the mod (in this case Ironman Options) you will get the warning.
moddep.PNG
moddep.PNG (61.71 KiB) Viewed 1354 times
I would assume this warning should only trigger if IsOptional: false

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Mod requirement warnings not triggering for disabled mods

Post by Ralzar »

Just wanted to bump this to point out this is still an issue. It's not a huge thing but it is obviously not how this mechanic should work so I am wonderingen if there is a bit of boolean logic that should be switched around here. This check should not be producing the popup above for mods that are not enabled and the mod is defined as ""IsOptional": true,".

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Mod requirement warnings not triggering for disabled mods

Post by pango »

Hi Ralzar,

Sorry, I missed your previous message. Simplest fix would be to add a

Code: Select all

                        if (dependency.IsOptional)
                            continue;
like

Code: Select all

                    if (!target.Enabled)
                    {
                        if (dependency.IsOptional)
                            continue;
                            
                        errorMessages.Add(string.Format(GetText("dependencyNotEnabled"), dependency.Name));
                        continue;
                    }
I created a PR
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Post Reply