Skip to content

Commit 8796836

Browse files
marilyniasmarilynias
and
marilynias
authored
Ask to wield container if parent container is too small to insert items (#79518)
* Ask to wield container if parent container is too small * spaace * Wording * explicity check is_avatar instead of !is_npc * add number of items * carrier->wield instead of carrier->wield_contents, remove comma * reword query --------- Co-authored-by: marilynias <[email protected]>
1 parent b6438a2 commit 8796836

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/activity_actor.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5114,6 +5114,20 @@ static ret_val<void> try_insert( item_location &holster, drop_location &holstere
51145114
return ret;
51155115
}
51165116
ret = holster.parents_can_contain_recursive( &it );
5117+
if( !ret.success() ) {
5118+
if( carrier->is_avatar() && query_yn(
5119+
_( "The parent container does not have enough space to fit more items. Would you like to first wield %s to fit more?" ),
5120+
holster->tname() )
5121+
&&
5122+
// wield the container
5123+
carrier->wield( *holster.get_item() ) ) {
5124+
holster = carrier->get_wielded_item();
5125+
5126+
// and recheck if parent can hold (there should be no parent)
5127+
ret = holster.parents_can_contain_recursive( &it );
5128+
5129+
}
5130+
}
51175131
if( !ret.success() ) {
51185132
return ret;
51195133
}
@@ -5128,6 +5142,19 @@ static ret_val<void> try_insert( item_location &holster, drop_location &holstere
51285142
ret_val<int> max_parent_charges = holster.max_charges_by_parent_recursive( it );
51295143
if( !max_parent_charges.success() ) {
51305144
return ret_val<void>::make_failure( max_parent_charges.str() );
5145+
} else if( carrier->is_avatar() && max_parent_charges.value() < holstered_item.second ) {
5146+
// if you cannot fit all items because parent container is too small
5147+
if( query_yn(
5148+
_( "The parent container does not have enough space to fit more than %i %s. Would you like to first wield %s to fit more?" ),
5149+
max_parent_charges.value(), it.tname( max_parent_charges.value() ), holster->tname() )
5150+
&&
5151+
// wield the container
5152+
carrier->wield( *holster.get_item() ) ) {
5153+
holster = carrier->get_wielded_item();
5154+
5155+
// and recalc max_parent_charges
5156+
max_parent_charges = holster.max_charges_by_parent_recursive( it );
5157+
}
51315158
}
51325159
int charges_to_insert = std::min( holstered_item.second, max_parent_charges.value() );
51335160
*charges_added = holster->fill_with( it, charges_to_insert, /*unseal_pockets=*/true,

0 commit comments

Comments
 (0)