diff options
author | Hop311 <hop3114@gmail.com> | 2023-09-14 10:34:54 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-14 10:34:54 +0200 |
commit | 5f3e1f3b1b021cbee243236ad8947f203d0416be (patch) | |
tree | 07ea9839190239544fe055812bf3fccce4c245a2 /src/openvic-simulation/map/Map.cpp | |
parent | 6278a35f4704574933464700026d8deb997da5c1 (diff) |
Region + localisation loading
Diffstat (limited to 'src/openvic-simulation/map/Map.cpp')
-rw-r--r-- | src/openvic-simulation/map/Map.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp index 728fc42..74764d2 100644 --- a/src/openvic-simulation/map/Map.cpp +++ b/src/openvic-simulation/map/Map.cpp @@ -7,6 +7,7 @@ #include "openvic-simulation/utility/Logger.hpp" using namespace OpenVic; +using namespace OpenVic::NodeTools; Mapmode::Mapmode(const std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func) : HasIdentifier { new_identifier }, @@ -503,3 +504,26 @@ bool Map::load_province_definitions(std::vector<LineObject> const& lines) { lock_provinces(); return ret; } + +/* TODO - add support for non-state province groupings used by some mods + * (currently they trigger "province already in other region" errors). + */ +bool Map::load_region_file(ast::NodeCPtr root) { + const bool ret = expect_dictionary_reserve_length( + regions, + [this](std::string_view region_identifier, ast::NodeCPtr region_node) -> bool { + std::vector<std::string_view> province_identifiers; + bool ret = expect_list_reserve_length( + province_identifiers, + expect_identifier([&province_identifiers](std::string_view identifier) -> bool { + province_identifiers.push_back(identifier); + return true; + }) + )(region_node); + ret &= add_region(region_identifier, province_identifiers); + return ret; + } + )(root); + lock_regions(); + return ret; +} |