Skip to content

Commit

Permalink
Allow lists in SLF location_id key (closes #3493)
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Sep 9, 2018
1 parent 59e78e5 commit 354f24e
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/terrain/filter.cpp
Expand Up @@ -154,7 +154,14 @@ bool terrain_filter::match_internal(const map_location& loc, const unit* ref_uni
}
}
if (cfg_.has_attribute("location_id")) {
if (loc != fc_->get_disp_context().map().special_location(cfg_["location_id"])) {
std::set<map_location> matching_locs;
for(const auto& id : utils::split(cfg_["location_id"])) {
map_location test_loc = fc_->get_disp_context().map().special_location(id);
if(test_loc.valid()) {
matching_locs.insert(test_loc);
}
}
if (matching_locs.count(loc) == 0) {
return false;
}
}
Expand Down Expand Up @@ -466,8 +473,14 @@ class terrain_filterimpl
static void filter_special_loc(T&& src, location_set& dest, const terrain_filter& filter, const F1& f1, const F2& f2)
{
if (filter.cfg_.has_attribute("location_id")) {
map_location loc2 = filter.fc_->get_disp_context().map().special_location(filter.cfg_["location_id"]);
filter_final(src, dest, filter, f1, f2, [loc2](const map_location& loc) { return loc == loc2; });
std::set<map_location> matching_locs;
for(const auto& id : utils::split(filter.cfg_["location_id"])) {
map_location test_loc = filter.fc_->get_disp_context().map().special_location(id);
if(test_loc.valid()) {
matching_locs.insert(test_loc);
}
}
filter_final(src, dest, filter, f1, f2, [matching_locs](const map_location& loc) { return matching_locs.count(loc) > 0; });
}
else {
filter_final(src, dest, filter, f1, f2, no_filter());
Expand Down Expand Up @@ -543,9 +556,11 @@ void terrain_filter::get_locs_impl(std::set<map_location>& locs, const unit* ref
terrain_filterimpl::filter_special_loc(area, match_set, *this, terrain_filterimpl::no_filter(), terrain_filterimpl::no_filter());
}
else if (cfg_.has_attribute("location_id")) {
map_location loc2 = fc_->get_disp_context().map().special_location(cfg_["location_id"]);
if (loc2.valid()) {
match_set.insert(loc2);
for(const auto& id : utils::split(cfg_["location_id"])) {
map_location test_loc = fc_->get_disp_context().map().special_location(id);
if(test_loc.valid()) {
match_set.insert(test_loc);
}
}
}
else {
Expand Down

0 comments on commit 354f24e

Please sign in to comment.