66#include " openvic-simulation/country/CountryDefinition.hpp"
77#include " openvic-simulation/defines/Define.hpp"
88#include " openvic-simulation/DefinitionManager.hpp"
9+ #include " openvic-simulation/economy/BuildingType.hpp"
910#include " openvic-simulation/economy/production/ProductionType.hpp"
1011#include " openvic-simulation/history/CountryHistory.hpp"
1112#include " openvic-simulation/InstanceManager.hpp"
@@ -32,18 +33,18 @@ static constexpr colour_t ERROR_COLOUR = colour_t::from_integer(0xFF0000);
3233CountryInstance::CountryInstance (
3334 CountryDefinition const * new_country_definition,
3435 index_t new_index,
35- decltype (building_type_unlock_levels)::keys_type const & building_type_keys,
36- decltype(technology_unlock_levels)::keys_type const & technology_keys,
37- decltype(invention_unlock_levels)::keys_type const & invention_keys,
38- decltype(upper_house)::keys_type const & ideology_keys,
39- decltype(reforms)::keys_type const & reform_keys,
40- decltype(government_flag_overrides)::keys_type const & government_type_keys,
41- decltype(crime_unlock_levels)::keys_type const & crime_keys,
42- decltype(pop_type_distribution)::keys_type const & pop_type_keys,
43- decltype(goods_data)::keys_type const & good_instances_keys,
44- decltype(regiment_type_unlock_levels)::keys_type const & regiment_type_unlock_levels_keys,
45- decltype(ship_type_unlock_levels)::keys_type const & ship_type_unlock_levels_keys,
46- decltype(tax_rate_slider_value_by_strata)::keys_type const & strata_keys,
36+ decltype (building_type_unlock_levels)::keys_span_type building_type_keys,
37+ decltype(technology_unlock_levels)::keys_span_type technology_keys,
38+ decltype(invention_unlock_levels)::keys_span_type invention_keys,
39+ decltype(upper_house)::keys_span_type ideology_keys,
40+ decltype(reforms)::keys_span_type reform_keys,
41+ decltype(government_flag_overrides)::keys_span_type government_type_keys,
42+ decltype(crime_unlock_levels)::keys_span_type crime_keys,
43+ decltype(pop_type_distribution)::keys_span_type pop_type_keys,
44+ decltype(goods_data)::keys_span_type good_instances_keys,
45+ decltype(regiment_type_unlock_levels)::keys_span_type regiment_type_unlock_levels_keys,
46+ decltype(ship_type_unlock_levels)::keys_span_type ship_type_unlock_levels_keys,
47+ decltype(tax_rate_slider_value_by_strata)::keys_span_type strata_keys,
4748 GameRulesManager const & new_game_rules_manager,
4849 SharedCountryValues const & new_shared_country_values,
4950 GoodInstanceManager& new_good_instance_manager,
@@ -59,44 +60,43 @@ CountryInstance::CountryInstance(
5960 colour { ERROR_COLOUR },
6061
6162 /* Production */
62- building_type_unlock_levels { & building_type_keys },
63+ building_type_unlock_levels { building_type_keys },
6364
6465 /* Budget */
6566 taxable_income_mutex { std::make_unique<std::mutex>() },
66- taxable_income_by_pop_type { & pop_type_keys },
67- effective_tax_rate_by_strata { & strata_keys },
68- tax_rate_slider_value_by_strata { & strata_keys },
67+ taxable_income_by_pop_type { pop_type_keys },
68+ effective_tax_rate_by_strata { strata_keys },
69+ tax_rate_slider_value_by_strata { strata_keys },
6970 actual_net_tariffs_mutex { std::make_unique<std::mutex>() },
7071
7172 /* Technology */
72- technology_unlock_levels { & technology_keys },
73- invention_unlock_levels { & invention_keys },
73+ technology_unlock_levels { technology_keys },
74+ invention_unlock_levels { invention_keys },
7475
7576 /* Politics */
76- upper_house { & ideology_keys },
77- reforms { & reform_keys },
78- government_flag_overrides { & government_type_keys },
79- crime_unlock_levels { & crime_keys },
77+ upper_house { ideology_keys },
78+ reforms { reform_keys },
79+ government_flag_overrides { government_type_keys },
80+ crime_unlock_levels { crime_keys },
8081
8182 /* Population */
82- population_by_strata { &strata_keys },
83- militancy_by_strata { &strata_keys },
84- life_needs_fulfilled_by_strata { &strata_keys },
85- everyday_needs_fulfilled_by_strata { &strata_keys },
86- luxury_needs_fulfilled_by_strata { &strata_keys },
87- pop_type_distribution { &pop_type_keys },
88- pop_type_unemployed_count { &pop_type_keys },
89- ideology_distribution { &ideology_keys },
90- vote_distribution { nullptr },
83+ population_by_strata { strata_keys },
84+ militancy_by_strata { strata_keys },
85+ life_needs_fulfilled_by_strata { strata_keys },
86+ everyday_needs_fulfilled_by_strata { strata_keys },
87+ luxury_needs_fulfilled_by_strata { strata_keys },
88+ pop_type_distribution { pop_type_keys },
89+ pop_type_unemployed_count { pop_type_keys },
90+ ideology_distribution { ideology_keys },
9191
9292 /* Trade */
93- goods_data { & good_instances_keys },
93+ goods_data { good_instances_keys },
9494
9595 /* Diplomacy */
9696
9797 /* Military */
98- regiment_type_unlock_levels { & regiment_type_unlock_levels_keys },
99- ship_type_unlock_levels { & ship_type_unlock_levels_keys } {
98+ regiment_type_unlock_levels { regiment_type_unlock_levels_keys },
99+ ship_type_unlock_levels { ship_type_unlock_levels_keys } {
100100
101101 // Exclude PROVINCE (local) modifier effects from the country's modifier sum
102102 modifier_sum.set_this_excluded_targets (ModifierEffect::target_t ::PROVINCE);
@@ -137,25 +137,25 @@ CountryInstance::CountryInstance(
137137
138138 update_country_definition_based_attributes ();
139139
140- for (BuildingType const & building_type : * building_type_unlock_levels.get_keys ()) {
140+ for (BuildingType const & building_type : building_type_unlock_levels.get_keys ()) {
141141 if (building_type.is_default_enabled ()) {
142142 unlock_building_type (building_type, new_good_instance_manager);
143143 }
144144 }
145145
146- for (Crime const & crime : * crime_unlock_levels.get_keys ()) {
146+ for (Crime const & crime : crime_unlock_levels.get_keys ()) {
147147 if (crime.is_default_active ()) {
148148 unlock_crime (crime);
149149 }
150150 }
151151
152- for (RegimentType const & regiment_type : * regiment_type_unlock_levels.get_keys ()) {
152+ for (RegimentType const & regiment_type : regiment_type_unlock_levels.get_keys ()) {
153153 if (regiment_type.is_active ()) {
154154 unlock_unit_type (regiment_type);
155155 }
156156 }
157157
158- for (ShipType const & ship_type : * ship_type_unlock_levels.get_keys ()) {
158+ for (ShipType const & ship_type : ship_type_unlock_levels.get_keys ()) {
159159 if (ship_type.is_active ()) {
160160 unlock_unit_type (ship_type);
161161 }
@@ -167,7 +167,7 @@ std::string_view CountryInstance::get_identifier() const {
167167}
168168
169169void CountryInstance::update_country_definition_based_attributes () {
170- vote_distribution.set_keys (& country_definition->get_parties ());
170+ vote_distribution.set_keys (country_definition->get_parties ());
171171}
172172
173173bool CountryInstance::exists () const {
@@ -1464,13 +1464,13 @@ void CountryInstance::update_modifier_sum(Date today, StaticModifierCache const&
14641464 modifier_sum.add_modifier (*tech_school);
14651465 }
14661466
1467- for (Technology const & technology : * technology_unlock_levels.get_keys ()) {
1467+ for (Technology const & technology : technology_unlock_levels.get_keys ()) {
14681468 if (is_technology_unlocked (technology)) {
14691469 modifier_sum.add_modifier (technology);
14701470 }
14711471 }
14721472
1473- for (Invention const & invention : * invention_unlock_levels.get_keys ()) {
1473+ for (Invention const & invention : invention_unlock_levels.get_keys ()) {
14741474 if (is_invention_unlocked (invention)) {
14751475 modifier_sum.add_modifier (invention);
14761476 }
@@ -2097,10 +2097,10 @@ CountryInstanceManager::CountryInstanceManager(
20972097 ModifierEffectCache const & new_modifier_effect_cache,
20982098 CountryDefines const & new_country_defines,
20992099 PopsDefines const & new_pop_defines,
2100- std::vector< PopType> const & pop_type_keys
2100+ std::span< const PopType> pop_type_keys
21012101)
21022102 : country_definition_manager { new_country_definition_manager },
2103- country_definition_to_instance_map { & new_country_definition_manager.get_country_definitions () },
2103+ country_definition_to_instance_map { new_country_definition_manager.get_country_definitions () },
21042104 shared_country_values {
21052105 new_modifier_effect_cache,
21062106 new_country_defines,
@@ -2121,18 +2121,18 @@ CountryInstance const& CountryInstanceManager::get_country_instance_from_definit
21212121}
21222122
21232123bool CountryInstanceManager::generate_country_instances (
2124- decltype (CountryInstance::building_type_unlock_levels)::keys_type const & building_type_keys,
2125- decltype(CountryInstance::technology_unlock_levels)::keys_type const & technology_keys,
2126- decltype(CountryInstance::invention_unlock_levels)::keys_type const & invention_keys,
2127- decltype(CountryInstance::upper_house)::keys_type const & ideology_keys,
2128- decltype(CountryInstance::reforms)::keys_type const & reform_keys,
2129- decltype(CountryInstance::government_flag_overrides)::keys_type const & government_type_keys,
2130- decltype(CountryInstance::crime_unlock_levels)::keys_type const & crime_keys,
2131- decltype(CountryInstance::pop_type_distribution)::keys_type const & pop_type_keys,
2132- decltype(CountryInstance::goods_data)::keys_type const & good_instances_keys,
2133- decltype(CountryInstance::regiment_type_unlock_levels)::keys_type const & regiment_type_unlock_levels_keys,
2134- decltype(CountryInstance::ship_type_unlock_levels)::keys_type const & ship_type_unlock_levels_keys,
2135- decltype(CountryInstance::tax_rate_slider_value_by_strata):: keys_type const & strata_keys,
2124+ decltype (CountryInstance::building_type_unlock_levels)::keys_span_type building_type_keys,
2125+ decltype(CountryInstance::technology_unlock_levels)::keys_span_type technology_keys,
2126+ decltype(CountryInstance::invention_unlock_levels)::keys_span_type invention_keys,
2127+ decltype(CountryInstance::upper_house)::keys_span_type ideology_keys,
2128+ decltype(CountryInstance::reforms)::keys_span_type reform_keys,
2129+ decltype(CountryInstance::government_flag_overrides)::keys_span_type government_type_keys,
2130+ decltype(CountryInstance::crime_unlock_levels)::keys_span_type crime_keys,
2131+ decltype(CountryInstance::pop_type_distribution)::keys_span_type pop_type_keys,
2132+ decltype(CountryInstance::goods_data)::keys_span_type good_instances_keys,
2133+ decltype(CountryInstance::regiment_type_unlock_levels)::keys_span_type regiment_type_unlock_levels_keys,
2134+ decltype(CountryInstance::ship_type_unlock_levels)::keys_span_type ship_type_unlock_levels_keys,
2135+ decltype(CountryInstance::tax_rate_slider_value_by_strata):: keys_span_type strata_keys,
21362136 GameRulesManager const & game_rules_manager,
21372137 GoodInstanceManager& good_instance_manager,
21382138 CountryDefines const & country_defines,
0 commit comments