diff options
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r-- | src/openvic-simulation/map/MapInstance.cpp | 10 | ||||
-rw-r--r-- | src/openvic-simulation/map/MapInstance.hpp | 5 | ||||
-rw-r--r-- | src/openvic-simulation/map/ProvinceInstance.cpp | 22 | ||||
-rw-r--r-- | src/openvic-simulation/map/ProvinceInstance.hpp | 9 |
4 files changed, 45 insertions, 1 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp index d8ec2fb..2875a66 100644 --- a/src/openvic-simulation/map/MapInstance.cpp +++ b/src/openvic-simulation/map/MapInstance.cpp @@ -42,6 +42,9 @@ ProvinceDefinition::index_t MapInstance::get_selected_province_index() const { } bool MapInstance::setup( +#if OV_MODIFIER_CALCULATION_TEST + bool ADD_OWNER_CONTRIBUTION, +#endif BuildingTypeManager const& building_type_manager, decltype(ProvinceInstance::pop_type_distribution)::keys_t const& pop_type_keys, decltype(ProvinceInstance::ideology_distribution)::keys_t const& ideology_keys @@ -60,7 +63,12 @@ bool MapInstance::setup( province_instances.reserve(map_definition.get_province_definition_count()); for (ProvinceDefinition const& province : map_definition.get_province_definitions()) { - ret &= province_instances.add_item({ province, pop_type_keys, ideology_keys }); + ret &= province_instances.add_item({ +#if OV_MODIFIER_CALCULATION_TEST + ADD_OWNER_CONTRIBUTION, +#endif + province, pop_type_keys, ideology_keys + }); } province_instances.lock(); diff --git a/src/openvic-simulation/map/MapInstance.hpp b/src/openvic-simulation/map/MapInstance.hpp index e7c623e..d3decb4 100644 --- a/src/openvic-simulation/map/MapInstance.hpp +++ b/src/openvic-simulation/map/MapInstance.hpp @@ -6,6 +6,8 @@ #include "openvic-simulation/types/Date.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" +#include "openvic-simulation/ModifierCalculationTestToggle.hpp" + namespace OpenVic { struct MapDefinition; struct BuildingTypeManager; @@ -43,6 +45,9 @@ namespace OpenVic { ProvinceDefinition::index_t get_selected_province_index() const; bool setup( +#if OV_MODIFIER_CALCULATION_TEST + bool ADD_OWNER_CONTRIBUTION, +#endif BuildingTypeManager const& building_type_manager, decltype(ProvinceInstance::pop_type_distribution)::keys_t const& pop_type_keys, decltype(ProvinceInstance::ideology_distribution)::keys_t const& ideology_keys diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp index cbb23bd..3ef81eb 100644 --- a/src/openvic-simulation/map/ProvinceInstance.cpp +++ b/src/openvic-simulation/map/ProvinceInstance.cpp @@ -14,9 +14,15 @@ using namespace OpenVic; ProvinceInstance::ProvinceInstance( +#if OV_MODIFIER_CALCULATION_TEST + bool new_ADD_OWNER_CONTRIBUTION, +#endif ProvinceDefinition const& new_province_definition, decltype(pop_type_distribution)::keys_t const& pop_type_keys, decltype(ideology_distribution)::keys_t const& ideology_keys ) : HasIdentifierAndColour { new_province_definition }, +#if OV_MODIFIER_CALCULATION_TEST + ADD_OWNER_CONTRIBUTION { new_ADD_OWNER_CONTRIBUTION }, +#endif province_definition { new_province_definition }, terrain_type { new_province_definition.get_default_terrain_type() }, life_rating { 0 }, @@ -237,7 +243,11 @@ void ProvinceInstance::update_modifier_sum(Date today, StaticModifierCache const modifier_sum.add_modifier_nullcheck(terrain_type, province_source); +#if OV_MODIFIER_CALCULATION_TEST + if (!ADD_OWNER_CONTRIBUTION) { +#else if constexpr (!ADD_OWNER_CONTRIBUTION) { +#endif if (controller != nullptr) { controller->contribute_province_modifier_sum(modifier_sum); } @@ -249,7 +259,11 @@ void ProvinceInstance::contribute_country_modifier_sum(ModifierSum const& owner_ } fixed_point_t ProvinceInstance::get_modifier_effect_value(ModifierEffect const& effect) const { +#if OV_MODIFIER_CALCULATION_TEST + if (ADD_OWNER_CONTRIBUTION) { +#else if constexpr (ADD_OWNER_CONTRIBUTION) { +#endif return modifier_sum.get_effect(effect); } else { using enum ModifierEffect::target_t; @@ -279,7 +293,11 @@ fixed_point_t ProvinceInstance::get_modifier_effect_value_nullcheck(ModifierEffe void ProvinceInstance::push_contributing_modifiers( ModifierEffect const& effect, std::vector<ModifierSum::modifier_entry_t>& contributions ) const { +#if OV_MODIFIER_CALCULATION_TEST + if (ADD_OWNER_CONTRIBUTION) { +#else if constexpr (ADD_OWNER_CONTRIBUTION) { +#endif modifier_sum.push_contributing_modifiers(effect, contributions); } else { using enum ModifierEffect::target_t; @@ -300,7 +318,11 @@ void ProvinceInstance::push_contributing_modifiers( } std::vector<ModifierSum::modifier_entry_t> ProvinceInstance::get_contributing_modifiers(ModifierEffect const& effect) const { +#if OV_MODIFIER_CALCULATION_TEST + if (ADD_OWNER_CONTRIBUTION) { +#else if constexpr (ADD_OWNER_CONTRIBUTION) { +#endif return modifier_sum.get_contributing_modifiers(effect); } else { std::vector<ModifierSum::modifier_entry_t> contributions; diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp index e7c0326..2794a50 100644 --- a/src/openvic-simulation/map/ProvinceInstance.hpp +++ b/src/openvic-simulation/map/ProvinceInstance.hpp @@ -11,6 +11,8 @@ #include "openvic-simulation/types/HasIdentifier.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" +#include "openvic-simulation/ModifierCalculationTestToggle.hpp" + namespace OpenVic { struct MapInstance; struct ProvinceDefinition; @@ -70,10 +72,14 @@ namespace OpenVic { CountryInstance* PROPERTY(controller); ordered_set<CountryInstance*> PROPERTY(cores); +#if OV_MODIFIER_CALCULATION_TEST + const bool ADD_OWNER_CONTRIBUTION; +#else public: static constexpr bool ADD_OWNER_CONTRIBUTION = true; private: +#endif // The total/resultant modifier affecting this province, including owner country contributions if // ADD_OWNER_CONTRIBUTION is true. ModifierSum PROPERTY(modifier_sum); @@ -102,6 +108,9 @@ namespace OpenVic { size_t PROPERTY(max_supported_regiments); ProvinceInstance( +#if OV_MODIFIER_CALCULATION_TEST + bool new_ADD_OWNER_CONTRIBUTION, +#endif ProvinceDefinition const& new_province_definition, decltype(pop_type_distribution)::keys_t const& pop_type_keys, decltype(ideology_distribution)::keys_t const& ideology_keys ); |