Allow lists in SLF location_id key (closes #3493)
(cherry-picked from commit 354f24e926
)
This commit is contained in:
parent
42c48d1483
commit
1606fdd6b6
1 changed files with 21 additions and 6 deletions
|
@ -155,7 +155,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;
|
||||
}
|
||||
}
|
||||
|
@ -467,8 +474,14 @@ public:
|
|||
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());
|
||||
|
@ -544,9 +557,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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue