From 91e84822799c6ded35d89bbd2877ba2448447c6c Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sun, 6 Jul 2014 23:48:13 -0400 Subject: [PATCH] add [has_ally],[has_enemy] tags for standard side filter Unlike [allied_with] and [enemy_of], these will match if only if there is *any* ally or enemy matching the filter. The other versions of the tag match only if all sides matching the filter are allied / opposed. --- src/side_filter.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/side_filter.cpp b/src/side_filter.cpp index 7715495a3645..b31e296d3574 100644 --- a/src/side_filter.cpp +++ b/src/side_filter.cpp @@ -173,6 +173,37 @@ bool side_filter::match_internal(const team &t) const } } + const vconfig& has_enemy = cfg_.child("has_enemy"); + if(!has_enemy.null()) { + side_filter s_filter(has_enemy); + const std::vector& teams = s_filter.get_teams(); + bool found = false; + BOOST_FOREACH(const int side, teams) { + if((*resources::teams)[side - 1].is_enemy(t.side())) + { + found = true; + break; + } + } + if (!found) return false; + } + + const vconfig& has_ally = cfg_.child("has_ally"); + if(!has_ally.null()) { + side_filter s_filter(has_ally); + const std::vector& teams = s_filter.get_teams(); + bool found = false; + BOOST_FOREACH(const int side, teams) { + if(!(*resources::teams)[side - 1].is_enemy(t.side())) + { + found = true; + break; + } + } + if (!found) return false; + } + + const config::attribute_value cfg_controller = cfg_["controller"]; if (!cfg_controller.blank()) {