diff options
Diffstat (limited to 'src/openvic-simulation/economy')
-rw-r--r-- | src/openvic-simulation/economy/Good.cpp | 32 | ||||
-rw-r--r-- | src/openvic-simulation/economy/Good.hpp | 2 |
2 files changed, 17 insertions, 17 deletions
diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/Good.cpp index 5500483..44b896b 100644 --- a/src/openvic-simulation/economy/Good.cpp +++ b/src/openvic-simulation/economy/Good.cpp @@ -94,22 +94,22 @@ bool GoodManager::load_goods_file(ast::NodeCPtr root) { return ret; } -#define GOOD_MODIFIER(name) \ - modifier_manager.register_complex_modifier(name); \ - for (Good const& good : this->get_goods()) { \ - ret &= modifier_manager.add_modifier_effect( \ - StringUtils::append_string_views(name, "_", good.get_identifier()), \ - true \ - ); \ - } - -bool GoodManager::generate_modifiers(ModifierManager& modifier_manager) { +bool GoodManager::generate_modifiers(ModifierManager& modifier_manager) const { bool ret = true; - GOOD_MODIFIER("factory_goods_output"); - GOOD_MODIFIER("factory_goods_throughput"); - GOOD_MODIFIER("rgo_goods_output"); - GOOD_MODIFIER("rgo_size"); + + const auto good_modifier = [this, &modifier_manager, &ret](std::string_view name) -> void { + ret &= modifier_manager.register_complex_modifier(name); + for (Good const& good : get_goods()) { + ret &= modifier_manager.add_modifier_effect( + StringUtils::append_string_views(name, "_", good.get_identifier()), true + ); + } + }; + + good_modifier("factory_goods_output"); + good_modifier("factory_goods_throughput"); + good_modifier("rgo_goods_output"); + good_modifier("rgo_size"); + return ret; } - -#undef GOOD_MODIFIER
\ No newline at end of file diff --git a/src/openvic-simulation/economy/Good.hpp b/src/openvic-simulation/economy/Good.hpp index c595768..d9d4251 100644 --- a/src/openvic-simulation/economy/Good.hpp +++ b/src/openvic-simulation/economy/Good.hpp @@ -76,6 +76,6 @@ namespace OpenVic { void reset_to_defaults(); bool load_goods_file(ast::NodeCPtr root); - bool generate_modifiers(ModifierManager& modifier_manager); + bool generate_modifiers(ModifierManager& modifier_manager) const; }; } |