aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop/Religion.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-10-29 21:14:55 +0100
committer GitHub <noreply@github.com>2023-10-29 21:14:55 +0100
commit06cc0606156d009026930c785c62434276fbe782 (patch)
treed37fcb69766ec029ea4e3e2816c419f9d7e05f7c /src/openvic-simulation/pop/Religion.cpp
parentd8ec90f07342876e9331819bd3cc372050f78248 (diff)
parent1b5e43fa7750cc4025d32f18390593cbce3ba842 (diff)
Merge pull request #67 from OpenVicProject/format
Formating
Diffstat (limited to 'src/openvic-simulation/pop/Religion.cpp')
-rw-r--r--src/openvic-simulation/pop/Religion.cpp55
1 files changed, 24 insertions, 31 deletions
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;
}