aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop/Religion.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-11-17 10:19:53 +0100
committer GitHub <noreply@github.com>2023-11-17 10:19:53 +0100
commite76336cd92639f4ec71088fc4c80aea4c25528cd (patch)
treeeeed419a7d97ecb58adf63a17eb9184db3e5ed7a /src/openvic-simulation/pop/Religion.cpp
parenta00b558a53edb40c9e6789790036f0b618e80ec1 (diff)
parent886b8b8f396438fc2b7da7d2508f2064d14150a8 (diff)
Merge pull request #75 from OpenVicProject/accumulated-changes
Accumulated changes
Diffstat (limited to 'src/openvic-simulation/pop/Religion.cpp')
-rw-r--r--src/openvic-simulation/pop/Religion.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp
index 99915c3..f52ed3e 100644
--- a/src/openvic-simulation/pop/Religion.cpp
+++ b/src/openvic-simulation/pop/Religion.cpp
@@ -37,7 +37,7 @@ bool ReligionManager::add_religion_group(std::string_view identifier) {
}
bool ReligionManager::add_religion(
- std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan
+ 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!");
@@ -47,10 +47,6 @@ bool ReligionManager::add_religion(
Logger::error("Invalid religion identifier - empty!");
return false;
}
- if (group == nullptr) {
- Logger::error("Null religion group for ", identifier);
- return false;
- }
if (colour > MAX_COLOUR_RGB) {
Logger::error("Invalid religion colour for ", identifier, ": ", colour_to_hex_string(colour));
return false;
@@ -59,7 +55,7 @@ bool ReligionManager::add_religion(
Logger::error("Invalid religion icon for ", identifier, ": ", icon);
return false;
}
- return religions.add_item({ identifier, colour, *group, icon, pagan });
+ return religions.add_item({ identifier, colour, group, icon, pagan });
}
/* REQUIREMENTS:
@@ -77,10 +73,8 @@ 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);
-
- return expect_dictionary([this, religion_group](std::string_view key, ast::NodeCPtr value) -> bool {
+ ret &= expect_religion_group_dictionary([this](ReligionGroup const& religion_group, ast::NodeCPtr religion_group_value) -> bool {
+ 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;