Implement save item corruption prevention #76
Merged
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.
Implemented the system to attempt to prevent item corruption by saving additional information for each item, aside from just their sequential IDs. This hasn't been fully tested with LLL mod item behaviour; there's a lot involved with that which is hard to test without many mods currently implementing scrap using LLL's systems.
This saves a bunch of additional values tied to each item sequential ID and, if it finds out a saved item doesn't load with the same name as before, goes through and fixes every item ID based on a scoring system where a bunch of these saved values are matched together, and they add up to a score which certain variables are much more important to - it then replaces the item's ID with the highest scored one (or, if the score is low enough, just removes the item altogether).
There's probably bound to be some flaw in the system I haven't found yet; an option to toggle this functionality would be good, but I'm not sure how you'd prefer to set that up. If you'd like to implement that yourself, returning early in
SaveManager.LoadShipGrabbableItems
to cancel the process would do the trick.There's also a few general adjustments to saves: