Weight cache invalidation where needed #44661
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
SUMMARY: Bugfixes "Containers not updating weight in certain situations"
Purpose of change
Fixes #43328
This addresses a number of situations where weight is not updated because the cache is not invalidated.
Reload of a wielded tank that cannot be placed in inventory would not add any weight for the contents.
Unloading the same tank would not change the weight even if the starting weight was correct.
Unloading of a container on the map to one being wielded would not update the weight.
Loading of a wielded container from infinite source would not update the weight.
Wearing a backpack that cannot be placed in inventory from the map would not add the weight.
Describe the solution
Added cache invalidation to fix the situations above plus potentially others which use the same methods. Attempted to limit the invalidation to situations where weight would change such as loading with ammo from the map.
Describe alternatives you've considered
Testing
Tested the situations listed above.
Passed all unit tests.
There is a related problem with weapons loading magazines from the map not updating the weight. It is proving elusive to solve so will leave for another PR.
Additional context