Skip to content

Commit

Permalink
Fix for spawning liquids with no charges (#35253)
Browse files Browse the repository at this point in the history
* potential fix for spawning liquids with no charges

* astyle
  • Loading branch information
RDru authored and ZhilkinSerg committed Nov 3, 2019
1 parent 3c1dcd1 commit 8dfe969
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ ret_val<edible_rating> player::will_eat( const item &food, bool interactive ) co
add_consequence( _( "Your stomach won't be happy (not rotten enough)." ), ALLERGY_WEAK );
}

if( stomach.stomach_remaining() < food.volume() / food.charges && !food.has_infinite_charges() ) {
if( food.charges > 0 && stomach.stomach_remaining() < food.volume() / food.charges &&
!food.has_infinite_charges() ) {
if( edible ) {
add_consequence( _( "You're full already and will be forcing yourself to eat." ), TOO_FULL );
} else {
Expand Down
11 changes: 4 additions & 7 deletions src/item_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,9 @@ void Item_modifier::modify( item &new_item ) const
}
}

if( max_capacity == -1 && !cont.is_null() ) {
if( new_item.made_of( LIQUID ) ) {
max_capacity = cont.get_remaining_capacity_for_liquid( new_item );
} else if( !new_item.is_tool() && !new_item.is_gun() && !new_item.is_magazine() ) {
max_capacity = new_item.charges_per_volume( cont.get_container_capacity() );
}
if( max_capacity == -1 && !cont.is_null() && ( new_item.made_of( LIQUID ) ||
( !new_item.is_tool() && !new_item.is_gun() && !new_item.is_magazine() ) ) ) {
max_capacity = new_item.charges_per_volume( cont.get_container_capacity() );
}

const bool charges_not_set = charges.first == -1 && charges.second == -1;
Expand All @@ -267,7 +264,7 @@ void Item_modifier::modify( item &new_item ) const
ch = charges_min == charges_max ? charges_min : rng( charges_min,
charges_max );
} else if( !cont.is_null() && new_item.made_of( LIQUID ) ) {
new_item.charges = max_capacity;
new_item.charges = std::max( 1, max_capacity );
}

if( ch != -1 ) {
Expand Down

0 comments on commit 8dfe969

Please sign in to comment.