aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/ProvinceInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map/ProvinceInstance.cpp')
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index f95ee21..06b3f1e 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -4,6 +4,7 @@
#include "openvic-simulation/history/ProvinceHistory.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
#include "openvic-simulation/military/UnitInstanceGroup.hpp"
+#include "openvic-simulation/misc/Define.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
using namespace OpenVic;
@@ -31,7 +32,8 @@ ProvinceInstance::ProvinceInstance(
pop_type_distribution { &pop_type_keys },
ideology_distribution { &ideology_keys },
culture_distribution {},
- religion_distribution {} {}
+ religion_distribution {},
+ max_supported_regiments { 0 } {}
bool ProvinceInstance::set_owner(CountryInstance* new_owner) {
bool ret = true;
@@ -92,6 +94,10 @@ bool ProvinceInstance::remove_core(CountryInstance& core_to_remove) {
}
}
+bool ProvinceInstance::is_owner_core() const {
+ return owner != nullptr && cores.contains(owner);
+}
+
bool ProvinceInstance::expand_building(size_t building_index) {
BuildingInstance* building = buildings.get_item_by_index(building_index);
if (building == nullptr) {
@@ -136,7 +142,7 @@ size_t ProvinceInstance::get_pop_count() const {
/* REQUIREMENTS:
* MAP-65, MAP-68, MAP-70, MAP-234
*/
-void ProvinceInstance::_update_pops() {
+void ProvinceInstance::_update_pops(DefineManager const& define_manager) {
total_population = 0;
average_literacy = 0;
average_consciousness = 0;
@@ -147,7 +153,18 @@ void ProvinceInstance::_update_pops() {
culture_distribution.clear();
religion_distribution.clear();
- for (Pop const& pop : pops) {
+ max_supported_regiments = 0;
+
+ using enum colony_status_t;
+
+ const fixed_point_t pop_size_per_regiment_multiplier =
+ colony_status == PROTECTORATE ? define_manager.get_pop_size_per_regiment_protectorate_multiplier()
+ : colony_status == COLONY ? define_manager.get_pop_size_per_regiment_colony_multiplier()
+ : is_owner_core() ? fixed_point_t::_1() : define_manager.get_pop_size_per_regiment_non_core_multiplier();
+
+ for (Pop& pop : pops) {
+ pop.update_gamestate(define_manager, owner, pop_size_per_regiment_multiplier);
+
total_population += pop.get_size();
average_literacy += pop.get_literacy();
average_consciousness += pop.get_consciousness();
@@ -157,6 +174,8 @@ void ProvinceInstance::_update_pops() {
ideology_distribution += pop.get_ideologies();
culture_distribution[&pop.get_culture()] += pop.get_size();
religion_distribution[&pop.get_religion()] += pop.get_size();
+
+ max_supported_regiments += pop.get_max_supported_regiments();
}
if (total_population > 0) {
@@ -166,11 +185,11 @@ void ProvinceInstance::_update_pops() {
}
}
-void ProvinceInstance::update_gamestate(Date today) {
+void ProvinceInstance::update_gamestate(Date today, DefineManager const& define_manager) {
for (BuildingInstance& building : buildings.get_items()) {
building.update_gamestate(today);
}
- _update_pops();
+ _update_pops(define_manager);
}
void ProvinceInstance::tick(Date today) {