Prevent cleanup of MOLLE pockets on contents update #70163
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.
Summary
Bugfixes "Prevent cleanup of MOLLE pockets on contents update"
Purpose of change
Fixes #70160
Fixes #70126
Fixes #70121
Describe the solution
See #70160 for more details.
When items are removed from a pocket the item pocket contents are updated and any unexpected pockets are removed from the item. Only pockets defined in the item base type are kept. At some point additional pocket support was added through modular containers that can be integrated in a parent item but the cleanup code wasn't updated to not remove those new pockets during cleanups.
This PR makes it so the cleanup function doesn't remove "additional pockets" coming from integrated containers.
The
update_modified_pockets()
function is called only from one place at the moment. This is only a mitigation though and more problems related to the way additional pockets are handled are to be expected. See alternatives for details.Describe alternatives you've considered
A rework of the additional pockets system since it seems to be a very hacky and unmaintainable solution. Currently the integrated items are added to a list of additional storage items while also adding extra pockets to the pocket list itself. The only way to tie the new pockets to the integrated items is through calculating indices based on the amount of pockets added by each item in the list.
This is prone to cause issues if the integrated items are modified down the road (i.e. the number of pockets added is changed) since the indices won't match any longer and their removal will cause issues. The added pockets should be tied uniquely to the item that added them (though a reference to the stored item in
additional_pockets
?) but it's a bigger refactor that I don't want to tackle right now.Testing
Can't reproduce the problem after the changes.
Additional context