Skip to content

Commit

Permalink
fix: prevent debugmsg while refilling liquid container with another o…
Browse files Browse the repository at this point in the history
…ne (#4010)

check emptiness before removing container contents
  • Loading branch information
scarf005 authored Dec 29, 2023
1 parent 6ade06b commit 552cbe5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8248,8 +8248,11 @@ bool item::reload( player &u, item &loc, int qty )
}
}

// we have transfered ammo from the container to the item
// therefore, we erase the 0-charge item inside container
// TODO: why don't we just remove 0-charge items?
if( ammo->charges == 0 && !ammo->has_flag( flag_SPEEDLOADER ) ) {
if( container != nullptr ) {
if( container != nullptr && !container->contents.empty() ) {
container->remove_item( container->contents.front() );
u.inv_restack( ); // emptied containers do not stack with non-empty ones
} else {
Expand Down

0 comments on commit 552cbe5

Please sign in to comment.