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/research/Technology.cpp | 19 +++++++++++-------- src/openvic-simulation/research/Technology.hpp | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/openvic-simulation/research') diff --git a/src/openvic-simulation/research/Technology.cpp b/src/openvic-simulation/research/Technology.cpp index 3ba3624..7851707 100644 --- a/src/openvic-simulation/research/Technology.cpp +++ b/src/openvic-simulation/research/Technology.cpp @@ -143,19 +143,22 @@ bool TechnologyManager::load_technologies_file( })(root); } -#define TECH_MODIFIER(NAME, POS) ret &= modifier_manager.add_modifier_effect(NAME, POS) -#define UNCIV_TECH_MODIFIER(NAME) TECH_MODIFIER(NAME, false); TECH_MODIFIER(StringUtils::append_string_views("self_", NAME), false); -bool TechnologyManager::generate_modifiers(ModifierManager& modifier_manager) { +bool TechnologyManager::generate_modifiers(ModifierManager& modifier_manager) const { bool ret = true; - UNCIV_TECH_MODIFIER("unciv_military_modifier"); - UNCIV_TECH_MODIFIER("unciv_economic_modifier"); + const auto unciv_tech_modifier = [&modifier_manager, &ret](std::string_view name) -> void { + ret &= modifier_manager.add_modifier_effect(name, false); + ret &= modifier_manager.add_modifier_effect(StringUtils::append_string_views("self_", name), false); + }; + + unciv_tech_modifier("unciv_military_modifier"); + unciv_tech_modifier("unciv_economic_modifier"); for (TechnologyFolder const& folder : get_technology_folders()) { - TECH_MODIFIER(StringUtils::append_string_views(folder.get_identifier(), "_research_bonus"), true); + ret &= modifier_manager.add_modifier_effect( + StringUtils::append_string_views(folder.get_identifier(), "_research_bonus"), true + ); } return ret; } -#undef UNCIV_TECH_MODIFIER -#undef TECH_MODIFIER \ No newline at end of file diff --git a/src/openvic-simulation/research/Technology.hpp b/src/openvic-simulation/research/Technology.hpp index 8489e9b..1035a8e 100644 --- a/src/openvic-simulation/research/Technology.hpp +++ b/src/openvic-simulation/research/Technology.hpp @@ -87,6 +87,6 @@ namespace OpenVic { ModifierManager const& modifier_manager, UnitManager const& unit_manager, BuildingTypeManager const& building_type_manager, ast::NodeCPtr root ); // technologies/*.txt - bool generate_modifiers(ModifierManager& modifier_manager); + bool generate_modifiers(ModifierManager& modifier_manager) const; }; } \ No newline at end of file -- cgit v1.2.3-56-ga3b1