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 eating from vehicle #25017
Fix eating from vehicle #25017
Conversation
The problem is when dragging around a shopping cart and eating some food from a non-resealable container, the game just puts the newly unsealed tin can back in the cart. Putting an opened bucket/non-resealable container back into a vehicle causes the contents to then spill. This is almost certainly not what the player wanted. This fixes the issue by using the same check used in put_into_vehicle() to put potentially spillable things into vehicles. To avoid code duplication this puts the needed functionality into its own function in the item class and refactors put_into_vehicle() to use the new function. Fixes CleverRaven#18168
src/item.cpp
Outdated
@@ -4139,6 +4139,21 @@ const item &item::get_contained() const | |||
return contents.front(); | |||
} | |||
|
|||
bool item::handle_spillable_contents( player &p ) | |||
{ | |||
if( is_bucket_nonempty() && !spill_contents( p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excessive space before &&.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good eye
src/item.cpp
Outdated
@@ -4139,6 +4139,21 @@ const item &item::get_contained() const | |||
return contents.front(); | |||
} | |||
|
|||
bool item::handle_spillable_contents( player &p ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be made a free function bool handle_spillable_contents( player &p, item &it)
since item functions is_bucket_nonempty
and spill_contents
are publicly accessible. This does not need to be a member function.
|
44f8a9d
to
e10a835
Compare
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.
PR #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.
The problem is when dragging around a shopping cart and eating some food
from a non-resealable container, the game just puts the newly unsealed
tin can back in the cart. Putting an opened bucket/non-resealable
container back into a vehicle causes the contents to then spill. This
is almost certainly not what the player wanted.
This fixes the issue by using the same check used in put_into_vehicle()
to put potentially spillable things into vehicles. To avoid code
duplication this puts the needed functionality into its own function into
pickup.h/cpp and refactors put_into_vehicle() to use the new function.
As a side affect, this fixes the player being able to have spillable buckets in
their inventory if they start as sealed and become unsealed.
A future fix should probably add the option to wield the container directly
as well.
Fixes #18168
SUMMARY: Bugfixes "Fix eating from tin cans from a vehicle"