Introduce SSF support in [filter][filter_vision].

Deprecate viewing_side= in favor of the SSF's side=.

Semantics in case of empty filter changes from "all enemy sides"
to "all sides". If a side isn't an enemy, it can usually see
the unit anyway, and just in case the SSF has [enemy_of].
wmllint rule to come.

(patch #3194 by Brilliand)
This commit is contained in:
Anonymissimus 2012-03-27 19:50:21 +00:00
parent c5e318e572
commit 045cd30920

View file

@ -1478,6 +1478,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
bool visible = (*i)["visible"].to_bool(true);
std::set<int> viewers;
if (i->has_attribute("viewing_side")) {
ERR_NG << "[filter_vision]viewing_side= is deprecated, use side=\n";
std::vector<std::pair<int,int> > ranges = utils::parse_ranges((*i)["viewing_side"]);
std::vector<std::pair<int,int> >::const_iterator range, range_end = ranges.end();
for (range = ranges.begin(); range != range_end; ++range) {
@ -1488,13 +1489,10 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
}
}
} else {
//if viewing_side is not defined, default to all enemies
const team& my_team = teams_manager::get_teams()[this->side()-1];
for (size_t i = 1; i <= teams_manager::get_teams().size(); ++i) {
if (my_team.is_enemy(i)) {
viewers.insert(i);
}
}
// Use standard side filter
side_filter ssf(*i);
std::vector<int> sides = ssf.get_teams();
viewers.insert(sides.begin(), sides.end());
}
if (viewers.empty()) {
return false;