diff options
author | hop311 <hop3114@gmail.com> | 2024-10-19 12:39:08 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-10-19 12:39:08 +0200 |
commit | 572ac597d8b43c4c97be4b68aa40de0e7ae6bfe0 (patch) | |
tree | c529d60fe49fbcd167522c0fb21ca10139cb5cc7 /src/openvic-simulation/map/MapDefinition.cpp | |
parent | 35909d6e79d524f19f9b69dffd02fcf162be5093 (diff) |
Require modifier type when parsing ModifierValues
Diffstat (limited to 'src/openvic-simulation/map/MapDefinition.cpp')
-rw-r--r-- | src/openvic-simulation/map/MapDefinition.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/openvic-simulation/map/MapDefinition.cpp b/src/openvic-simulation/map/MapDefinition.cpp index 50fba7d..5fe7189 100644 --- a/src/openvic-simulation/map/MapDefinition.cpp +++ b/src/openvic-simulation/map/MapDefinition.cpp @@ -955,8 +955,12 @@ bool MapDefinition::load_climate_file(ModifierManager const& modifier_manager, a bool ret = true; Climate* cur_climate = climates.get_item_by_identifier(identifier); if (cur_climate == nullptr) { + using enum Modifier::modifier_type_t; + ModifierValue values; - ret &= modifier_manager.expect_modifier_value(move_variable_callback(values))(node); + + ret &= modifier_manager.expect_modifier_value(move_variable_callback(values), CLIMATE)(node); + ret &= climates.add_item({ identifier, std::move(values), Modifier::modifier_type_t::CLIMATE }); } else { ret &= expect_list_reserve_length(*cur_climate, expect_province_definition_identifier( @@ -1000,6 +1004,8 @@ bool MapDefinition::load_continent_file(ModifierManager const& modifier_manager, bool ret = expect_dictionary_reserve_length( continents, [this, &modifier_manager](std::string_view identifier, ast::NodeCPtr node) -> bool { + using enum Modifier::modifier_type_t; + if (identifier.empty()) { Logger::error("Invalid continent identifier - empty!"); return false; @@ -1007,7 +1013,9 @@ bool MapDefinition::load_continent_file(ModifierManager const& modifier_manager, ModifierValue values; std::vector<ProvinceDefinition const*> prov_list; - bool ret = modifier_manager.expect_modifier_value_and_keys(move_variable_callback(values), + bool ret = modifier_manager.expect_modifier_value_and_keys( + move_variable_callback(values), + CONTINENT, "provinces", ONE_EXACTLY, expect_list_reserve_length(prov_list, expect_province_definition_identifier( [&prov_list](ProvinceDefinition const& province) -> bool { if (province.continent == nullptr) { |