diff options
Diffstat (limited to 'src/openvic-simulation/politics')
-rw-r--r-- | src/openvic-simulation/politics/Issue.hpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/politics/NationalFocus.hpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/politics/NationalValue.hpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/politics/Rebel.cpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/politics/Rebel.hpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/politics/Rule.cpp | 50 | ||||
-rw-r--r-- | src/openvic-simulation/politics/Rule.hpp | 8 |
7 files changed, 27 insertions, 41 deletions
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp index 3a6daed..9f2d842 100644 --- a/src/openvic-simulation/politics/Issue.hpp +++ b/src/openvic-simulation/politics/Issue.hpp @@ -1,6 +1,6 @@ #pragma once -#include "openvic-simulation/misc/Modifier.hpp" +#include "openvic-simulation/modifier/Modifier.hpp" #include "openvic-simulation/politics/Rule.hpp" #include "openvic-simulation/scripts/ConditionScript.hpp" #include "openvic-simulation/scripts/EffectScript.hpp" diff --git a/src/openvic-simulation/politics/NationalFocus.hpp b/src/openvic-simulation/politics/NationalFocus.hpp index 04a4100..327b25b 100644 --- a/src/openvic-simulation/politics/NationalFocus.hpp +++ b/src/openvic-simulation/politics/NationalFocus.hpp @@ -1,6 +1,6 @@ #pragma once -#include "openvic-simulation/misc/Modifier.hpp" +#include "openvic-simulation/modifier/Modifier.hpp" #include "openvic-simulation/scripts/ConditionScript.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" #include "openvic-simulation/utility/Getters.hpp" diff --git a/src/openvic-simulation/politics/NationalValue.hpp b/src/openvic-simulation/politics/NationalValue.hpp index b896fd7..e69aa28 100644 --- a/src/openvic-simulation/politics/NationalValue.hpp +++ b/src/openvic-simulation/politics/NationalValue.hpp @@ -1,6 +1,6 @@ #pragma once -#include "openvic-simulation/misc/Modifier.hpp" +#include "openvic-simulation/modifier/Modifier.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" namespace OpenVic { diff --git a/src/openvic-simulation/politics/Rebel.cpp b/src/openvic-simulation/politics/Rebel.cpp index 1c54f06..fef61c0 100644 --- a/src/openvic-simulation/politics/Rebel.cpp +++ b/src/openvic-simulation/politics/Rebel.cpp @@ -2,8 +2,6 @@ #include <string_view> -#include "openvic-simulation/misc/Modifier.hpp" - using namespace OpenVic; using namespace OpenVic::NodeTools; diff --git a/src/openvic-simulation/politics/Rebel.hpp b/src/openvic-simulation/politics/Rebel.hpp index 7aeb31b..fc82c84 100644 --- a/src/openvic-simulation/politics/Rebel.hpp +++ b/src/openvic-simulation/politics/Rebel.hpp @@ -2,7 +2,7 @@ #include <cstdint> -#include "openvic-simulation/misc/Modifier.hpp" +#include "openvic-simulation/modifier/Modifier.hpp" #include "openvic-simulation/politics/Government.hpp" #include "openvic-simulation/politics/Ideology.hpp" #include "openvic-simulation/scripts/ConditionalWeight.hpp" diff --git a/src/openvic-simulation/politics/Rule.cpp b/src/openvic-simulation/politics/Rule.cpp index f2c0f8d..64d06f1 100644 --- a/src/openvic-simulation/politics/Rule.cpp +++ b/src/openvic-simulation/politics/Rule.cpp @@ -83,54 +83,42 @@ bool RuleSet::empty() const { return true; } -RuleSet::rule_map_t const& RuleSet::get_rule_group(Rule::rule_group_t group, bool* successful) const { +RuleSet::rule_map_t const& RuleSet::get_rule_group(Rule::rule_group_t group, bool* rule_group_found) const { const rule_group_map_t::const_iterator it = rule_groups.find(group); if (it != rule_groups.end()) { - if (successful != nullptr) { - *successful = true; + if (rule_group_found != nullptr) { + *rule_group_found = true; } return it->second; } - if (successful != nullptr) { - *successful = false; + if (rule_group_found != nullptr) { + *rule_group_found = false; } static const rule_map_t empty_map {}; return empty_map; } -bool RuleSet::get_rule(Rule const* rule, bool* successful) const { - if (rule == nullptr) { - Logger::error("Invalid rule - null!"); - return false; - } - rule_map_t const& rule_map = get_rule_group(rule->get_group()); - const rule_map_t::const_iterator it = rule_map.find(rule); +bool RuleSet::get_rule(Rule const& rule, bool* rule_found) const { + rule_map_t const& rule_map = get_rule_group(rule.get_group()); + const rule_map_t::const_iterator it = rule_map.find(&rule); if (it != rule_map.end()) { - if (successful != nullptr) { - *successful = true; + if (rule_found != nullptr) { + *rule_found = true; } return it->second; } - if (successful != nullptr) { - *successful = false; + if (rule_found != nullptr) { + *rule_found = false; } - return Rule::is_default_enabled(rule->get_group()); + return Rule::is_default_enabled(rule.get_group()); } -bool RuleSet::has_rule(Rule const* rule) const { - if (rule == nullptr) { - Logger::error("Invalid rule - null!"); - return false; - } - return get_rule_group(rule->get_group()).contains(rule); +bool RuleSet::has_rule(Rule const& rule) const { + return get_rule_group(rule.get_group()).contains(&rule); } -bool RuleSet::set_rule(Rule const* rule, bool value) { - if (rule == nullptr) { - Logger::error("Invalid rule - null!"); - return false; - } - rule_groups[rule->get_group()][rule] = value; +bool RuleSet::set_rule(Rule const& rule, bool value) { + rule_groups[rule.get_group()][&rule] = value; return true; } @@ -144,8 +132,8 @@ RuleSet& RuleSet::operator|=(RuleSet const& right) { } RuleSet RuleSet::operator|(RuleSet const& right) const { - RuleSet ret = *this; - return ret |= right; + RuleSet copy = *this; + return copy |= right; } bool RuleManager::add_rule(std::string_view identifier, Rule::rule_group_t group, std::string_view localisation_key) { diff --git a/src/openvic-simulation/politics/Rule.hpp b/src/openvic-simulation/politics/Rule.hpp index 579299b..0bbac82 100644 --- a/src/openvic-simulation/politics/Rule.hpp +++ b/src/openvic-simulation/politics/Rule.hpp @@ -65,12 +65,12 @@ namespace OpenVic { void clear(); bool empty() const; - rule_map_t const& get_rule_group(Rule::rule_group_t group, bool* successful = nullptr) const; - bool get_rule(Rule const* rule, bool* successful = nullptr) const; - bool has_rule(Rule const* rule) const; + rule_map_t const& get_rule_group(Rule::rule_group_t group, bool* rule_group_found = nullptr) const; + bool get_rule(Rule const& rule, bool* rule_found = nullptr) const; + bool has_rule(Rule const& rule) const; /* Sets the rule to the specified value. Returns false if there was an existing rule, regardless of its value. */ - bool set_rule(Rule const* rule, bool value); + bool set_rule(Rule const& rule, bool value); RuleSet& operator|=(RuleSet const& right); RuleSet operator|(RuleSet const& right) const; |