aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop/Religion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/pop/Religion.cpp')
-rw-r--r--src/openvic-simulation/pop/Religion.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp
index 0527da7..3fa81bf 100644
--- a/src/openvic-simulation/pop/Religion.cpp
+++ b/src/openvic-simulation/pop/Religion.cpp
@@ -47,7 +47,8 @@ bool ReligionManager::add_religion(
*/
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);
@@ -55,22 +56,24 @@ bool ReligionManager::load_religion_file(ast::NodeCPtr root) {
}
)(root);
lock_religion_groups();
- religions.reserve(religions.size() + total_expected_religions);
- 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 = colour_t::null();
- Religion::icon_t icon = 0;
- bool pagan = false;
+ reserve_more_religions(total_expected_religions);
+ 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 = colour_t::null();
+ 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;
}