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.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index b3d2df3..5a3dda2 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -40,10 +40,15 @@ ProvinceInstance::ProvinceInstance(
pops {},
total_population { 0 },
pop_type_distribution { &pop_type_keys },
+ pops_cache_by_type { &pop_type_keys },
ideology_distribution { &ideology_keys },
culture_distribution {},
religion_distribution {},
- max_supported_regiments { 0 } {}
+ max_supported_regiments { 0 } {
+ for (PopType const& pop_type : pop_type_keys) {
+ pops_cache_by_type[pop_type] = {};
+ }
+ }
GoodDefinition const* ProvinceInstance::get_rgo_good() const {
if (!rgo.is_valid()) { return nullptr; }
@@ -182,6 +187,10 @@ void ProvinceInstance::_update_pops(DefineManager const& define_manager) {
culture_distribution.clear();
religion_distribution.clear();
+ for (PopType const& pop_type : *pops_cache_by_type.get_keys()) {
+ pops_cache_by_type[pop_type].clear();
+ }
+
max_supported_regiments = 0;
MilitaryDefines const& military_defines = define_manager.get_military_defines();
@@ -202,6 +211,7 @@ void ProvinceInstance::_update_pops(DefineManager const& define_manager) {
average_militancy += pop.get_militancy();
pop_type_distribution[*pop.get_type()] += pop.get_size();
+ pops_cache_by_type[*pop.get_type()].push_back(&pop);
ideology_distribution += pop.get_ideologies();
culture_distribution[&pop.get_culture()] += pop.get_size();
religion_distribution[&pop.get_religion()] += pop.get_size();
@@ -354,17 +364,21 @@ bool ProvinceInstance::convert_rgo_worker_pops_to_equivalent(ProductionType cons
return is_valid_operation;
}
-void ProvinceInstance::update_gamestate(Date today, DefineManager const& define_manager) {
+void ProvinceInstance::update_gamestate(const Date today, DefineManager const& define_manager) {
for (BuildingInstance& building : buildings.get_items()) {
building.update_gamestate(today);
}
_update_pops(define_manager);
}
-void ProvinceInstance::tick(Date today) {
+void ProvinceInstance::province_tick(const Date today, ModifierEffectCache const& modifier_effect_cache) {
for (BuildingInstance& building : buildings.get_items()) {
building.tick(today);
}
+ rgo.rgo_tick(
+ *this,
+ modifier_effect_cache
+ );
}
template<UnitType::branch_t Branch>
@@ -468,8 +482,8 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const& ent
return ret;
}
-void ProvinceInstance::initialise_for_new_game(ModifierEffectCache const& modifier_effect_cache) {
- rgo.initialise_for_new_game(*this, modifier_effect_cache);
+void ProvinceInstance::initialise_rgo(ModifierEffectCache const& modifier_effect_cache) {
+ rgo.initialise_rgo_size_multiplier(*this, modifier_effect_cache);
}
void ProvinceInstance::setup_pop_test_values(IssueManager const& issue_manager) {
@@ -478,6 +492,14 @@ void ProvinceInstance::setup_pop_test_values(IssueManager const& issue_manager)
}
}
+State* ProvinceInstance::get_mutable_state() {
+ return state;
+}
+
plf::colony<Pop>& ProvinceInstance::get_mutable_pops() {
return pops;
+}
+
+IndexedMap<PopType, std::vector<Pop*>>& ProvinceInstance::get_mutable_pops_cache_by_type() {
+ return pops_cache_by_type;
} \ No newline at end of file