mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 18:16:11 +00:00
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:
parent
e81131fcc5
commit
4f8d99f96b
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user