Skip to content

Commit

Permalink
Fix Character::i_add_or_drop (#73556)
Browse files Browse the repository at this point in the history
* Fix Character::i_add_or_drop

* Update character_inventory.cpp

* Update character_inventory.cpp

* astyle
  • Loading branch information
osuphobia authored May 10, 2024
1 parent 1aca3eb commit 1de57ca
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/character_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,27 +454,25 @@ bool Character::i_add_or_drop( item &it, int qty, const item *avoid,
bool retval = true;
bool drop = it.made_of( phase_id::LIQUID );
bool add = it.is_gun() || !it.is_irremovable();
int added = 0;
inv->assign_empty_invlet( it, *this );
map &here = get_map();
drop |= !can_pickWeight( it, !get_option<bool>( "DANGEROUS_PICKUPS" ) ) || !can_pickVolume( it );
for( int i = 0; i < qty; ++i ) {
drop |= !can_pickWeight( it, !get_option<bool>( "DANGEROUS_PICKUPS" ) ) || !can_pickVolume( it );
if( drop ) {
// No need to loop now, we already knew that there isn't enough room for the item.
retval &= !here.add_item_or_charges( pos(), it ).is_null();
added++;
break;
if( !retval ) {
// No need to loop now, we already knew that there isn't enough room for the item.
break;
}
} else if( add ) {
i_add( it, true, avoid,
original_inventory_item, /*allow_drop=*/true, /*allow_wield=*/!has_wield_conflicts( it ) );
added++;
} else {
retval = false;
break;
}
}

for( int i = added; i < qty; ++i ) {
retval &= !here.add_item_or_charges( pos(), it ).is_null();
}

return retval;
}

Expand Down

0 comments on commit 1de57ca

Please sign in to comment.