diff options
Diffstat (limited to 'src/openvic-simulation/country')
-rw-r--r-- | src/openvic-simulation/country/Country.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/openvic-simulation/country/Country.cpp b/src/openvic-simulation/country/Country.cpp index ed8c3cb..d666411 100644 --- a/src/openvic-simulation/country/Country.cpp +++ b/src/openvic-simulation/country/Country.cpp @@ -122,10 +122,12 @@ bool CountryManager::add_country( return false; } - return countries.add_item({ identifier, color, graphical_culture, std::move(parties), std::move(unit_names), dynamic_tag, std::move(alternative_colours) }); + return countries.add_item({ identifier, color, graphical_culture, std::move(parties), + std::move(unit_names), dynamic_tag, std::move(alternative_colours) }); } -bool CountryManager::load_country_data_file(GameManager& game_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root) { +bool CountryManager::load_country_data_file(GameManager& game_manager, + std::string_view name, bool is_dynamic, ast::NodeCPtr root) { colour_t color; const GraphicalCultureType* graphical_culture; std::vector<CountryParty> country_parties; @@ -135,7 +137,8 @@ bool CountryManager::load_country_data_file(GameManager& game_manager, std::stri bool ret = expect_dictionary_keys_and_default( [&game_manager, &alternative_colours, &name](std::string_view key, ast::NodeCPtr value) -> bool { const GovernmentType* colour_gov_type; - bool ret = game_manager.get_politics_manager().get_government_type_manager().expect_government_type_str(assign_variable_callback_pointer(colour_gov_type))(key); + bool ret = game_manager.get_politics_manager().get_government_type_manager() + .expect_government_type_str(assign_variable_callback_pointer(colour_gov_type))(key); if (!ret) return false; @@ -147,14 +150,18 @@ bool CountryManager::load_country_data_file(GameManager& game_manager, std::stri return alternative_colours.emplace(std::move(colour_gov_type), std::move(alternative_colour)).second; }, "color", ONE_EXACTLY, expect_colour(assign_variable_callback(color)), - "graphical_culture", ONE_EXACTLY, expect_identifier_or_string([&game_manager, &graphical_culture, &name](std::string_view value) -> bool { - graphical_culture = game_manager.get_pop_manager().get_culture_manager().get_graphical_culture_type_by_identifier(value); - if (graphical_culture == nullptr) { - Logger::error("When loading country ", name, ", specified graphical culture ", value, " is invalid!\nCheck that CultureManager has loaded before CountryManager."); - } + "graphical_culture", ONE_EXACTLY, expect_identifier_or_string( + [&game_manager, &graphical_culture, &name](std::string_view value) -> bool { + graphical_culture = game_manager.get_pop_manager().get_culture_manager() + .get_graphical_culture_type_by_identifier(value); + if (graphical_culture == nullptr) { + Logger::error("When loading country ", name, ", specified graphical culture ", value, + " is invalid!\nCheck that CultureManager has loaded before CountryManager."); + } - return graphical_culture != nullptr; - }), + return graphical_culture != nullptr; + } + ), "party", ZERO_OR_MORE, [&game_manager, &country_parties, &name](ast::NodeCPtr value) -> bool { std::string_view party_name; Date start_date, end_date; @@ -180,7 +187,8 @@ bool CountryManager::load_country_data_file(GameManager& game_manager, std::stri "name", ONE_EXACTLY, expect_identifier_or_string(assign_variable_callback(party_name)), "start_date", ONE_EXACTLY, expect_date(assign_variable_callback(start_date)), "end_date", ONE_EXACTLY, expect_date(assign_variable_callback(end_date)), - "ideology", ONE_EXACTLY, expect_identifier_or_string(game_manager.get_politics_manager().get_ideology_manager().expect_ideology_str(assign_variable_callback_pointer(ideology))) + "ideology", ONE_EXACTLY, expect_identifier_or_string(game_manager.get_politics_manager() + .get_ideology_manager().expect_ideology_str(assign_variable_callback_pointer(ideology))) )(value); country_parties.push_back({ party_name, start_date, end_date, *ideology, std::move(policies) }); @@ -203,6 +211,7 @@ bool CountryManager::load_country_data_file(GameManager& game_manager, std::stri }) )(root); - ret &= add_country(name, color, *graphical_culture, std::move(country_parties), std::move(unit_names), is_dynamic, std::move(alternative_colours)); + ret &= add_country(name, color, *graphical_culture, std::move(country_parties), + std::move(unit_names), is_dynamic, std::move(alternative_colours)); return ret; } |