map: update active items cache when removing contents #62916
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
None
Purpose of change
Removing active items from an otherwise inactive container does not properly update the active item cache because the container's processing speed changes.
Fixes the
place_player_can_safely_move_multiple_submaps
failure that has been plaguing CI jobs lately, for example:https://github.com/CleverRaven/Cataclysm-DDA/actions/runs/3793690000/jobs/6451047981#step:17:349
https://github.com/CleverRaven/Cataclysm-DDA/actions/runs/3789774728/jobs/6445913140#step:17:305
https://github.com/CleverRaven/Cataclysm-DDA/actions/runs/3773072901/jobs/6414342348#step:17:264
Describe the solution
Update the active item cache when removing items with
item_location::impl::item_in_container::remove_item()
(used by shop restock code, for example)If the container of the item-to-be-removed isn't active (anymore), remove it from all active queues.
Describe alternatives you've considered
N/A
Testing
New test unit
Also ran
while :; do ../build_lto/cata_test --rng-seed time --min-duration 0.2 --use-colour yes "npc does healing",place_player_can_safely_move_multiple_submaps;ret=$?;if [[ "$ret" != '0' ]];then break;fi;done
for a couple of hours with no issuesAdditional context
The test unit
place_player_can_safely_move_multiple_submaps
is really bad because it doesn't set up anything and can only catch issues by happenstance. However, it caught this (almost) completely unrelated issue so I'll leave it alone for now. I've only updated it a little bit so it's a bit more clear what's failing.