Fix target-lock V2 crash
This commit is contained in:
@@ -1095,7 +1095,10 @@ void handle_target_mode(eGameMode target_mode, int range, eSpell spell) {
|
||||
}
|
||||
if(!enemy_locs_in_range.empty()){
|
||||
std::vector<location> dest_candidates = points_containing_most(enemy_locs_in_range, enemy_locs_already_seen);
|
||||
center = closest_point(dest_candidates, loc);
|
||||
// Center can stay the same if all points with the most monsters exclude any required (already seen) monsters
|
||||
if(!dest_candidates.empty()){
|
||||
center = closest_point(dest_candidates, loc);
|
||||
}
|
||||
draw_terrain();
|
||||
}
|
||||
}
|
||||
|
@@ -401,6 +401,8 @@ std::vector<location> points_containing_most(std::vector<location> points, std:
|
||||
}
|
||||
}
|
||||
|
||||
if(points_seen_from.empty()) return {};
|
||||
|
||||
// Sort candidates by how many of the points they see
|
||||
std::sort(points_seen_from.begin(), points_seen_from.end(), [](std::pair<location,int> pair1, std::pair<location,int> pair2) -> bool {
|
||||
return pair1.second > pair2.second;
|
||||
|
Reference in New Issue
Block a user