From 3b6be81fb327a9c5e7bcc7c2127f513048e67480 Mon Sep 17 00:00:00 2001 From: hop311 Date: Wed, 13 Dec 2023 23:56:20 +0000 Subject: Removed modifier generating macros. --- src/openvic-simulation/economy/Good.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/openvic-simulation/economy/Good.cpp') 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 -- cgit v1.2.3-56-ga3b1