aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop/Religion.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-01-22 21:02:58 +0100
committer hop311 <hop3114@gmail.com>2024-01-23 23:14:53 +0100
commit268a6948c0400905dfc335427395519689f067f5 (patch)
treeb30e9b5774130552fe97e27deaf0370d83920c43 /src/openvic-simulation/pop/Religion.cpp
parentd4e597da089a81f719a9c33b46111d1c2c590124 (diff)
Added reserve_more, expect_dictionary_key[s|_map]_reserve_length[_and_default]reserve_more
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;
}