Fix starting items settings string roundtrip - #36
Open
flee135 wants to merge 1 commit into
Open
Conversation
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.
Fixes #35.
Starting items are stored either in a starting_items dict or as the lists 'starting_equipment', 'starting_inventory', 'starting_songs'. The encoder and decoder both work under the assumption that the data was in starting_items. But after commit 1be9b08 ("Allow plandoing different settings per world"), the conversion from lists to dict runs in each world's copy of the settings, and the shared Settings object is never normalized.
get_legacy_starting_items() was added to produce the list format using starting_items if populated, and the three lists otherwise. This is used both when encoding and decoding.
Discovery of the bug and the proposed solution are via Claude, and reviewed and slightly tweaked by myself.
Testing
Verified by importing settings strings containing starting items prior to and after the change and checked that the items were still present.