feat: validate mods compatibility when trying to load saved games#490
Open
LordMidas wants to merge 21 commits intodevelopmentfrom
Open
feat: validate mods compatibility when trying to load saved games#490LordMidas wants to merge 21 commits intodevelopmentfrom
LordMidas wants to merge 21 commits intodevelopmentfrom
Conversation
fc326c8 to
531f3f8
Compare
Darxo
suggested changes
Apr 17, 2026
| { | ||
| local info = split(mod, this.ModInfoSeparator); | ||
| local mod = ::Hooks.SQClass.Mod(info[0], info[2], info[1], this.EmptyTable); | ||
| if (info[3] != "x") |
Contributor
There was a problem hiding this comment.
The 3 should be a static class variable with a name. Especially since you later use a [3] magic number a second time where it is not clear if both of those values mean the same thing
| mod.require(this.__getCompatString(req)); | ||
| } | ||
| } | ||
| if (info[4] != "x") |
Contributor
There was a problem hiding this comment.
4 should be a static class variable
796dc9d to
dd52355
Compare
This will hopefully avoid any pitfalls if metadata has a limit on the length of strings. Also makes it probably more readable when the data is printed out.
6c1be3b to
87c2a36
Compare
Different from native squirrel split which considers every character in the `_delimiter` string to be a delimiter rather than the entire `_delimiter` string as the delimiter.
Because for required mods you already have them installed otherwise modern hooks won't let you get to main menu without error. We should not validate requirements for installed mods in savegames because it will make it impossible to continue your older save if a mod updates a dependency requirement e.g. requires MSU 1.8.0 will make it impossible to load saves made with MSU 1.7.0. If you really don't want an older save to be loadable you should declare conflict with that version.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Usage
This system is meant to seamlessly blend with Modern Hooks. Use Modern Hooks and declare your requirements/conflicts as normal. This info will be saved to the save file and will be automatically used to validate compatibility.
Declaring your mod as unsafe to add to existing saves
Use Modern Hooks and require your own mod i.e.
Declaring your mod incompatible with older versions of itself
Use Modern Hooks and require a version of your mod:
Applying a compatibility patch to remove declared incompatibilities
During savegame compatibility validation, you can adjust the CompatibilityData stored in the save file. For this, you need to use the MSU Serialization system. This can be useful when creating compatibility patches or creating forks of mods with different ids and declaring yourself compatible with save games that require the original mod.