1010#include " openvic-simulation/map/Region.hpp"
1111#include " openvic-simulation/map/TerrainType.hpp"
1212#include " openvic-simulation/military/UnitInstanceGroup.hpp"
13+ #include " openvic-simulation/misc/GameRulesManager.hpp"
1314#include " openvic-simulation/modifier/StaticModifierCache.hpp"
1415#include " openvic-simulation/politics/Ideology.hpp"
1516#include " openvic-simulation/pop/PopValuesFromProvince.hpp"
@@ -19,6 +20,7 @@ using namespace OpenVic;
1920
2021ProvinceInstance::ProvinceInstance (
2122 MarketInstance& new_market_instance,
23+ GameRulesManager const & new_game_rules_manager,
2224 ModifierEffectCache const & new_modifier_effect_cache,
2325 ProvinceDefinition const & new_province_definition,
2426 decltype (population_by_strata)::keys_type const & strata_keys,
@@ -28,6 +30,7 @@ ProvinceInstance::ProvinceInstance(
2830 HasIndex { new_province_definition.get_index () },
2931 FlagStrings { " province" },
3032 province_definition { new_province_definition },
33+ game_rules_manager { new_game_rules_manager },
3134 modifier_effect_cache { new_modifier_effect_cache },
3235 terrain_type { new_province_definition.get_default_terrain_type () },
3336 rgo { new_market_instance, pop_type_keys },
@@ -84,6 +87,14 @@ bool ProvinceInstance::set_owner(CountryInstance* new_owner) {
8487 for (Pop& pop : pops) {
8588 pop.update_location_based_attributes ();
8689 }
90+
91+ if (game_rules_manager.get_country_to_report_economy () == country_to_report_economy_t ::Owner) {
92+ country_to_report_economy = new_owner;
93+ } else if (game_rules_manager.get_country_to_report_economy () == country_to_report_economy_t ::NeitherWhenOccupied) {
94+ country_to_report_economy = is_occupied ()
95+ ? nullptr
96+ : owner;
97+ }
8798 }
8899
89100 return ret;
@@ -92,6 +103,10 @@ bool ProvinceInstance::set_owner(CountryInstance* new_owner) {
92103bool ProvinceInstance::set_controller (CountryInstance* new_controller) {
93104 bool ret = true ;
94105
106+ if (new_controller == nullptr ) {
107+ new_controller = owner;
108+ }
109+
95110 if (controller != new_controller) {
96111 if (controller != nullptr ) {
97112 ret &= controller->remove_controlled_province (*this );
@@ -102,6 +117,14 @@ bool ProvinceInstance::set_controller(CountryInstance* new_controller) {
102117 if (controller != nullptr ) {
103118 ret &= controller->add_controlled_province (*this );
104119 }
120+
121+ if (game_rules_manager.get_country_to_report_economy () == country_to_report_economy_t ::Controller) {
122+ country_to_report_economy = new_controller;
123+ } else if (game_rules_manager.get_country_to_report_economy () == country_to_report_economy_t ::NeitherWhenOccupied) {
124+ country_to_report_economy = is_occupied ()
125+ ? nullptr
126+ : owner;
127+ }
105128 }
106129
107130 return ret;
0 commit comments