From c123cc4b79dfc32c652ee4da83a8d9d1f0e5ec0a Mon Sep 17 00:00:00 2001 From: Aivean Date: Wed, 23 Dec 2020 21:22:26 -0800 Subject: [PATCH] use `temp_crafting_inventory` in `are_requirements_nearby` --- src/activity_item_handling.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index e0e90704b5334..e1cce655d1221 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -57,6 +57,7 @@ #include "stomach.h" #include "string_formatter.h" #include "string_id.h" +#include "temp_crafting_inventory.h" #include "translations.h" #include "trap.h" #include "units.h" @@ -899,7 +900,7 @@ static bool are_requirements_nearby( const std::vector &loot_spots, const bool in_loot_zones, const tripoint &src_loc ) { zone_manager &mgr = zone_manager::get_manager(); - inventory temp_inv; + temp_crafting_inventory temp_inv; units::volume volume_allowed = p.volume_capacity() - p.volume_carried(); units::mass weight_allowed = p.weight_capacity() - p.weight_carried(); static const auto check_weight_if = []( const activity_id & id ) { @@ -919,7 +920,7 @@ static bool are_requirements_nearby( const std::vector &loot_spots, if( elem->has_quality( qual_WELD ) ) { found_welder = true; } - temp_inv += *elem; + temp_inv.add_item_ref( *elem ); } map &here = get_map(); for( const tripoint &elem : loot_spots ) { @@ -935,7 +936,7 @@ static bool are_requirements_nearby( const std::vector &loot_spots, continue; } } - for( const item &elem2 : here.i_at( elem ) ) { + for( item &elem2 : here.i_at( elem ) ) { if( in_loot_zones && elem2.made_of_from_type( phase_id::LIQUID ) ) { continue; } @@ -946,7 +947,7 @@ static bool are_requirements_nearby( const std::vector &loot_spots, continue; } } - temp_inv += elem2; + temp_inv.add_item_ref( elem2 ); } if( !in_loot_zones ) { if( const cata::optional vp = here.veh_at( elem ).part_with_feature( "CARGO", @@ -954,7 +955,7 @@ static bool are_requirements_nearby( const std::vector &loot_spots, vehicle &src_veh = vp->vehicle(); int src_part = vp->part_index(); for( item &it : src_veh.get_items( src_part ) ) { - temp_inv += it; + temp_inv.add_item_ref( it ); } } } @@ -970,11 +971,11 @@ static bool are_requirements_nearby( const std::vector &loot_spots, item welder( itype_welder, calendar::turn_zero ); welder.charges = veh_battery; welder.set_flag( flag_PSEUDO ); - temp_inv.add_item( welder ); + temp_inv.add_item_copy( welder ); item soldering_iron( itype_soldering_iron, calendar::turn_zero ); soldering_iron.charges = veh_battery; soldering_iron.set_flag( flag_PSEUDO ); - temp_inv.add_item( soldering_iron ); + temp_inv.add_item_copy( soldering_iron ); } } }