Skip to content

Commit

Permalink
use temp_crafting_inventory in are_requirements_nearby
Browse files Browse the repository at this point in the history
  • Loading branch information
Aivean committed Dec 25, 2020
1 parent 8c0324a commit c123cc4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -899,7 +900,7 @@ static bool are_requirements_nearby( const std::vector<tripoint> &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 ) {
Expand All @@ -919,7 +920,7 @@ static bool are_requirements_nearby( const std::vector<tripoint> &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 ) {
Expand All @@ -935,7 +936,7 @@ static bool are_requirements_nearby( const std::vector<tripoint> &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;
}
Expand All @@ -946,15 +947,15 @@ static bool are_requirements_nearby( const std::vector<tripoint> &loot_spots,
continue;
}
}
temp_inv += elem2;
temp_inv.add_item_ref( elem2 );
}
if( !in_loot_zones ) {
if( const cata::optional<vpart_reference> vp = here.veh_at( elem ).part_with_feature( "CARGO",
false ) ) {
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 );
}
}
}
Expand All @@ -970,11 +971,11 @@ static bool are_requirements_nearby( const std::vector<tripoint> &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 );
}
}
}
Expand Down

0 comments on commit c123cc4

Please sign in to comment.