Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't rebuild the item drop list #36647

Merged
merged 2 commits into from
Jan 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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