diff options
author | Hop311 <Hop3114@gmail.com> | 2024-10-20 20:44:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-20 20:44:51 +0200 |
commit | 6527f832a5e14a28fc1f5b85628541038eb90141 (patch) | |
tree | aca829171be7b1144cb3ca29510593fa8a84af24 /src/openvic-simulation/map/MapDefinition.cpp | |
parent | 9a84e7af70f2528578b00879e568bca285563e9b (diff) | |
parent | 5194a3d043db66b81470111a94f3b1cdf8d42176 (diff) |
Merge pull request #198 from OpenVicProject/resultant-modifier
Calculate country and province modifier sums
Diffstat (limited to 'src/openvic-simulation/map/MapDefinition.cpp')
-rw-r--r-- | src/openvic-simulation/map/MapDefinition.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/openvic-simulation/map/MapDefinition.cpp b/src/openvic-simulation/map/MapDefinition.cpp index 828a679..5fe7189 100644 --- a/src/openvic-simulation/map/MapDefinition.cpp +++ b/src/openvic-simulation/map/MapDefinition.cpp @@ -3,6 +3,7 @@ #include <cstdint> #include <vector> +#include "openvic-simulation/modifier/ModifierManager.hpp" #include "openvic-simulation/types/Colour.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" #include "openvic-simulation/types/Vector.hpp" @@ -954,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( @@ -999,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; @@ -1006,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) { |