aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/pop/Religion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic/pop/Religion.cpp')
-rw-r--r--src/openvic/pop/Religion.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/openvic/pop/Religion.cpp b/src/openvic/pop/Religion.cpp
index 58b73e5..f7c657a 100644
--- a/src/openvic/pop/Religion.cpp
+++ b/src/openvic/pop/Religion.cpp
@@ -32,10 +32,10 @@ ReligionManager::ReligionManager()
: religion_groups { "religion groups" },
religions { "religions" } {}
-return_t ReligionManager::add_religion_group(const std::string_view identifier) {
+bool ReligionManager::add_religion_group(const std::string_view identifier) {
if (identifier.empty()) {
Logger::error("Invalid religion group identifier - empty!");
- return FAILURE;
+ return false;
}
return religion_groups.add_item({ identifier });
}
@@ -56,26 +56,26 @@ std::vector<ReligionGroup> const& ReligionManager::get_religion_groups() const {
return religion_groups.get_items();
}
-return_t ReligionManager::add_religion(const std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan) {
+bool ReligionManager::add_religion(const 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 FAILURE;
+ return false;
}
if (identifier.empty()) {
Logger::error("Invalid religion identifier - empty!");
- return FAILURE;
+ return false;
}
if (group == nullptr) {
Logger::error("Null religion group for ", identifier);
- return FAILURE;
+ return false;
}
if (colour > MAX_COLOUR_RGB) {
Logger::error("Invalid religion colour for ", identifier, ": ", colour_to_hex_string(colour));
- return FAILURE;
+ return false;
}
if (icon <= 0) {
Logger::error("Invalid religion icon for ", identifier, ": ", icon);
- return FAILURE;
+ return false;
}
return religions.add_item({ identifier, colour, *group, icon, pagan });
}
@@ -96,47 +96,47 @@ std::vector<Religion> const& ReligionManager::get_religions() const {
return religions.get_items();
}
-return_t ReligionManager::load_religion_file(ast::NodeCPtr root) {
+bool ReligionManager::load_religion_file(ast::NodeCPtr root) {
size_t total_expected_religions = 0;
- return_t ret = expect_dictionary_reserve_length(
+ bool ret = expect_dictionary_reserve_length(
religion_groups,
- [this, &total_expected_religions](std::string_view key, ast::NodeCPtr value) -> return_t {
- return_t ret = expect_list_and_length(
+ [this, &total_expected_religions](std::string_view key, ast::NodeCPtr value) -> bool {
+ bool ret = expect_list_and_length(
[&total_expected_religions](size_t size) -> size_t {
total_expected_religions += size;
return 0;
},
success_callback
)(value);
- if (add_religion_group(key) != SUCCESS) ret = FAILURE;
+ ret &= add_religion_group(key);
return ret;
}
)(root);
lock_religion_groups();
religions.reserve(religions.size() + total_expected_religions);
- if (expect_dictionary(
- [this](std::string_view religion_group_key, ast::NodeCPtr religion_group_value) -> return_t {
+ 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) -> return_t {
+ [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_t ret = expect_dictionary_keys(
+ bool ret = expect_dictionary_keys(
"icon", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("religion icon", icon)),
"color", ONE_EXACTLY, expect_colour(assign_variable_callback(colour)),
"pagan", ZERO_OR_ONE, expect_bool(assign_variable_callback(pagan))
)(value);
- if (add_religion(key, colour, religion_group, icon, pagan) != SUCCESS) ret = FAILURE;
+ ret &= add_religion(key, colour, religion_group, icon, pagan);
return ret;
}
)(religion_group_value);
}
- )(root) != SUCCESS) ret = FAILURE;
+ )(root);
lock_religions();
return ret;
}