diff options
author | hop311 <hop3114@gmail.com> | 2023-10-29 15:11:10 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-10-29 21:08:08 +0100 |
commit | 1b5e43fa7750cc4025d32f18390593cbce3ba842 (patch) | |
tree | d37fcb69766ec029ea4e3e2816c419f9d7e05f7c /src/openvic-simulation/pop/Religion.cpp | |
parent | 164264b047921dbe1567d2af183e1cffb200a8cb (diff) |
Clang-format formatting (with manual cleanup)
Diffstat (limited to 'src/openvic-simulation/pop/Religion.cpp')
-rw-r--r-- | src/openvic-simulation/pop/Religion.cpp | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp index a685fca..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,8 +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; @@ -71,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); @@ -81,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; } |