aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/country/CountryInstance.cpp
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/country/CountryInstance.cpp
parent3713393682c16fd5d3bed3e12fef68a1559c0cc5 (diff)
Add alternative modifier calculation (keeping country modifiers out of their owned provinces' modifier sums)
Diffstat (limited to 'src/openvic-simulation/country/CountryInstance.cpp')
-rw-r--r--src/openvic-simulation/country/CountryInstance.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/openvic-simulation/country/CountryInstance.cpp b/src/openvic-simulation/country/CountryInstance.cpp
index be62fda..f04dfc6 100644
--- a/src/openvic-simulation/country/CountryInstance.cpp
+++ b/src/openvic-simulation/country/CountryInstance.cpp
@@ -1007,23 +1007,30 @@ void CountryInstance::update_modifier_sum(Date today, StaticModifierCache const&
}
}
- // Add province base modifiers (with local province modifier effects removed)
- using enum ModifierEffect::target_t;
- static constexpr ModifierEffect::target_t NOT_PROVINCE = ALL_TARGETS & ~PROVINCE;
-
- for (ProvinceInstance const* province : owned_provinces) {
- modifier_sum.add_modifier_sum_filter_targets(province->get_modifier_sum(), NOT_PROVINCE);
- }
+ if constexpr (ProvinceInstance::ADD_OWNER_CONTRIBUTION) {
+ // Add province base modifiers (with local province modifier effects removed)
+ for (ProvinceInstance const* province : owned_provinces) {
+ contribute_province_modifier_sum(province->get_modifier_sum());
+ }
- // This has to be done after adding all province modifiers to the country's sum, otherwise provinces earlier in the list
- // wouldn't be affected by modifiers from provinces later in the list.
- for (ProvinceInstance* province : owned_provinces) {
- province->contribute_country_modifier_sum(modifier_sum);
+ // This has to be done after adding all province modifiers to the country's sum, otherwise provinces
+ // earlier in the list wouldn't be affected by modifiers from provinces later in the list.
+ for (ProvinceInstance* province : owned_provinces) {
+ province->contribute_country_modifier_sum(modifier_sum);
+ }
}
// TODO - calculate stats for each unit type (locked and unlocked)
}
+void CountryInstance::contribute_province_modifier_sum(ModifierSum const& province_modifier_sum) {
+ using enum ModifierEffect::target_t;
+
+ static constexpr ModifierEffect::target_t NOT_PROVINCE = ALL_TARGETS & ~PROVINCE;
+
+ modifier_sum.add_modifier_sum_filter_targets(province_modifier_sum, NOT_PROVINCE);
+}
+
fixed_point_t CountryInstance::get_modifier_effect_value(ModifierEffect const& effect) const {
return modifier_sum.get_effect(effect);
}
@@ -1032,6 +1039,16 @@ fixed_point_t CountryInstance::get_modifier_effect_value_nullcheck(ModifierEffec
return modifier_sum.get_effect_nullcheck(effect);
}
+void CountryInstance::push_contributing_modifiers(
+ ModifierEffect const& effect, std::vector<ModifierSum::modifier_entry_t>& contributions
+) const {
+ modifier_sum.push_contributing_modifiers(effect, contributions);
+}
+
+std::vector<ModifierSum::modifier_entry_t> CountryInstance::get_contributing_modifiers(ModifierEffect const& effect) const {
+ return modifier_sum.get_contributing_modifiers(effect);
+}
+
void CountryInstance::update_gamestate(
DefineManager const& define_manager, UnitTypeManager const& unit_type_manager,
ModifierEffectCache const& modifier_effect_cache