Skip to content

Commit

Permalink
don't rebuild the item drop list (CleverRaven#36647)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT authored and kevingranade committed Jan 3, 2020
1 parent 07dc4f5 commit 7aad3ab
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,21 @@ static std::list<item> obtain_activity_items( player_activity &act, player &p )
res.insert( res.begin(), excess.begin(), excess.end() );
}
// Load anything that remains (if any) into the activity
act.targets.clear();
act.values.clear();
if( !items.empty() ) {
if( items.size() > act.targets.size() ) {
for( const drop_location &drop : convert_to_locations( items ) ) {
act.targets.push_back( drop.first );
act.values.push_back( drop.second );
}
}
// remove items already dropped from the targets list by checking if pointers were invalidated
for( int i = act.targets.size() - 1; i >= 0; i-- ) {
const auto target_iter = act.targets.cbegin() + i;
const auto value_iter = act.values.cbegin() + i;
if( !*target_iter ) {
act.targets.erase( target_iter );
act.values.erase( value_iter );
}
}
// And cancel if its empty. If its not, we modified in place and we will continue
// to resolve the drop next turn. This is different from the pickup logic which
// creates a brand new activity every turn and cancels the old activity
Expand Down

0 comments on commit 7aad3ab

Please sign in to comment.