Skip to content

Commit

Permalink
fix: errors when npcs pickup items (#3629)
Browse files Browse the repository at this point in the history
Fix double detach in npc pickup
  • Loading branch information
joveeater authored Nov 11, 2023
1 parent a199ab6 commit a7dc1c2
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3123,40 +3123,34 @@ std::vector<item *> npc_pickup_from_stack( npc &who, T &items )
auto min_value = whitelisting ? 0 : who.minimum_item_value();
std::vector<item *> picked_up;

for( auto iter = items.begin(); iter != items.end(); ) {
item &it = **iter;
for( auto &iter : items ) {
item &it = *iter;
if( it.made_of( LIQUID ) ) {
iter++;
continue;
}

if( whitelisting && !who.item_whitelisted( it ) ) {
iter++;
continue;
}

auto volume = it.volume();
if( volume > volume_allowed ) {
iter++;
continue;
}

auto weight = it.weight();
if( weight > weight_allowed ) {
iter++;
continue;
}

int itval = whitelisting ? 1000 : who.value( it );
if( itval < min_value ) {
iter++;
continue;
}

volume_allowed -= volume;
weight_allowed -= weight;
picked_up.push_back( &it );
iter = items.erase( iter );
}

return picked_up;
Expand Down

0 comments on commit a7dc1c2

Please sign in to comment.