Fix segfault on using spillable comestibles (aluminum cans/tin cans) #25098
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 drinking from 'aluminum can' segfault and fix tin cans more"
Purpose of change
PR #25017 broke using aluminum cans and caused a duplication bug when eating from tin cans from inventory.
Inventory/item code is hard.
Describe the solution
This fixes it by adjusting the placement of the call to handle_spillable_contents() to a more appropriate place in the flow of consuming an item. We also check if handle_spillable_content handled our comestible or not. If it did we need to remove it from inventory.
This also fixes a small issue in usability where if you:
User should expect to see another dialog box asking them what to do about the rest of the soup instead of just defaulting to put it on the ground for the remaining portions. This, however was actually a preexisting issue if you tried to put a spillable bucket in a vehicle and chose 'Consume It', the same behavior is observed and the same fix will fix them both.
Additional context
The original issue attempted to be treated here is when eating from a vehicle, the item just gets spilled on the ground instead of handled gracefully. See #18168