aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/country/CountryInstance.cpp
diff options
context:
space:
mode:
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