Skip to content

Commit

Permalink
Fix [filter_wml] implementation so that [or] tags actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Mar 30, 2018
1 parent 2b87829 commit b483d96
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/config.cpp
Expand Up @@ -1182,31 +1182,25 @@ bool config::matches(const config& filter) const
{
check_valid(filter);

bool result = true;

for(const attribute& i : filter.attribute_range()) {
const attribute_value* v = get(i.first);
if(!v || *v != i.second) {
return false;
result = false;
break;
}
}

for(const any_child& i : filter.all_children_range()) {
if(i.key == "not") {
if(matches(i.cfg)) {
return false;
}

result = result && !matches(i.cfg);
continue;
} else if(i.key == "and") {
if(!matches(i.cfg)) {
return false;
}

result = result && matches(i.cfg);
continue;
} else if(i.key == "or") {
if(matches(i.cfg)) {
return true;
}

result = result || matches(i.cfg);
continue;
}

Expand All @@ -1218,12 +1212,10 @@ bool config::matches(const config& filter) const
}
}

if(!found) {
return false;
}
result = result && found;
}

return true;
return result;
}

std::string config::debug() const
Expand Down

0 comments on commit b483d96

Please sign in to comment.