diff options
Diffstat (limited to 'src/openvic-simulation/pop')
-rw-r--r-- | src/openvic-simulation/pop/Culture.cpp | 85 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Culture.hpp | 26 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Pop.cpp | 74 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Pop.hpp | 22 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Religion.cpp | 55 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Religion.hpp | 9 |
6 files changed, 143 insertions, 128 deletions
diff --git a/src/openvic-simulation/pop/Culture.cpp b/src/openvic-simulation/pop/Culture.cpp index 85c96a0..e386930 100644 --- a/src/openvic-simulation/pop/Culture.cpp +++ b/src/openvic-simulation/pop/Culture.cpp @@ -7,11 +7,11 @@ using namespace OpenVic::NodeTools; GraphicalCultureType::GraphicalCultureType(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -CultureGroup::CultureGroup(std::string_view new_identifier, std::string_view new_leader, - GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas) - : HasIdentifier { new_identifier }, leader { new_leader }, - unit_graphical_culture_type { new_unit_graphical_culture_type }, - is_overseas { new_is_overseas } {} +CultureGroup::CultureGroup( + std::string_view new_identifier, std::string_view new_leader, GraphicalCultureType const& new_unit_graphical_culture_type, + bool new_is_overseas +) : HasIdentifier { new_identifier }, leader { new_leader }, unit_graphical_culture_type { new_unit_graphical_culture_type }, + is_overseas { new_is_overseas } {} std::string_view CultureGroup::get_leader() const { return leader; @@ -25,12 +25,11 @@ bool CultureGroup::get_is_overseas() const { return is_overseas; } -Culture::Culture(std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, - std::vector<std::string>&& new_first_names, std::vector<std::string>&& new_last_names) - : HasIdentifierAndColour { new_identifier, new_colour, true, false }, - group { new_group }, - first_names { std::move(new_first_names) }, - last_names { std::move(new_last_names) } {} +Culture::Culture( + std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, + std::vector<std::string>&& new_first_names, std::vector<std::string>&& new_last_names +) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, + first_names { std::move(new_first_names) }, last_names { std::move(new_last_names) } {} CultureGroup const& Culture::get_group() const { return group; @@ -45,9 +44,7 @@ std::vector<std::string> const& Culture::get_last_names() const { } CultureManager::CultureManager() - : graphical_culture_types { "graphical culture types" }, - culture_groups { "culture groups" }, - cultures { "cultures" } {} + : graphical_culture_types { "graphical culture types" }, culture_groups { "culture groups" }, cultures { "cultures" } {} bool CultureManager::add_graphical_culture_type(std::string_view identifier) { if (identifier.empty()) { @@ -57,7 +54,9 @@ bool CultureManager::add_graphical_culture_type(std::string_view identifier) { return graphical_culture_types.add_item({ identifier }); } -bool CultureManager::add_culture_group(std::string_view identifier, std::string_view leader, GraphicalCultureType const* graphical_culture_type, bool is_overseas) { +bool CultureManager::add_culture_group( + std::string_view identifier, std::string_view leader, GraphicalCultureType const* graphical_culture_type, bool is_overseas +) { if (!graphical_culture_types.is_locked()) { Logger::error("Cannot register culture groups until graphical culture types are locked!"); return false; @@ -77,7 +76,10 @@ bool CultureManager::add_culture_group(std::string_view identifier, std::string_ return culture_groups.add_item({ identifier, leader, *graphical_culture_type, is_overseas }); } -bool CultureManager::add_culture(std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string>&& first_names, std::vector<std::string>&& last_names) { +bool CultureManager::add_culture( + std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string>&& first_names, + std::vector<std::string>&& last_names +) { if (!culture_groups.is_locked()) { Logger::error("Cannot register cultures until culture groups are locked!"); return false; @@ -98,8 +100,7 @@ bool CultureManager::add_culture(std::string_view identifier, colour_t colour, C } bool CultureManager::load_graphical_culture_type_file(ast::NodeCPtr root) { - const bool ret = expect_list_reserve_length( - graphical_culture_types, + const bool ret = expect_list_reserve_length(graphical_culture_types, expect_identifier( std::bind(&CultureManager::add_graphical_culture_type, this, std::placeholders::_1) ) @@ -108,9 +109,10 @@ bool CultureManager::load_graphical_culture_type_file(ast::NodeCPtr root) { return ret; } -bool CultureManager::_load_culture_group(size_t& total_expected_cultures, - GraphicalCultureType const* default_unit_graphical_culture_type, - std::string_view culture_group_key, ast::NodeCPtr culture_group_node) { +bool CultureManager::_load_culture_group( + size_t& total_expected_cultures, GraphicalCultureType const* default_unit_graphical_culture_type, + std::string_view culture_group_key, ast::NodeCPtr culture_group_node +) { std::string_view leader; GraphicalCultureType const* unit_graphical_culture_type = default_unit_graphical_culture_type; @@ -119,7 +121,8 @@ bool CultureManager::_load_culture_group(size_t& total_expected_cultures, bool ret = expect_dictionary_keys_and_default( increment_callback(total_expected_cultures), "leader", ONE_EXACTLY, expect_identifier(assign_variable_callback(leader)), - "unit", ZERO_OR_ONE, expect_graphical_culture_type_identifier(assign_variable_callback_pointer(unit_graphical_culture_type)), + "unit", ZERO_OR_ONE, + expect_graphical_culture_type_identifier(assign_variable_callback_pointer(unit_graphical_culture_type)), "union", ZERO_OR_ONE, success_callback, "is_overseas", ZERO_OR_ONE, expect_bool(assign_variable_callback(is_overseas)) )(culture_group_node); @@ -127,8 +130,9 @@ bool CultureManager::_load_culture_group(size_t& total_expected_cultures, return ret; } -bool CultureManager::_load_culture(CultureGroup const* culture_group, - std::string_view culture_key, ast::NodeCPtr culture_node) { +bool CultureManager::_load_culture( + CultureGroup const* culture_group, std::string_view culture_key, ast::NodeCPtr culture_node +) { colour_t colour = NULL_COLOUR; std::vector<std::string> first_names, last_names; @@ -171,35 +175,32 @@ bool CultureManager::load_culture_file(ast::NodeCPtr root) { } static const std::string default_unit_graphical_culture_type_identifier = "Generic"; - GraphicalCultureType const* const default_unit_graphical_culture_type = get_graphical_culture_type_by_identifier(default_unit_graphical_culture_type_identifier); + GraphicalCultureType const* const default_unit_graphical_culture_type = + get_graphical_culture_type_by_identifier(default_unit_graphical_culture_type_identifier); if (default_unit_graphical_culture_type == nullptr) { Logger::error("Failed to find default unit graphical culture type: ", default_unit_graphical_culture_type_identifier); } size_t total_expected_cultures = 0; - bool ret = expect_dictionary_reserve_length( - culture_groups, - [this, default_unit_graphical_culture_type, &total_expected_cultures](std::string_view key, ast::NodeCPtr value) -> bool { + bool ret = expect_dictionary_reserve_length(culture_groups, + [this, default_unit_graphical_culture_type, &total_expected_cultures]( + std::string_view key, ast::NodeCPtr value) -> bool { return _load_culture_group(total_expected_cultures, default_unit_graphical_culture_type, key, value); } )(root); lock_culture_groups(); cultures.reserve(cultures.size() + total_expected_cultures); - ret &= expect_dictionary( - [this](std::string_view culture_group_key, ast::NodeCPtr culture_group_value) -> bool { - CultureGroup const* culture_group = get_culture_group_by_identifier(culture_group_key); - return expect_dictionary( - [this, culture_group](std::string_view key, ast::NodeCPtr value) -> bool { - static const string_set_t reserved_keys = { - "leader", "unit", "union", "is_overseas" - }; - if (reserved_keys.find(key) != reserved_keys.end()) return true; - return _load_culture(culture_group, key, value); - } - )(culture_group_value); - } - )(root); + ret &= expect_dictionary([this](std::string_view culture_group_key, ast::NodeCPtr culture_group_value) -> bool { + CultureGroup const* culture_group = get_culture_group_by_identifier(culture_group_key); + return expect_dictionary([this, culture_group](std::string_view key, ast::NodeCPtr value) -> bool { + static const string_set_t reserved_keys = { "leader", "unit", "union", "is_overseas" }; + if (reserved_keys.find(key) != reserved_keys.end()) { + return true; + } + return _load_culture(culture_group, key, value); + })(culture_group_value); + })(root); lock_cultures(); return ret; } diff --git a/src/openvic-simulation/pop/Culture.hpp b/src/openvic-simulation/pop/Culture.hpp index 688733e..402af0c 100644 --- a/src/openvic-simulation/pop/Culture.hpp +++ b/src/openvic-simulation/pop/Culture.hpp @@ -26,7 +26,10 @@ namespace OpenVic { // TODO - union tag - CultureGroup(std::string_view new_identifier, std::string_view new_leader, GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas); + CultureGroup( + std::string_view new_identifier, std::string_view new_leader, + GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas + ); public: CultureGroup(CultureGroup&&) = default; @@ -45,7 +48,10 @@ namespace OpenVic { // TODO - radicalism, primary tag - Culture(std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, std::vector<std::string>&& new_first_names, std::vector<std::string>&& new_last_names); + Culture( + std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, + std::vector<std::string>&& new_first_names, std::vector<std::string>&& new_last_names + ); public: Culture(Culture&&) = default; @@ -61,8 +67,10 @@ namespace OpenVic { IdentifierRegistry<CultureGroup> culture_groups; IdentifierRegistry<Culture> cultures; - bool _load_culture_group(size_t& total_expected_cultures, GraphicalCultureType const* default_unit_graphical_culture_type, - std::string_view culture_group_key, ast::NodeCPtr culture_group_node); + bool _load_culture_group( + size_t& total_expected_cultures, GraphicalCultureType const* default_unit_graphical_culture_type, + std::string_view culture_group_key, ast::NodeCPtr culture_group_node + ); bool _load_culture(CultureGroup const* culture_group, std::string_view culture_key, ast::NodeCPtr node); public: @@ -71,10 +79,16 @@ namespace OpenVic { bool add_graphical_culture_type(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(graphical_culture_type) - bool add_culture_group(std::string_view identifier, std::string_view leader, GraphicalCultureType const* new_graphical_culture_type, bool is_overseas); + bool add_culture_group( + std::string_view identifier, std::string_view leader, GraphicalCultureType const* new_graphical_culture_type, + bool is_overseas + ); IDENTIFIER_REGISTRY_ACCESSORS(culture_group) - bool add_culture(std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string>&& first_names, std::vector<std::string>&& last_names); + bool add_culture( + std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string>&& first_names, + std::vector<std::string>&& last_names + ); IDENTIFIER_REGISTRY_ACCESSORS(culture) bool load_graphical_culture_type_file(ast::NodeCPtr root); diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index 5286393..f63a704 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -9,11 +9,9 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -Pop::Pop(PopType const& new_type, Culture const& new_culture, Religion const& new_religion, pop_size_t new_size) - : type { new_type }, - culture { new_culture }, - religion { new_religion }, - size { new_size } { +Pop::Pop( + PopType const& new_type, Culture const& new_culture, Religion const& new_religion, pop_size_t new_size +) : type { new_type }, culture { new_culture }, religion { new_religion }, size { new_size } { assert(size > 0); } @@ -49,25 +47,16 @@ Pop::pop_size_t Pop::get_pop_daily_change() const { return Pop::get_num_promoted() - (Pop::get_num_demoted() + Pop::get_num_migrated()); } -PopType::PopType(std::string_view new_identifier, colour_t new_colour, - strata_t new_strata, sprite_t new_sprite, - Good::good_map_t&& new_life_needs, Good::good_map_t&& new_everyday_needs, - Good::good_map_t&& new_luxury_needs, rebel_units_t&& new_rebel_units, - Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, - bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave) - : HasIdentifierAndColour { new_identifier, new_colour, true, false }, - strata { new_strata }, - sprite { new_sprite }, - life_needs { std::move(new_life_needs) }, - everyday_needs { std::move(new_everyday_needs) }, - luxury_needs { std::move(new_luxury_needs) }, - rebel_units { std::move(new_rebel_units) }, - max_size { new_max_size }, - merge_max_size { new_merge_max_size }, - state_capital_only { new_state_capital_only }, - demote_migrant { new_demote_migrant }, - is_artisan { new_is_artisan }, - is_slave { new_is_slave } { +PopType::PopType( + std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, + Good::good_map_t&& new_life_needs, Good::good_map_t&& new_everyday_needs, Good::good_map_t&& new_luxury_needs, + rebel_units_t&& new_rebel_units, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, + bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave +) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, strata { new_strata }, sprite { new_sprite }, + life_needs { std::move(new_life_needs) }, everyday_needs { std::move(new_everyday_needs) }, + luxury_needs { std::move(new_luxury_needs) }, rebel_units { std::move(new_rebel_units) }, max_size { new_max_size }, + merge_max_size { new_merge_max_size }, state_capital_only { new_state_capital_only }, + demote_migrant { new_demote_migrant }, is_artisan { new_is_artisan }, is_slave { new_is_slave } { assert(sprite > 0); assert(max_size >= 0); assert(merge_max_size >= 0); @@ -123,10 +112,12 @@ bool PopType::get_is_slave() const { PopManager::PopManager() : pop_types { "pop types" } {} -bool PopManager::add_pop_type(std::string_view identifier, colour_t colour, PopType::strata_t strata, - PopType::sprite_t sprite, Good::good_map_t&& life_needs, Good::good_map_t&& everyday_needs, - Good::good_map_t&& luxury_needs, PopType::rebel_units_t&& rebel_units, Pop::pop_size_t max_size, - Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave) { +bool PopManager::add_pop_type( + std::string_view identifier, colour_t colour, PopType::strata_t strata, PopType::sprite_t sprite, + Good::good_map_t&& life_needs, Good::good_map_t&& everyday_needs, Good::good_map_t&& luxury_needs, + PopType::rebel_units_t&& rebel_units, Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, + bool demote_migrant, bool is_artisan, bool is_slave +) { if (identifier.empty()) { Logger::error("Invalid pop type identifier - empty!"); return false; @@ -147,15 +138,19 @@ bool PopManager::add_pop_type(std::string_view identifier, colour_t colour, PopT Logger::error("Invalid pop type merge max size for ", identifier, ": ", merge_max_size); return false; } - return pop_types.add_item({ identifier, colour, strata, sprite, std::move(life_needs), std::move(everyday_needs), - std::move(luxury_needs), std::move(rebel_units), max_size, merge_max_size, state_capital_only, demote_migrant, - is_artisan, is_slave }); + return pop_types.add_item({ + identifier, colour, strata, sprite, std::move(life_needs), std::move(everyday_needs), + std::move(luxury_needs), std::move(rebel_units), max_size, merge_max_size, state_capital_only, + demote_migrant, is_artisan, is_slave + }); } /* REQUIREMENTS: * POP-3, POP-4, POP-5, POP-6, POP-7, POP-8, POP-9, POP-10, POP-11, POP-12, POP-13, POP-14 */ -bool PopManager::load_pop_type_file(std::string_view filestem, UnitManager const& unit_manager, GoodManager const& good_manager, ast::NodeCPtr root) { +bool PopManager::load_pop_type_file( + std::string_view filestem, UnitManager const& unit_manager, GoodManager const& good_manager, ast::NodeCPtr root +) { static const string_map_t<PopType::strata_t> strata_map = { { "poor", PopType::strata_t::POOR }, { "middle", PopType::strata_t::MIDDLE }, @@ -209,13 +204,15 @@ bool PopManager::load_pop_type_file(std::string_view filestem, UnitManager const "unemployment", ZERO_OR_ONE, success_callback )(root); - ret &= add_pop_type(filestem, colour, strata, sprite, std::move(life_needs), std::move(everyday_needs), - std::move(luxury_needs), std::move(rebel_units), max_size, merge_max_size, state_capital_only, demote_migrant, - is_artisan, is_slave); + ret &= add_pop_type( + filestem, colour, strata, sprite, std::move(life_needs), std::move(everyday_needs), std::move(luxury_needs), + std::move(rebel_units), max_size, merge_max_size, state_capital_only, demote_migrant, is_artisan, is_slave + ); return ret; } -bool PopManager::load_pop_into_province(Province& province, std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const { +bool PopManager::load_pop_into_province(Province& province, std::string_view pop_type_identifier, ast::NodeCPtr pop_node) + const { PopType const* type = get_pop_type_by_identifier(pop_type_identifier); Culture const* culture = nullptr; Religion const* religion = nullptr; @@ -231,7 +228,10 @@ bool PopManager::load_pop_into_province(Province& province, std::string_view pop if (type != nullptr && culture != nullptr && religion != nullptr && size > 0) { ret &= province.add_pop({ *type, *culture, *religion, size }); } else { - Logger::warning("Some pop arguments are invalid: province = ", province, ", type = ", type, ", culture = ", culture, ", religion = ", religion, ", size = ", size); + Logger::warning( + "Some pop arguments are invalid: province = ", province, ", type = ", type, ", culture = ", culture, + ", religion = ", religion, ", size = ", size + ); } return ret; } diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp index 7261831..4abb2a9 100644 --- a/src/openvic-simulation/pop/Pop.hpp +++ b/src/openvic-simulation/pop/Pop.hpp @@ -52,11 +52,7 @@ namespace OpenVic { using rebel_units_t = decimal_map_t<Unit const*>; private: - const enum class strata_t { - POOR, - MIDDLE, - RICH - } strata; + const enum class strata_t { POOR, MIDDLE, RICH } strata; const sprite_t sprite; const Good::good_map_t life_needs, everyday_needs, luxury_needs; const rebel_units_t rebel_units; @@ -65,10 +61,12 @@ namespace OpenVic { // TODO - country and province migration targets, promote_to targets, ideologies and issues - PopType(std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, + PopType( + std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, Good::good_map_t&& new_life_needs, Good::good_map_t&& new_everyday_needs, Good::good_map_t&& new_luxury_needs, rebel_units_t&& new_rebel_units, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, - bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave); + bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave + ); public: PopType(PopType&&) = default; @@ -102,13 +100,17 @@ namespace OpenVic { REF_GETTERS(culture_manager) REF_GETTERS(religion_manager) - bool add_pop_type(std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite, + bool add_pop_type( + std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite, Good::good_map_t&& life_needs, Good::good_map_t&& everyday_needs, Good::good_map_t&& luxury_needs, PopType::rebel_units_t&& rebel_units, Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, - bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave); + bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave + ); IDENTIFIER_REGISTRY_ACCESSORS(pop_type) - bool load_pop_type_file(std::string_view filestem, UnitManager const& unit_manager, GoodManager const& good_manager, ast::NodeCPtr root); + bool load_pop_type_file( + std::string_view filestem, UnitManager const& unit_manager, GoodManager const& good_manager, ast::NodeCPtr root + ); bool load_pop_into_province(Province& province, std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const; }; } diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp index 1152ae5..489984d 100644 --- a/src/openvic-simulation/pop/Religion.cpp +++ b/src/openvic-simulation/pop/Religion.cpp @@ -7,12 +7,10 @@ using namespace OpenVic::NodeTools; ReligionGroup::ReligionGroup(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -Religion::Religion(std::string_view new_identifier, colour_t new_colour, - ReligionGroup const& new_group, icon_t new_icon, bool new_pagan) - : HasIdentifierAndColour { new_identifier, new_colour, true, false }, - group { new_group }, - icon { new_icon }, - pagan { new_pagan } { +Religion::Religion( + std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, bool new_pagan +) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, icon { new_icon }, + pagan { new_pagan } { assert(icon > 0); } @@ -28,9 +26,7 @@ bool Religion::get_pagan() const { return pagan; } -ReligionManager::ReligionManager() - : religion_groups { "religion groups" }, - religions { "religions" } {} +ReligionManager::ReligionManager() : religion_groups { "religion groups" }, religions { "religions" } {} bool ReligionManager::add_religion_group(std::string_view identifier) { if (identifier.empty()) { @@ -40,7 +36,9 @@ bool ReligionManager::add_religion_group(std::string_view identifier) { return religion_groups.add_item({ identifier }); } -bool ReligionManager::add_religion(std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan) { +bool ReligionManager::add_religion( + std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan +) { if (!religion_groups.is_locked()) { Logger::error("Cannot register religions until religion groups are locked!"); return false; @@ -70,8 +68,7 @@ bool ReligionManager::add_religion(std::string_view identifier, colour_t colour, */ bool ReligionManager::load_religion_file(ast::NodeCPtr root) { size_t total_expected_religions = 0; - bool ret = expect_dictionary_reserve_length( - religion_groups, + bool ret = expect_dictionary_reserve_length(religion_groups, [this, &total_expected_religions](std::string_view key, ast::NodeCPtr value) -> bool { bool ret = expect_length(add_variable_callback(total_expected_religions))(value); ret &= add_religion_group(key); @@ -80,27 +77,23 @@ bool ReligionManager::load_religion_file(ast::NodeCPtr root) { )(root); lock_religion_groups(); religions.reserve(religions.size() + total_expected_religions); - ret &= expect_dictionary( - [this](std::string_view religion_group_key, ast::NodeCPtr religion_group_value) -> bool { - ReligionGroup const* religion_group = get_religion_group_by_identifier(religion_group_key); + ret &= expect_dictionary([this](std::string_view religion_group_key, ast::NodeCPtr religion_group_value) -> bool { + ReligionGroup const* religion_group = get_religion_group_by_identifier(religion_group_key); - return expect_dictionary( - [this, religion_group](std::string_view key, ast::NodeCPtr value) -> bool { - colour_t colour = NULL_COLOUR; - Religion::icon_t icon = 0; - bool pagan = false; + return expect_dictionary([this, religion_group](std::string_view key, ast::NodeCPtr value) -> bool { + colour_t colour = NULL_COLOUR; + Religion::icon_t icon = 0; + bool pagan = false; - bool ret = expect_dictionary_keys( - "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)), - "color", ONE_EXACTLY, expect_colour(assign_variable_callback(colour)), - "pagan", ZERO_OR_ONE, expect_bool(assign_variable_callback(pagan)) - )(value); - ret &= add_religion(key, colour, religion_group, icon, pagan); - return ret; - } - )(religion_group_value); - } - )(root); + bool ret = expect_dictionary_keys( + "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)), + "color", ONE_EXACTLY, expect_colour(assign_variable_callback(colour)), + "pagan", ZERO_OR_ONE, expect_bool(assign_variable_callback(pagan)) + )(value); + ret &= add_religion(key, colour, religion_group, icon, pagan); + return ret; + })(religion_group_value); + })(root); lock_religions(); return ret; } diff --git a/src/openvic-simulation/pop/Religion.hpp b/src/openvic-simulation/pop/Religion.hpp index 6b17266..a47754d 100644 --- a/src/openvic-simulation/pop/Religion.hpp +++ b/src/openvic-simulation/pop/Religion.hpp @@ -27,7 +27,10 @@ namespace OpenVic { const icon_t icon; const bool pagan; - Religion(std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, bool new_pagan); + Religion( + std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, + bool new_pagan + ); public: Religion(Religion&&) = default; @@ -48,7 +51,9 @@ namespace OpenVic { bool add_religion_group(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(religion_group) - bool add_religion(std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan); + bool add_religion( + std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan + ); IDENTIFIER_REGISTRY_ACCESSORS(religion) bool load_religion_file(ast::NodeCPtr root); |