AI Attacks Aspect: Better exclusion of invalid units

Previously the aspect did not check whether a potential attacker belongs to the AI's side,
or whether a potential target is an enemy. This generally isn't a problem, but should probably
be fixed anyway. In particular, it affects the new ai.aspects.attacks result.
This commit is contained in:
Celtic Minstrel 2016-10-17 16:26:26 -04:00
parent e81131fcc5
commit 4f8d99f96b

View File

@ -394,6 +394,9 @@ config aspect_attacks::to_config() const
bool aspect_attacks::is_allowed_attacker(const unit& u) const
{
if(u.side() != get_side()) {
return false;
}
if (filter_own_) {
return (*filter_own_)(u);
}
@ -402,6 +405,10 @@ bool aspect_attacks::is_allowed_attacker(const unit& u) const
bool aspect_attacks::is_allowed_enemy(const unit& u) const
{
team& my_team = resources::gameboard->get_team(get_side());
if(!my_team.is_enemy(u.side())) {
return false;
}
if (filter_enemy_) {
return (*filter_enemy_)(u);
}