aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-12-14 00:56:20 +0100
committer hop311 <hop3114@gmail.com>2023-12-14 00:56:20 +0100
commit3b6be81fb327a9c5e7bcc7c2127f513048e67480 (patch)
tree83d5a86fe04594feada3c82258d9c08624e542be /src/openvic-simulation/pop
parent35e07b57aed9177be1bfeb7732ed8f17c71f2354 (diff)
Removed modifier generating macros.
Diffstat (limited to 'src/openvic-simulation/pop')
-rw-r--r--src/openvic-simulation/pop/Pop.cpp27
-rw-r--r--src/openvic-simulation/pop/Pop.hpp2
2 files changed, 15 insertions, 14 deletions
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index 88ea69a..39deeaa 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -219,21 +219,22 @@ bool PopManager::load_pop_into_vector(
return ret;
}
-#define STRATA_MODIFIER(name, positive_good) \
- ret &= modifier_manager.add_modifier_effect(StringUtils::append_string_views(strata.get_identifier(), name), positive_good)
-
-bool PopManager::generate_modifiers(ModifierManager& modifier_manager) {
+bool PopManager::generate_modifiers(ModifierManager& modifier_manager) const {
bool ret = true;
for (Strata const& strata : get_stratas()) {
- STRATA_MODIFIER("_income_modifier", true);
- STRATA_MODIFIER("_savings_modifier", true);
- STRATA_MODIFIER("_vote", true);
-
- STRATA_MODIFIER("_life_needs", false);
- STRATA_MODIFIER("_everyday_needs", false);
- STRATA_MODIFIER("_luxury_needs", false);
+ const auto strata_modifier = [&modifier_manager, &ret, &strata](std::string_view suffix, bool positive_good) -> void {
+ ret &= modifier_manager.add_modifier_effect(
+ StringUtils::append_string_views(strata.get_identifier(), suffix), positive_good
+ );
+ };
+
+ strata_modifier("_income_modifier", true);
+ strata_modifier("_savings_modifier", true);
+ strata_modifier("_vote", true);
+
+ strata_modifier("_life_needs", false);
+ strata_modifier("_everyday_needs", false);
+ strata_modifier("_luxury_needs", false);
}
return ret;
}
-
-#undef STRATA_MODIFIER
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index 3d52362..0c84aae 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -141,6 +141,6 @@ namespace OpenVic {
bool *non_integer_size
) const;
- bool generate_modifiers(ModifierManager& modifier_manager);
+ bool generate_modifiers(ModifierManager& modifier_manager) const;
};
}