From 6a99bd8237fa61bd740ba482b59ff428a7e2f123 Mon Sep 17 00:00:00 2001 From: hop311 Date: Tue, 19 Mar 2024 23:23:58 +0000 Subject: Add Pop attributes + generate test values --- src/openvic-simulation/map/Province.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/openvic-simulation/map/Province.cpp') diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp index 94c8dcb..d1183f5 100644 --- a/src/openvic-simulation/map/Province.cpp +++ b/src/openvic-simulation/map/Province.cpp @@ -65,9 +65,14 @@ bool Province::expand_building(size_t building_index) { return building->expand(); } +void Province::_add_pop(Pop pop) { + pop.set_location(this); + pops.push_back(std::move(pop)); +} + bool Province::add_pop(Pop&& pop) { if (!is_water()) { - pops.push_back(std::move(pop)); + _add_pop(std::move(pop)); return true; } else { Logger::error("Trying to add pop to water province ", get_identifier()); @@ -79,7 +84,7 @@ bool Province::add_pop_vec(std::vector const& pop_vec) { if (!is_water()) { reserve_more(pops, pop_vec.size()); for (Pop const& pop : pop_vec) { - pops.push_back(pop); + _add_pop(pop); } return true; } else { @@ -104,7 +109,7 @@ void Province::update_pops() { for (Pop const& pop : pops) { total_population += pop.get_size(); pop_type_distribution[&pop.get_type()] += pop.get_size(); - //ideology_distribution[&pop.get_???()] += pop.get_size(); + ideology_distribution += pop.get_ideologies(); culture_distribution[&pop.get_culture()] += pop.get_size(); religion_distribution[&pop.get_religion()] += pop.get_size(); } @@ -257,3 +262,11 @@ bool Province::apply_history_to_province(ProvinceHistoryEntry const* entry) { // TODO: party loyalties for each POP when implemented on POP side return ret; } + +void Province::setup_pop_test_values( + IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country +) { + for (Pop& pop : pops) { + pop.setup_pop_test_values(ideology_manager, issue_manager, country); + } +} -- cgit v1.2.3-56-ga3b1