Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault on using spillable comestibles (aluminum cans/tin cans) #25098

Merged
merged 2 commits into from Aug 24, 2018

Conversation

alanbrady
Copy link
Contributor

@alanbrady alanbrady commented Aug 24, 2018

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:

  1. eat soup from a sealed tin can
  2. get query asking what to do with rest of soup
  3. choose e) 'Consume It'
  4. item gets placed on the ground without further queries

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

PR CleverRaven#25017 broke using aluminum cans and caused a duplication bug when
eating from tin cans from inventory.

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.
If the player chooses an action which can cause an item to spill, they
only receive one query about what to do with the contents.

This fixes it so that they continue to receive queries until either the
contents is spilled or the number of charges doesn't change.  If the
number of charges on the contents stays the same that means the player
is choosing not to do anything with the rest of the contents so we
should put it on the ground to avoid spilling it.
@kevingranade kevingranade merged commit 85e47ed into CleverRaven:master Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants