Skip to content

Commit

Permalink
add 'has_default_value' option for if 'value' or other is empty, cons…
Browse files Browse the repository at this point in the history
…idered like null by default.

this option is false by default in filter.
  • Loading branch information
newfrenchy83 committed Sep 29, 2023
1 parent 9698a7e commit 414e713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions data/schema/filters/abilities.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{SIMPLE_KEY value s_int_range_list}
{SIMPLE_KEY add s_int_range_list}
{SIMPLE_KEY sub s_int_range_list}
{SIMPLE_KEY has_default_value s_bool}
{SIMPLE_KEY multiply s_real_range_list}
{SIMPLE_KEY divide s_real_range_list}
{SIMPLE_KEY affect_adjacent s_bool}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/config_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool utils::config_filters::unsigned_matches_if_present(const config& filter, co
return true;
}

if(cfg[attribute].empty()) {
if(cfg[attribute].empty() && filter["has_default_value"].to_bool(false)) {
return false;
}
return in_ranges<int>(cfg[attribute].to_int(0), utils::parse_ranges_unsigned(filter[attribute].str()));
Expand All @@ -59,7 +59,7 @@ bool utils::config_filters::int_matches_if_present(const config& filter, const c
return true;
}

if(cfg[attribute].empty()) {
if(cfg[attribute].empty() && filter["has_default_value"].to_bool(false)) {
return false;
}

Expand All @@ -76,7 +76,7 @@ bool utils::config_filters::int_matches_if_present_or_negative(
// don't check for !cfg[opposite].empty(), as this assumes a default value of zero (similarly to
// int_matches_if_present)
if(cfg[attribute].empty()) {
if(cfg[opposite].empty()) {
if(cfg[opposite].empty() && filter["has_default_value"].to_bool(false)) {
return false;
}
return in_ranges<int>(-cfg[opposite].to_int(0), utils::parse_ranges_int(filter[attribute].str()));
Expand All @@ -91,7 +91,7 @@ bool utils::config_filters::double_matches_if_present(const config& filter, cons
return true;
}

if(cfg[attribute].empty()) {
if(cfg[attribute].empty() && filter["has_default_value"].to_bool(false)) {
return false;
}

Expand Down

0 comments on commit 414e713

Please sign in to comment.