mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 23:03:21 +00:00
Allow lists in SLF location_id key (closes #3493)
(cherry-picked from commit 354f24e926eec0c1e60cc1fab65dda223cfe15f5)
This commit is contained in:
parent
42c48d1483
commit
1606fdd6b6
@ -155,7 +155,14 @@ bool terrain_filter::match_internal(const map_location& loc, const unit* ref_uni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cfg_.has_attribute("location_id")) {
|
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;
|
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)
|
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")) {
|
if (filter.cfg_.has_attribute("location_id")) {
|
||||||
map_location loc2 = filter.fc_->get_disp_context().map().special_location(filter.cfg_["location_id"]);
|
std::set<map_location> matching_locs;
|
||||||
filter_final(src, dest, filter, f1, f2, [loc2](const map_location& loc) { return loc == loc2; });
|
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 {
|
else {
|
||||||
filter_final(src, dest, filter, f1, f2, no_filter());
|
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());
|
terrain_filterimpl::filter_special_loc(area, match_set, *this, terrain_filterimpl::no_filter(), terrain_filterimpl::no_filter());
|
||||||
}
|
}
|
||||||
else if (cfg_.has_attribute("location_id")) {
|
else if (cfg_.has_attribute("location_id")) {
|
||||||
map_location loc2 = fc_->get_disp_context().map().special_location(cfg_["location_id"]);
|
for(const auto& id : utils::split(cfg_["location_id"])) {
|
||||||
if (loc2.valid()) {
|
map_location test_loc = fc_->get_disp_context().map().special_location(id);
|
||||||
match_set.insert(loc2);
|
if(test_loc.valid()) {
|
||||||
|
match_set.insert(test_loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user