diff options
author | hop311 <hop3114@gmail.com> | 2024-10-05 20:08:55 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-10-05 22:48:42 +0200 |
commit | 6c23b7ff2e8bc733699ef9b29aee80719001acf2 (patch) | |
tree | 31032796ff2addd154837a873663d8325ee6bdc6 /src/openvic-simulation/modifier/ModifierSum.cpp | |
parent | 4f9fd8a327b6de5fb32792a07453e9a2e245dc84 (diff) |
Add nullcheck fuction variants accepting pointer arguments to ModifierValue and ModifierSum
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierSum.cpp')
-rw-r--r-- | src/openvic-simulation/modifier/ModifierSum.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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; |