Skip to content

Commit

Permalink
Merge pull request CleverRaven#49318 from mqrause/pocket_settings_che…
Browse files Browse the repository at this point in the history
…ck_fix

Ignore pocket settings when manually inserting stackable items
  • Loading branch information
Rivet-the-Zombie authored Jul 8, 2021
2 parents b09bbfe + c04fe4c commit 335ab2a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,8 @@ void insert_item_activity_actor::finish( player_activity &act, Character &who )
if( charges > 0 && holster->can_contain_partial( it ) ) {
int result = holster->fill_with( it, charges,
/*unseal_pockets=*/true,
/*allow_sealed=*/true );
/*allow_sealed=*/true,
/*ignore_settings*/true );
success = result > 0;

if( success ) {
Expand Down
11 changes: 5 additions & 6 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7519,11 +7519,10 @@ bool item::can_contain_partial( const item &it ) const
}

std::pair<item_location, item_pocket *> item::best_pocket( const item &it, item_location &parent,
const bool allow_sealed )
const bool allow_sealed, const bool ignore_settings )
{
item_location nested_location( parent, this );
return contents.best_pocket( it, nested_location, false,
/*allow_sealed=*/allow_sealed );
return contents.best_pocket( it, nested_location, false, allow_sealed, ignore_settings );
}

bool item::spill_contents( Character &c )
Expand Down Expand Up @@ -9128,7 +9127,8 @@ void item::set_item_temperature( float new_temperature )

int item::fill_with( const item &contained, const int amount,
const bool unseal_pockets,
const bool allow_sealed )
const bool allow_sealed,
const bool ignore_settings )
{
if( amount <= 0 ) {
return 0;
Expand All @@ -9147,8 +9147,7 @@ int item::fill_with( const item &contained, const int amount,
if( count_by_charges ) {
contained_item.charges = 1;
}
pocket = best_pocket( contained_item, loc,
/*allow_sealed=*/allow_sealed ).second;
pocket = best_pocket( contained_item, loc, allow_sealed, ignore_settings ).second;
}
if( pocket == nullptr ) {
break;
Expand Down
5 changes: 3 additions & 2 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,8 @@ class item : public visitable
*/
int fill_with( const item &contained, int amount = INFINITE_CHARGES,
bool unseal_pockets = false,
bool allow_sealed = false );
bool allow_sealed = false,
bool ignore_settings = false );

/**
* How much more of this liquid (in charges) can be put in this container.
Expand Down Expand Up @@ -1277,7 +1278,7 @@ class item : public visitable
bool can_contain_partial( const item &it ) const;
/*@}*/
std::pair<item_location, item_pocket *> best_pocket( const item &it, item_location &parent,
bool allow_sealed = false );
bool allow_sealed = false, bool ignore_settings = false );

units::length max_containable_length() const;
units::volume max_containable_volume() const;
Expand Down
4 changes: 2 additions & 2 deletions src/item_contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void item_contents::force_insert_item( const item &it, item_pocket::pocket_type
}

std::pair<item_location, item_pocket *> item_contents::best_pocket( const item &it,
item_location &parent, bool nested, const bool allow_sealed )
item_location &parent, bool nested, const bool allow_sealed, const bool ignore_settings )
{
if( !can_contain( it ).success() ) {
return { item_location(), nullptr };
Expand All @@ -542,7 +542,7 @@ std::pair<item_location, item_pocket *> item_contents::best_pocket( const item &
if( !pocket.can_contain( it ).success() ) {
continue;
}
if( !pocket.settings.accepts_item( it ) ) {
if( !ignore_settings && !pocket.settings.accepts_item( it ) ) {
// Item forbidden by whitelist / blacklist
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/item_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class item_contents
* only checks CONTAINER pocket type
*/
std::pair<item_location, item_pocket *> best_pocket( const item &it, item_location &parent,
bool nested, bool allow_sealed = false );
bool nested, bool allow_sealed = false, bool ignore_settings = false );

units::length max_containable_length() const;
units::volume max_containable_volume() const;
Expand Down

0 comments on commit 335ab2a

Please sign in to comment.