diff options
author | Hop311 <Hop3114@gmail.com> | 2024-09-14 21:37:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-14 21:37:10 +0200 |
commit | d8c04cbe53188d4717f8c49f918e01657dbf3440 (patch) | |
tree | 7754de92a23f21e0546dcd09439bf0d3962b096f /src/openvic-simulation/country/CountryDefinition.cpp | |
parent | 7a9206e3869fbb659d296b854c90f5c81755a5ca (diff) | |
parent | a424969548083a977480a6be0f078760a5789bbf (diff) |
Merge pull request #197 from OpenVicProject/country-unlock
CountryInstance unlock tech, invention, crime, building, unit, gas etc.
Diffstat (limited to 'src/openvic-simulation/country/CountryDefinition.cpp')
-rw-r--r-- | src/openvic-simulation/country/CountryDefinition.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/openvic-simulation/country/CountryDefinition.cpp b/src/openvic-simulation/country/CountryDefinition.cpp index a9e7487..12a7a22 100644 --- a/src/openvic-simulation/country/CountryDefinition.cpp +++ b/src/openvic-simulation/country/CountryDefinition.cpp @@ -138,24 +138,31 @@ node_callback_t CountryDefinitionManager::load_country_party( std::string_view party_name; Date start_date, end_date; Ideology const* ideology; - CountryParty::policy_map_t policies; + CountryParty::policy_map_t policies { &politics_manager.get_issue_manager().get_issue_groups() }; bool ret = expect_dictionary_keys_and_default( [&politics_manager, &policies, &party_name](std::string_view key, ast::NodeCPtr value) -> bool { return politics_manager.get_issue_manager().expect_issue_group_str( [&politics_manager, &policies, value, &party_name](IssueGroup const& group) -> bool { - if (policies.contains(&group)) { + CountryParty::policy_map_t::value_ref_t policy = policies[group]; + + if (policy != nullptr) { Logger::error("Country party ", party_name, " has duplicate entry for ", group.get_identifier()); return false; } + return politics_manager.get_issue_manager().expect_issue_identifier( - [&policies, &group](Issue const& issue) -> bool { + [&group, &policy](Issue const& issue) -> bool { if (&issue.get_group() == &group) { - return map_callback(policies, &group)(&issue); + policy = &issue; + return true; } + // TODO - change this back to error/false once TGC no longer has this issue - Logger::warning("Invalid policy ", issue.get_identifier(), ", group is ", - issue.get_group().get_identifier(), " when ", group.get_identifier(), " was expected"); + Logger::warning( + "Invalid policy ", issue.get_identifier(), ", group is ", + issue.get_group().get_identifier(), " when ", group.get_identifier(), " was expected." + ); return true; } )(value); |