Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement save item corruption prevention #76

Merged
merged 1 commit into from
May 20, 2024

Conversation

SylviBlossom
Copy link
Contributor

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:

  • New "parityStepsTaken" saves the "StepsTaken" stat which is also saved in the vanilla file and, when loading, if they aren't the same value, any loading of LLLSaveFile values will be cancelled since the LLLSaveFile may be out-of-date
  • The LLLSaveFile class doesn't need a prefix since that's auto-defined, and would have prevented LLL save data from loading if the save was renamed
  • "CurrentLevelName" now only saves to the file when the rest of the game saves to the file

@melvyn2
Copy link

melvyn2 commented Apr 30, 2024

Here's a build of this PR:
LethalLevelLoader.dll.zip
Seems to work so far, even restoring items after loading a corrupted save

@IAmBatby IAmBatby merged commit d1ed196 into IAmBatby:main May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants