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.
Summary
SUMMARY: Bugfixes "fix item_contents save/load"
Purpose of change
related #40127 - possibly fixes it but i haven't checked random item spawns as this doesn't effect them at all
Fixes #40876
Describe the solution
the load function for item_contents incorrectly assumes that the insert_item function will insert the item into the same pocket that the item was saved in - but this is definitely not the case as items are dynamically assigned and possibly specifically assigned by the player. additionall, the MIGRATION item pocket was never utilized such that items won't disappear on save/load.
a weakness of this implementation is the following example: an item has multiple pockets, and someone changes the json to rearrange the pockets, or add a MAGAZINE pocket to the front. in this case, most of the items will be moved to the MIGRATION pocket, necessitating the player to pick up the items after they fall to the ground after moving once.
Testing
several save/load cycles, with 2 army jackets and jeans and assorted sundry of items. also spawned in canned sardines to make sure they stay sealed across the save/load cycle.
Additional context
this might be one of the main things that are causing cans to appear to spawn open, maybe people are saving and loading near enough to houses to have the items spawned and go through the save/load cycle. it's worth reassessing the related bug report after this bugfix.