Default AI MtT CA: remove guardian moves before moving other units

Deal with units with ai_special=guardian before all other units in the
move-to-targets candidate action. This can speed up move times on maps
with many guardians significantly, as the movemaps calculated for the
AI units later in the MtT CA do not include the guardians any more.
This commit is contained in:
mattsc 2016-10-01 17:08:17 -07:00
parent 6d7680494d
commit eefc28c138

View file

@ -278,7 +278,17 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
unit_map::iterator u;
//find the first eligible unit
//take care of all the guardians first
for(u = units_.begin(); u != units_.end(); ++u) {
if (!(u->side() != get_side() || (u->can_recruit() && !get_leader_ignores_keep()) || u->movement_left() <= 0 || u->incapacitated())) {
if (u->get_state("guardian")) {
LOG_AI << u->type_id() << " is guardian, staying still\n";
return std::make_pair(u->get_location(), u->get_location());
}
}
}
//now find the first eligible remaining unit
for(u = units_.begin(); u != units_.end(); ++u) {
if (!(u->side() != get_side() || (u->can_recruit() && !get_leader_ignores_keep()) || u->movement_left() <= 0 || u->incapacitated())) {
break;
@ -290,12 +300,6 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
return std::pair<map_location,map_location>();
}
//guardian units stay put
if (u->get_state("guardian")) {
LOG_AI << u->type_id() << " is guardian, staying still\n";
return std::make_pair(u->get_location(), u->get_location());
}
const pathfind::plain_route dummy_route;
assert(dummy_route.steps.empty() && dummy_route.move_cost == 0);