aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/openvic-simulation/modifier/Modifier.cpp12
-rw-r--r--src/openvic-simulation/modifier/Modifier.hpp1
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.cpp12
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.hpp5
4 files changed, 30 insertions, 0 deletions
diff --git a/src/openvic-simulation/modifier/Modifier.cpp b/src/openvic-simulation/modifier/Modifier.cpp
index 73b30ce..c7c8087 100644
--- a/src/openvic-simulation/modifier/Modifier.cpp
+++ b/src/openvic-simulation/modifier/Modifier.cpp
@@ -58,6 +58,18 @@ fixed_point_t ModifierValue::get_effect(ModifierEffect const& effect, bool* effe
}
return it->second;
}
+
+ if (effect_found != nullptr) {
+ *effect_found = false;
+ }
+ return fixed_point_t::_0();
+}
+
+fixed_point_t ModifierValue::get_effect_nullcheck(ModifierEffect const* effect, bool* effect_found) const {
+ if (effect != nullptr) {
+ return get_effect(*effect, effect_found);
+ }
+
if (effect_found != nullptr) {
*effect_found = false;
}
diff --git a/src/openvic-simulation/modifier/Modifier.hpp b/src/openvic-simulation/modifier/Modifier.hpp
index a848cb8..f52f126 100644
--- a/src/openvic-simulation/modifier/Modifier.hpp
+++ b/src/openvic-simulation/modifier/Modifier.hpp
@@ -71,6 +71,7 @@ namespace OpenVic {
bool empty() const;
fixed_point_t get_effect(ModifierEffect const& effect, bool* effect_found = nullptr) const;
+ fixed_point_t get_effect_nullcheck(ModifierEffect const* effect, bool* effect_found = nullptr) const;
bool has_effect(ModifierEffect const& effect) const;
void set_effect(ModifierEffect const& effect, fixed_point_t value);
diff --git a/src/openvic-simulation/modifier/ModifierSum.cpp b/src/openvic-simulation/modifier/ModifierSum.cpp
index 312432a..4051d64 100644
--- a/src/openvic-simulation/modifier/ModifierSum.cpp
+++ b/src/openvic-simulation/modifier/ModifierSum.cpp
@@ -15,6 +15,10 @@ fixed_point_t ModifierSum::get_effect(ModifierEffect const& effect, bool* effect
return value_sum.get_effect(effect, effect_found);
}
+fixed_point_t ModifierSum::get_effect_nullcheck(ModifierEffect const* effect, bool* effect_found) const {
+ return value_sum.get_effect_nullcheck(effect, effect_found);
+}
+
bool ModifierSum::has_effect(ModifierEffect const& effect) const {
return value_sum.has_effect(effect);
}
@@ -30,6 +34,14 @@ void ModifierSum::add_modifier(
}
}
+void ModifierSum::add_modifier_nullcheck(
+ Modifier const* modifier, modifier_source_t const& source, fixed_point_t multiplier, ModifierEffect::target_t targets
+) {
+ if (modifier != nullptr) {
+ add_modifier(*modifier, source, multiplier, targets);
+ }
+}
+
void ModifierSum::add_modifier_sum(ModifierSum const& modifier_sum) {
modifiers.insert(modifiers.end(), modifier_sum.modifiers.begin(), modifier_sum.modifiers.end());
value_sum += modifier_sum.value_sum;
diff --git a/src/openvic-simulation/modifier/ModifierSum.hpp b/src/openvic-simulation/modifier/ModifierSum.hpp
index b982ed1..406c52b 100644
--- a/src/openvic-simulation/modifier/ModifierSum.hpp
+++ b/src/openvic-simulation/modifier/ModifierSum.hpp
@@ -39,12 +39,17 @@ namespace OpenVic {
bool empty();
fixed_point_t get_effect(ModifierEffect const& effect, bool* effect_found = nullptr) const;
+ fixed_point_t get_effect_nullcheck(ModifierEffect const* effect, bool* effect_found = nullptr) const;
bool has_effect(ModifierEffect const& effect) const;
void add_modifier(
Modifier const& modifier, modifier_source_t const& source, fixed_point_t multiplier = fixed_point_t::_1(),
ModifierEffect::target_t targets = ModifierEffect::target_t::ALL_TARGETS
);
+ void add_modifier_nullcheck(
+ Modifier const* modifier, modifier_source_t const& source, fixed_point_t multiplier = fixed_point_t::_1(),
+ ModifierEffect::target_t targets = ModifierEffect::target_t::ALL_TARGETS
+ );
void add_modifier_sum(ModifierSum const& modifier_sum);
void add_modifier_sum_filter_targets(ModifierSum const& modifier_sum, ModifierEffect::target_t targets);
void add_modifier_sum_exclude_source(ModifierSum const& modifier_sum, modifier_source_t const& excluded_source);