Skip to content

Commit

Permalink
Simplify under_leadership() further.
Browse files Browse the repository at this point in the history
Avoid an expensive clone().
  • Loading branch information
jostephd committed Oct 27, 2018
1 parent 839c9f3 commit d59dd8f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/actions/attack.cpp
Expand Up @@ -1566,10 +1566,7 @@ void attack_unit_and_advance(const map_location& attacker,

int under_leadership(const unit &u, const map_location& loc, const_attack_ptr weapon, const_attack_ptr opp_weapon)
{
unit_ptr new_unit = u.clone();
new_unit->set_location(loc);

unit_ability_list abil = new_unit->get_abilities("leadership", weapon, opp_weapon);
unit_ability_list abil = u.get_abilities("leadership", loc, weapon, opp_weapon);
return abil.highest("value").first;
}

Expand Down

0 comments on commit d59dd8f

Please sign in to comment.