From 3daebe5db14949f55be2c50220323138260dbaea Mon Sep 17 00:00:00 2001 From: wvpm <24685035+wvpm@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:09:40 +0200 Subject: contextual modifier parsing --- src/openvic-simulation/politics/NationalFocus.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/openvic-simulation/politics/NationalFocus.cpp') diff --git a/src/openvic-simulation/politics/NationalFocus.cpp b/src/openvic-simulation/politics/NationalFocus.cpp index 4d1546c..2427d7c 100644 --- a/src/openvic-simulation/politics/NationalFocus.cpp +++ b/src/openvic-simulation/politics/NationalFocus.cpp @@ -117,8 +117,6 @@ bool NationalFocusManager::load_national_foci_file( [this, &group, &pop_manager, &ideology_manager, &good_definition_manager, &modifier_manager]( std::string_view identifier, ast::NodeCPtr node ) -> bool { - using enum Modifier::modifier_type_t; - uint8_t icon = 0; bool has_flashpoint = false, own_provinces = true, outliner_show_as_percent = false; fixed_point_t flashpoint_tension = 0; @@ -132,10 +130,9 @@ bool NationalFocusManager::load_national_foci_file( scope_t::PROVINCE | scope_t::COUNTRY, scope_t::PROVINCE | scope_t::COUNTRY, scope_t::NO_SCOPE }; - bool ret = modifier_manager.expect_modifier_value_and_keys_and_default( - move_variable_callback(modifiers), - NATIONAL_FOCUS, - [&good_definition_manager, &encourage_goods, &pop_manager, &encourage_pop_types]( + const auto expect_base_province_modifier_cb = modifier_manager.expect_base_province_modifier(modifiers); + bool ret = NodeTools::expect_dictionary_keys_and_default( + [&good_definition_manager, &encourage_goods, &pop_manager, &encourage_pop_types, &expect_base_province_modifier_cb]( std::string_view key, ast::NodeCPtr value ) -> bool { GoodDefinition const* good = good_definition_manager.get_good_definition_by_identifier(key); @@ -148,7 +145,7 @@ bool NationalFocusManager::load_national_foci_file( return expect_fixed_point(map_callback(encourage_pop_types, pop_type))(value); } - return key_value_invalid_callback(key, value); + return expect_base_province_modifier_cb(key, value) || key_value_invalid_callback(key, value); }, "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)), "ideology", ZERO_OR_ONE, -- cgit v1.2.3-56-ga3b1