Skip to content

Commit

Permalink
When placing items in a pet's bag, also consider the maximum length t…
Browse files Browse the repository at this point in the history
…hat can be accommodated (#66750)

* think about length

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
WhiteCloud0123 and github-actions[bot] authored Jul 8, 2023
1 parent bc8f565 commit ebe08f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/monexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,24 @@ bool give_items_to( monster &z )
item &storage = *z.storage_item;
units::mass max_weight = z.weight_capacity() - z.get_carried_weight();
units::volume max_volume = storage.get_total_capacity() - z.get_carried_volume();

units::length max_length = storage.max_containable_length();
avatar &player_character = get_avatar();
drop_locations items = game_menus::inv::multidrop( player_character );
drop_locations to_move;
for( const drop_location &itq : items ) {
const item &it = *itq.first;
units::volume item_volume = it.volume() * itq.second;
units::mass item_weight = it.weight() * itq.second;
units::length item_length = it.length();
if( max_weight < item_weight ) {
add_msg( _( "The %1$s is too heavy for the %2$s to carry." ), it.tname(), pet_name );
continue;
} else if( max_volume < item_volume ) {
add_msg( _( "The %1$s is too big to fit in the %2$s." ), it.tname(), storage.tname() );
continue;
} else if( max_length < item_length ) {
add_msg( _( "The %1$s is too long to fit in the %2$s." ), it.tname(), storage.tname() );
continue;
} else {
max_weight -= item_weight;
max_volume -= item_volume;
Expand Down

0 comments on commit ebe08f3

Please sign in to comment.