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 some item deletion bugs"
Purpose of change
Fixes #40393 where tying an animal would delete whatever contained the rope you used
Related to #42059 (not enough info to know if it fixes it)
Fixes another bug where trying to unwield a container could ask to try to put the container in itself, deleting it
Describe the solution
Using i_rem( item* ) instead of i_rem( int ) (which I honestly think should be removed, not sure if that's possible)
Simple checks to stop a container from considering putting itself in itself
Describe alternatives you've considered
Seeing if switching all Character::i_rem( int ) uses to Character::i_rem( item* ) was possible, but I just want to get these bugs fixed
Testing
Bug 1:
Reproduce the steps in #40393 with their save file
Bug 2:
Strip naked
Wield a backpack
Unwield the backpack
Can no longer choose to put the backpack in itself
Additional context
i_rem( int ) + get_item_position is a dangerous combo, you can easily delete entire containers instead of what's in the container