diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 0bf7cae..e45e152 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -1240,7 +1240,7 @@ int loadExternalConfig(std::string &path, ExternalConfig &ext) try { YAML::Node yaml = YAML::Load(base_content); - if(yaml.size() && yaml["custom"]) + if(yaml.size() && yaml["custom"].IsDefined()) return loadExternalYAML(yaml, ext); } catch (YAML::Exception &e) diff --git a/src/misc.h b/src/misc.h index 0958068..926a65b 100644 --- a/src/misc.h +++ b/src/misc.h @@ -155,7 +155,7 @@ class tribool { private: - int _M_VALUE = -1; + char _M_VALUE = 0; public: @@ -179,14 +179,15 @@ public: return *this; } - operator bool() const { return _M_VALUE == 1; } + operator bool() const { return _M_VALUE == 3; } - bool is_undef() { return _M_VALUE == -1; } + bool is_undef() { return _M_VALUE <= 1; } - template void define(const T &value) + template tribool define(const T &value) { - if(_M_VALUE == -1) + if(_M_VALUE <= 1) *this = value; + return *this; } template tribool read(const T &value) @@ -197,13 +198,14 @@ public: tribool reverse() { - _M_VALUE = _M_VALUE == -1 ? -1 : (_M_VALUE == 0 ? 1 : 0); + if(_M_VALUE > 1) + _M_VALUE = _M_VALUE > 2 ? 2 : 3; return *this; } bool get(const bool &def_value = false) { - if(_M_VALUE == -1) + if(_M_VALUE <= 1) return def_value; return _M_VALUE; } @@ -212,9 +214,9 @@ public: { switch(_M_VALUE) { - case 0: + case 2: return "false"; - case 1: + case 3: return "true"; } return "undef"; @@ -222,8 +224,8 @@ public: template bool set(const T &value) { - _M_VALUE = value; - return _M_VALUE; + _M_VALUE = (bool)value + 2; + return _M_VALUE > 2; } bool set(const std::string &str) @@ -232,23 +234,23 @@ public: { case "true"_hash: case "1"_hash: - _M_VALUE = 1; + _M_VALUE = 3; break; case "false"_hash: case "0"_hash: - _M_VALUE = 0; + _M_VALUE = 2; break; default: if(to_int(str, 0) > 1) - _M_VALUE = 1; + _M_VALUE = 3; else - _M_VALUE = -1; + _M_VALUE = 0; break; } return _M_VALUE; } - void clear() { _M_VALUE = -1; } + void clear() { _M_VALUE = 0; } }; #ifndef HAVE_TO_STRING diff --git a/src/subexport.cpp b/src/subexport.cpp index 52ea3ba..9fac398 100644 --- a/src/subexport.cpp +++ b/src/subexport.cpp @@ -868,6 +868,8 @@ void rulesetToSurge(INIReader &base_rule, std::vector &ruleset_ if(surge_ver > 2 && remote_path_prefix.size()) { strLine = "RULE-SET," + remote_path_prefix + "/getruleset?type=1&url=" + urlsafe_base64_encode(rule_path_typed) + "," + rule_group; + if(x.update_interval) + strLine += ",update-interval=" + std::to_string(x.update_interval); allRules.emplace_back(std::move(strLine)); continue; } @@ -899,6 +901,9 @@ void rulesetToSurge(INIReader &base_rule, std::vector &ruleset_ else strLine = "RULE-SET," + rule_path + "," + rule_group; + if(x.update_interval) + strLine += ",update-interval=" + std::to_string(x.update_interval); + allRules.emplace_back(std::move(strLine)); continue; }