aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-10-06 01:08:44 +0200
committer hop311 <hop3114@gmail.com>2024-10-06 23:43:10 +0200
commit6181851281876730d7db4bed18791fdbbe3cfbbc (patch)
tree9d97602eb4b02688ea6b4e5bca060b1031c543d5 /src/openvic-simulation/modifier
parent3713393682c16fd5d3bed3e12fef68a1559c0cc5 (diff)
Add alternative modifier calculation (keeping country modifiers out of their owned provinces' modifier sums)
Diffstat (limited to 'src/openvic-simulation/modifier')
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.cpp17
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.hpp1
2 files changed, 12 insertions, 6 deletions
diff --git a/src/openvic-simulation/modifier/ModifierSum.cpp b/src/openvic-simulation/modifier/ModifierSum.cpp
index 09cb36d..a3b8cd5 100644
--- a/src/openvic-simulation/modifier/ModifierSum.cpp
+++ b/src/openvic-simulation/modifier/ModifierSum.cpp
@@ -70,23 +70,28 @@ void ModifierSum::add_modifier_sum_exclude_source(ModifierSum const& modifier_su
}
// TODO - include value_sum[effect] in result? Early return if lookup in value_sum fails?
-std::vector<ModifierSum::modifier_entry_t> ModifierSum::get_contributing_modifiers(
- ModifierEffect const& effect
+
+void ModifierSum::push_contributing_modifiers(
+ ModifierEffect const& effect, std::vector<modifier_entry_t>& contributions
) const {
using enum ModifierEffect::target_t;
- std::vector<modifier_entry_t> ret;
-
for (modifier_entry_t const& modifier_entry : modifiers) {
if ((modifier_entry.targets & effect.get_targets()) != NO_TARGETS) {
bool effect_found = false;
const fixed_point_t value = modifier_entry.modifier->get_effect(effect, &effect_found);
if (effect_found) {
- ret.push_back(modifier_entry);
+ contributions.push_back(modifier_entry);
}
}
}
+}
+
+std::vector<ModifierSum::modifier_entry_t> ModifierSum::get_contributing_modifiers(ModifierEffect const& effect) const {
+ std::vector<modifier_entry_t> contributions;
+
+ push_contributing_modifiers(effect, contributions);
- return ret;
+ return contributions;
}
diff --git a/src/openvic-simulation/modifier/ModifierSum.hpp b/src/openvic-simulation/modifier/ModifierSum.hpp
index 0ca8caa..7c1b238 100644
--- a/src/openvic-simulation/modifier/ModifierSum.hpp
+++ b/src/openvic-simulation/modifier/ModifierSum.hpp
@@ -55,6 +55,7 @@ namespace OpenVic {
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);
+ void push_contributing_modifiers(ModifierEffect const& effect, std::vector<modifier_entry_t>& contributions) const;
std::vector<modifier_entry_t> get_contributing_modifiers(ModifierEffect const& effect) const;
};
}