fix: Multiple mod versions
Associated mods PR: https://github.com/R2Northstar/NorthstarMods/pull/824
Problem
Whether through manual installation or through mod auto-downloading, several versions of the same mod can be installed in Northstar, which currently does not handle this:
This video was recorded using a profile with two Parkour mod versions, v0.1.2 and v0.2.1: note how the client does not distinguish between the two versions (version displayed in the UI is the same for both mods), and is not capable of (de)activating any of them.
Description
New enabledmods.json format
Since the current enabledmods.json format does not allow for multiple mod versions, it has been reworked.
With this PR, if "old" file format is detected, enabledmods.json will automatically be converted to "new" format.
Old format
{
"Northstar.Client": true,
"Northstar.Coop": true,
"Northstar.CustomServers": true,
"Northstar.Custom": true,
"MRVN Shake It": true,
"Titan Payload": false,
"Parkour": true
}
New format
{
"Northstar.Client": {
"1.19.0": true
},
"Northstar.Coop": {
"0.0.0": true
},
"Northstar.CustomServers": {
"1.19.0": true
},
"Northstar.Custom": {
"1.19.0": false
},
"Parkour": {
"0.1.2": false,
"0.2.1": true
},
"MRVN Shake It": {
"0.0.1": true
},
"Titan Payload": {
"1.2.0": false
}
}
(new enabledmods.json format also means mod managers will have to adapt)
Squirrel-exposed functions
- Functions were reworked to take mod version into account:
NSIsModEnabled(string modName)is nowNSIsModEnabled(string modName, string modVersion);NSSetModEnabled(string modName, bool enabled)is nowNSSetModEnabled(string modName, string modVersion, bool enabled);NSIsModRemote(string modName)is nowNSIsModRemote(string modName, string modVersion);NSGetModVersionByModName(string modName)is nowNSGetModVersions(string modName);
- A lot of functions loop over the list of local mods to retrieve some mod attribute (mod description, download link etc); these functions are called one after the other in the VM, therefore making useless loops over the list of mods:
- To fix that, we add a
NSGetModsInformationmethod, that returns a list of mods with all associated information at once (and not only names likeNSGetModNamescurrently does it); - As the information they provided is now accessible through
NSGetModsInformation, the following functions were removed:NSGetModDescriptionByModName,NSGetModDownloadLinkByModName,NSGetModLoadPriority,NSIsModRequiredOnClient,NSGetModConvarsByModName
- To fix that, we add a
Result
multiple_versions_handling.webm
This video was recorded using a profile with two Parkour mod versions, v0.1.2 and v0.2.1: the client now differentiate the two versions (they both appear correctly on the UI), and is capable (de)activating any of them.
Closes #670. Closes #757.
Testing (manifesto format)
As this PR modifies your enabledmods.json file, you might want to copy it somewhere safe before testing.
Test scenarios
- Old format refers to the following configuration format: mod name => boolean value
- New format refers to the following configuration format: mod name => version string => boolean value
Launch game:
with no enabledmods.json file at all
enabledmods.jsonshould be created using new format
with an invalid enabledmods.json file (not following JSON format)
- invalid
enabledmods.jsonshould be renamed intoenabledmods.json.old enabledmods.jsonshould be created using new format
with enabledmods.json using old format
enabledmods.jsonfile should be renamed intoenabledmods.json.oldenabledmods.jsonshould be recreated using new format
with enabledmods.json using new format
- game should start and load mods according to
enabledmods.jsonconfiguration (you can check that in the Mods menu)
TODOs
- [x] If old manifesto format is detected, rename file and recreate file using new format
- [x] Mutualise file creation code with
UnloadModsmethod - [x] Check whether I can remove
GenerateModsConfigurationFilemethod (since mod entries are already created ~L667) - [x] Rename original file if it exists
- [x] Convert old format to new format
- [x] Mutualise file creation code with
- [x] Use new manifesto format to load mods config into the client
- [x] Remove all code related to old format
- [x] Remove new script package and update old functions instead (e.g.
NSSetModEnabled(name,booltoNSSetModEnabled(name,ver,bool)- [x] Mirror changes in mods
The two PRs are now ready for review, I'll gladly take any feedback.
Note: merging https://github.com/R2Northstar/NorthstarLauncher/pull/826 first should ease reviewing this PR.
Is any additional testing required? I should be available tomorrow at around 6:00 PM CDT
Is any additional testing required? I should be available tomorrow at around 6:00 PM CDT
Testing is necessary at all, yep! Kind reminder that you need to install both launcher and mods PRs before testing; testing instructions are listed on each PR webpage. (don't hesitate to ping me if you need more info!)
https://github.com/R2Northstar/NorthstarLauncher/pull/826 has been merged, but some (previously removed) functions were added back during the process (e.g. NSIsModRequiredOnClient).
Moving this to draft while I fix the issue.
Don't play with --force, kids.
Closing in favor of https://github.com/R2Northstar/NorthstarLauncher/pull/828.