Skip to content

Commit

Permalink
move item_pocket::pocket_type to it's own header
Browse files Browse the repository at this point in the history
  • Loading branch information
mqrause committed Nov 27, 2023
1 parent db3054e commit bd21196
Show file tree
Hide file tree
Showing 85 changed files with 720 additions and 715 deletions.
24 changes: 12 additions & 12 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ void bookbinder_copy_activity_actor::finish( player_activity &act, Character &p

p.consume_tools( writing_tools, pages );
book_binder->put_in( item( itype_paper, calendar::turn, pages ),
item_pocket::pocket_type::MAGAZINE );
pocket_type::MAGAZINE );
} else {
debugmsg( "Recipe book already has '%s' recipe when it should not.", rec_id.str() );
}
Expand Down Expand Up @@ -2740,7 +2740,7 @@ void ebooksave_activity_actor::completed_scanning_current_book( player_activity
item_location scanned_book = books.back();
books.pop_back();
if( scanned_book ) {
ereader->put_in( *scanned_book, item_pocket::pocket_type::EBOOK );
ereader->put_in( *scanned_book, pocket_type::EBOOK );
if( who.is_avatar() ) {
if( !who.has_identified( scanned_book->typeId() ) ) {
who.identify( *scanned_book );
Expand Down Expand Up @@ -3215,10 +3215,10 @@ void unload_activity_actor::unload( Character &who, item_location &target )
contents_change_handler handler;
bool changed = false;

for( item_pocket::pocket_type ptype : {
item_pocket::pocket_type::CONTAINER,
item_pocket::pocket_type::MAGAZINE_WELL,
item_pocket::pocket_type::MAGAZINE
for( pocket_type ptype : {
pocket_type::CONTAINER,
pocket_type::MAGAZINE_WELL,
pocket_type::MAGAZINE
} ) {

for( item *contained : it.all_items_top( ptype, true ) ) {
Expand Down Expand Up @@ -4319,7 +4319,7 @@ static ret_val<void> try_insert( item_location &holster, drop_location &holstere
return ret;
}

return holster->put_in( it, item_pocket::pocket_type::CONTAINER, /*unseal_pockets=*/true, carrier );
return holster->put_in( it, pocket_type::CONTAINER, /*unseal_pockets=*/true, carrier );
}

ret = holster->can_contain_partial_directly( it );
Expand Down Expand Up @@ -6541,7 +6541,7 @@ void gunmod_add_activity_actor::finish( player_activity &act, Character &who )
if( rng( 0, 100 ) <= roll ) {
add_msg( m_good, _( "You successfully attached the %1$s to your %2$s." ), mod.tname(),
gun.tname() );
gun.put_in( who.i_rem( &mod ), item_pocket::pocket_type::MOD );
gun.put_in( who.i_rem( &mod ), pocket_type::MOD );
gun.on_contents_changed();

} else if( rng( 0, 100 ) <= risk ) {
Expand Down Expand Up @@ -6985,13 +6985,13 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you )
!it->first->any_pockets_sealed() ) {
std::unordered_map<itype_id, int> item_counts;
if( unload_sparse_only ) {
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::CONTAINER ) ) {
for( item *contained : it->first->all_items_top( pocket_type::CONTAINER ) ) {
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
item_counts[contained->typeId()]++;
}
}
}
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::CONTAINER ) ) {
for( item *contained : it->first->all_items_top( pocket_type::CONTAINER ) ) {
// no liquids don't want to spill stuff
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
if( unload_sparse_only &&
Expand All @@ -7005,7 +7005,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you )
return;
}
}
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::MAGAZINE ) ) {
for( item *contained : it->first->all_items_top( pocket_type::MAGAZINE ) ) {
// no liquids don't want to spill stuff
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
if( it->first->is_ammo_belt() ) {
Expand Down Expand Up @@ -7035,7 +7035,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you )
return;
}
}
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::MAGAZINE_WELL ) ) {
for( item *contained : it->first->all_items_top( pocket_type::MAGAZINE_WELL ) ) {
// no liquids don't want to spill stuff
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
move_item( you, *contained, contained->count(), src_loc, src_loc, this_veh, this_part );
Expand Down
10 changes: 5 additions & 5 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include "item.h"
#include "item_factory.h"
#include "item_location.h"
#include "item_pocket.h"
#include "item_stack.h"
#include "itype.h"
#include "iuse.h"
Expand All @@ -77,6 +76,7 @@
#include "overmapbuffer.h"
#include "pimpl.h"
#include "player_activity.h"
#include "pocket_type.h"
#include "point.h"
#include "proficiency.h"
#include "ranged.h"
Expand Down Expand Up @@ -901,7 +901,7 @@ static bool butchery_drops_harvest( item *corpse_item, const mtype &mt, Characte
if( action == butcher_type::DISSECT ) {
int dissectable_practice = 0;
int dissectable_num = 0;
for( item *item : corpse_item->all_items_top( item_pocket::pocket_type::CORPSE ) ) {
for( item *item : corpse_item->all_items_top( pocket_type::CORPSE ) ) {
dissectable_num++;
const int skill_level = butchery_dissect_skill_level( you, tool_quality,
item->dropped_from );
Expand Down Expand Up @@ -1173,7 +1173,7 @@ static bool butchery_drops_harvest( item *corpse_item, const mtype &mt, Characte
// reveal hidden items / hidden content
if( action != butcher_type::FIELD_DRESS && action != butcher_type::SKIN &&
action != butcher_type::BLEED ) {
for( item *content : corpse_item->all_items_top( item_pocket::pocket_type::CONTAINER ) ) {
for( item *content : corpse_item->all_items_top( pocket_type::CONTAINER ) ) {
if( ( roll_butchery_dissect( round( you.get_average_skill_level( skill_survival ) ), you.dex_cur,
tool_quality ) + 10 ) * 5 > rng( 0, 100 ) ) {
//~ %1$s - item name, %2$s - monster name
Expand Down Expand Up @@ -2292,7 +2292,7 @@ struct weldrig_hack {
}

item pseudo_magazine( pseudo.magazine_default() );
pseudo.put_in( pseudo_magazine, item_pocket::pocket_type::MAGAZINE_WELL );
pseudo.put_in( pseudo_magazine, pocket_type::MAGAZINE_WELL );
pseudo.ammo_set( itype_battery, part->vehicle().drain( itype_battery,
pseudo.ammo_capacity( ammo_battery ) ) );
return pseudo;
Expand Down Expand Up @@ -2656,7 +2656,7 @@ void activity_handlers::toolmod_add_finish( player_activity *act, Character *you
you->add_msg_if_player( m_good, _( "You successfully attached the %1$s to your %2$s." ),
mod.tname(), tool.tname() );
mod.set_flag( flag_IRREMOVABLE );
tool.put_in( mod, item_pocket::pocket_type::MOD );
tool.put_in( mod, pocket_type::MOD );
tool.on_contents_changed();
act->targets[1].remove_item();
}
Expand Down
8 changes: 4 additions & 4 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2230,13 +2230,13 @@ void activity_on_turn_move_loot( player_activity &act, Character &you )
!it->first->any_pockets_sealed() ) {
std::unordered_map<itype_id, int> item_counts;
if( unload_sparse_only ) {
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::CONTAINER ) ) {
for( item *contained : it->first->all_items_top( pocket_type::CONTAINER ) ) {
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
item_counts[contained->typeId()]++;
}
}
}
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::CONTAINER ) ) {
for( item *contained : it->first->all_items_top( pocket_type::CONTAINER ) ) {
// no liquids don't want to spill stuff
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
if( unload_sparse_only &&
Expand All @@ -2247,7 +2247,7 @@ void activity_on_turn_move_loot( player_activity &act, Character &you )
it->first->remove_item( *contained );
}
}
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::MAGAZINE ) ) {
for( item *contained : it->first->all_items_top( pocket_type::MAGAZINE ) ) {
// no liquids don't want to spill stuff
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
if( it->first->is_ammo_belt() ) {
Expand All @@ -2264,7 +2264,7 @@ void activity_on_turn_move_loot( player_activity &act, Character &you )
it->first->remove_item( *contained );
}
}
for( item *contained : it->first->all_items_top( item_pocket::pocket_type::MAGAZINE_WELL ) ) {
for( item *contained : it->first->all_items_top( pocket_type::MAGAZINE_WELL ) ) {
// no liquids don't want to spill stuff
if( !contained->made_of( phase_id::LIQUID ) && !contained->made_of( phase_id::GAS ) ) {
move_item( you, *contained, contained->count(), src_loc, src_loc, vpr_src );
Expand Down
1 change: 0 additions & 1 deletion src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "item.h"
#include "item_category.h"
#include "item_location.h"
#include "item_pocket.h"
#include "item_stack.h"
#include "localized_comparator.h"
#include "map.h"
Expand Down
8 changes: 4 additions & 4 deletions src/advanced_inv_pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
#include "cata_assert.h"
#include "flag.h"
#include "item.h"
#include "item_pocket.h"
#include "item_search.h"
#include "make_static.h"
#include "map.h"
#include "map_selector.h"
#include "options.h"
#include "pocket_type.h"
#include "type_id.h"
#include "uistate.h"
#include "units.h"
Expand Down Expand Up @@ -137,7 +137,7 @@ std::vector<advanced_inv_listitem> outfit::get_AIM_inventory( size_t &item_index
}
for( const std::vector<item_location> &it_stack : item_list_to_stack(
item_location( you, &worn_item ),
worn_item.all_items_top( item_pocket::pocket_type::CONTAINER ) ) ) {
worn_item.all_items_top( pocket_type::CONTAINER ) ) ) {
advanced_inv_listitem adv_it( it_stack, item_index++, square.id, false );
if( !pane.is_filtered( *adv_it.items.front() ) ) {
square.volume += adv_it.volume;
Expand All @@ -160,7 +160,7 @@ std::vector<advanced_inv_listitem> avatar::get_AIM_inventory( const advanced_inv
item_location weapon = get_wielded_item();
if( weapon && weapon->is_container() ) {
for( const std::vector<item_location> &it_stack : item_list_to_stack( weapon,
weapon->all_items_top( item_pocket::pocket_type::CONTAINER ) ) ) {
weapon->all_items_top( pocket_type::CONTAINER ) ) ) {
advanced_inv_listitem adv_it( it_stack, item_index++, square.id, false );
if( !pane.is_filtered( *adv_it.items.front() ) ) {
square.volume += adv_it.volume;
Expand Down Expand Up @@ -258,7 +258,7 @@ void advanced_inventory_pane::add_items_from_area( advanced_inv_area &square,
} else {
locs.emplace_back( loc_cursor, it );
if( it->is_corpse() ) {
for( item *loot : it->all_items_top( item_pocket::pocket_type::CONTAINER ) ) {
for( item *loot : it->all_items_top( pocket_type::CONTAINER ) ) {
if( !is_filtered( *loot ) ) {
advanced_inv_listitem aim_item( item_location( item_location( loc_cursor, it ), loot ),
0, 1, square.id, is_in_vehicle );
Expand Down
2 changes: 1 addition & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ void Character::burn_fuel( bionic &bio )
if( fuel_source->ammo_remaining() ) {
fuel = &fuel_source->first_ammo();
} else {
fuel = fuel_source->all_items_ptr( item_pocket::pocket_type::CONTAINER ).front();
fuel = fuel_source->all_items_ptr( pocket_type::CONTAINER ).front();
}
energy_gain = fuel->fuel_energy();

Expand Down
22 changes: 11 additions & 11 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3108,7 +3108,7 @@ units::mass Character::weight_carried_with_tweaks( const item_tweaks &tweaks ) c
units::mass weaponweight = 0_gram;
if( !without.count( &weapon ) ) {
weaponweight += weapon.weight();
for( const item *i : weapon.all_items_ptr( item_pocket::pocket_type::CONTAINER ) ) {
for( const item *i : weapon.all_items_ptr( pocket_type::CONTAINER ) ) {
if( i->count_by_charges() ) {
weaponweight -= get_selected_stack_weight( i, without );
} else if( without.count( i ) ) {
Expand Down Expand Up @@ -10231,7 +10231,7 @@ void Character::place_corpse()
body.set_item_temperature( units::from_celsius( 37 ) );
map &here = get_map();
for( item *itm : tmp ) {
body.force_insert_item( *itm, item_pocket::pocket_type::CONTAINER );
body.force_insert_item( *itm, pocket_type::CONTAINER );
}
for( const bionic &bio : *my_bionics ) {
if( item::type_is_defined( bio.info().itype() ) ) {
Expand All @@ -10240,7 +10240,7 @@ void Character::place_corpse()
cbm.set_flag( flag_NO_STERILE );
cbm.set_flag( flag_NO_PACKED );
cbm.faults.emplace( fault_bionic_salvaged );
body.put_in( cbm, item_pocket::pocket_type::CORPSE );
body.put_in( cbm, pocket_type::CORPSE );
}
}

Expand Down Expand Up @@ -10271,11 +10271,11 @@ void Character::place_corpse( const tripoint_abs_omt &om_target )
std::vector<item *> tmp = inv_dump();
item body = item::make_corpse( mtype_id::NULL_ID(), calendar::turn, get_name() );
for( item *itm : tmp ) {
body.force_insert_item( *itm, item_pocket::pocket_type::CONTAINER );
body.force_insert_item( *itm, pocket_type::CONTAINER );
}
for( const bionic &bio : *my_bionics ) {
if( item::type_is_defined( bio.info().itype() ) ) {
body.put_in( item( bio.id.str(), calendar::turn ), item_pocket::pocket_type::CORPSE );
body.put_in( item( bio.id.str(), calendar::turn ), pocket_type::CORPSE );
}
}

Expand Down Expand Up @@ -11204,10 +11204,10 @@ bool Character::unload( item_location &loc, bool bypass_activity,
int moves = 0;
item *prev_contained = nullptr;

for( item_pocket::pocket_type ptype : {
item_pocket::pocket_type::CONTAINER,
item_pocket::pocket_type::MAGAZINE_WELL,
item_pocket::pocket_type::MAGAZINE
for( pocket_type ptype : {
pocket_type::CONTAINER,
pocket_type::MAGAZINE_WELL,
pocket_type::MAGAZINE
} ) {

for( item *contained : it.all_items_top( ptype, true ) ) {
Expand Down Expand Up @@ -12507,10 +12507,10 @@ bool Character::wield_contents( item &container, item *internal_item, bool penal
}

void Character::store( item &container, item &put, bool penalties, int base_cost,
item_pocket::pocket_type pk_type, bool check_best_pkt )
pocket_type pk_type, bool check_best_pkt )
{
moves -= item_store_cost( put, container, penalties, base_cost );
if( check_best_pkt && pk_type == item_pocket::pocket_type::CONTAINER &&
if( check_best_pkt && pk_type == pocket_type::CONTAINER &&
container.get_all_contained_pockets().size() > 1 ) {
// Bypass pocket settings (assuming the item is manually stored)
container.fill_with( i_rem( &put ), put.count_by_charges() ? put.charges : 1, false, false, true );
Expand Down
4 changes: 2 additions & 2 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ class Character : public Creature, public visitable
*/
void store( item &container, item &put, bool penalties = true,
int base_cost = INVENTORY_HANDLING_PENALTY,
item_pocket::pocket_type pk_type = item_pocket::pocket_type::CONTAINER,
pocket_type pk_type = pocket_type::CONTAINER,
bool check_best_pkt = false );
void store( item_pocket *pocket, item &put, bool penalties = true,
int base_cost = INVENTORY_HANDLING_PENALTY );
Expand Down Expand Up @@ -1853,7 +1853,7 @@ class Character : public Creature, public visitable
bool operator()( const item &it ) const {
return it.mission_id == mission_id || it.has_any_with( [&]( const item & it ) {
return it.mission_id == mission_id;
}, item_pocket::pocket_type::SOFTWARE );
}, pocket_type::SOFTWARE );
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/character_attire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ units::mass outfit::weight_carried_with_tweaks( const std::map<const item *, int
if( without.empty() ) {
ret += i.weight();
} else if( !without.count( &i ) ) {
for( const item *j : i.all_items_ptr( item_pocket::pocket_type::CONTAINER ) ) {
for( const item *j : i.all_items_ptr( pocket_type::CONTAINER ) ) {
if( j->count_by_charges() ) {
ret -= get_selected_stack_weight( j, without );
} else if( without.count( j ) ) {
Expand Down Expand Up @@ -1915,7 +1915,7 @@ void outfit::absorb_damage( Character &guy, damage_unit &elem, bodypart_id bp,
destroyed_armor_msg( guy, pre_damage_name );
armor_destroyed = true;
armor.on_takeoff( guy );
for( const item *it : armor.all_items_top( item_pocket::pocket_type::CONTAINER ) ) {
for( const item *it : armor.all_items_top( pocket_type::CONTAINER ) ) {
worn_remains.push_back( *it );
}
// decltype is the type name of the iterator, note that reverse_iterator::base returns the
Expand Down Expand Up @@ -2440,7 +2440,7 @@ void outfit::add_stash( Character &guy, const item &newit, int &remaining_charge
// Crawl all pockets regardless of priority
// Crawl First : wielded item
item_location carried_item = guy.get_wielded_item();
if( carried_item && !carried_item->has_pocket_type( item_pocket::pocket_type::MAGAZINE ) &&
if( carried_item && !carried_item->has_pocket_type( pocket_type::MAGAZINE ) &&
carried_item->can_contain_partial( newit ).success() ) {
int used_charges = carried_item->fill_with( newit, remaining_charges, /*unseal_pockets=*/false,
/*allow_sealed=*/false, /*ignore_settings=*/false, /*into_bottom*/false, &guy );
Expand Down
Loading

0 comments on commit bd21196

Please sign in to comment.