diff options
author | Hop311 <Hop3114@gmail.com> | 2023-12-13 21:09:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-13 21:09:27 +0100 |
commit | e79ad08e28c07bac5d28d0653cbe374cd51e6bbe (patch) | |
tree | 4dbbbc2c10b8bbc6670b36f3d4ecd4d5f7e765f9 /src/openvic-simulation/map/Province.cpp | |
parent | ce45aaae79199e07f9249799884cbba1b3d581eb (diff) | |
parent | 89c93f98b865c20cd3c3486a9b91323565e759fc (diff) |
Merge pull request #89 from OpenVicProject/dataloading-pop-history
Pop History Loading (with the new system)
Diffstat (limited to 'src/openvic-simulation/map/Province.cpp')
-rw-r--r-- | src/openvic-simulation/map/Province.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp index 363be6c..8094463 100644 --- a/src/openvic-simulation/map/Province.cpp +++ b/src/openvic-simulation/map/Province.cpp @@ -58,14 +58,6 @@ bool Province::expand_building(std::string_view building_type_identifier) { return building->expand(); } -bool Province::load_pop_list(PopManager const& pop_manager, ast::NodeCPtr root) { - return expect_dictionary_reserve_length(pops, - [this, &pop_manager](std::string_view pop_type_identifier, ast::NodeCPtr pop_node) -> bool { - return pop_manager.load_pop_into_province(*this, pop_type_identifier, pop_node); - } - )(root); -} - bool Province::add_pop(Pop&& pop) { if (!get_water()) { pops.push_back(std::move(pop)); @@ -76,6 +68,19 @@ bool Province::add_pop(Pop&& pop) { } } +bool Province::add_pop_vec(std::vector<Pop> const& pop_vec) { + if (!get_water()) { + pops.reserve(pops.size() + pop_vec.size()); + for (Pop const& pop : pop_vec) { + pops.push_back(pop); + } + return true; + } else { + Logger::error("Trying to add pop vector to water province ", get_identifier()); + return false; + } +} + size_t Province::get_pop_count() const { return pops.size(); } |