From 4ef33d4df6198e613b0f27406d49978c8ea2fb97 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Sun, 10 Dec 2023 23:15:41 +0100 Subject: feat: improved identifier registry macro --- src/openvic-simulation/research/Invention.cpp | 2 -- src/openvic-simulation/research/Invention.hpp | 6 +----- src/openvic-simulation/research/Technology.cpp | 4 ---- src/openvic-simulation/research/Technology.hpp | 14 ++++---------- 4 files changed, 5 insertions(+), 21 deletions(-) (limited to 'src/openvic-simulation/research') diff --git a/src/openvic-simulation/research/Invention.cpp b/src/openvic-simulation/research/Invention.cpp index 381a249..f9f3f7b 100644 --- a/src/openvic-simulation/research/Invention.cpp +++ b/src/openvic-simulation/research/Invention.cpp @@ -16,8 +16,6 @@ Invention::Invention( enabled_crimes { std::move(new_enabled_crimes) }, unlock_gas_attack { new_unlock_gas_attack }, unlock_gas_defence { new_unlock_gas_defence } {} //TODO icon -InventionManager::InventionManager() : inventions { "inventions" } {} - bool InventionManager::add_invention( std::string_view identifier, ModifierValue&& values, bool news, Invention::unit_set_t&& activated_units, Invention::building_set_t&& activated_buildings, Invention::crime_set_t&& enabled_crimes, diff --git a/src/openvic-simulation/research/Invention.hpp b/src/openvic-simulation/research/Invention.hpp index dc4256e..a8ce96d 100644 --- a/src/openvic-simulation/research/Invention.hpp +++ b/src/openvic-simulation/research/Invention.hpp @@ -38,19 +38,15 @@ namespace OpenVic { }; struct InventionManager { - IdentifierRegistry inventions; + IdentifierRegistry IDENTIFIER_REGISTRY(invention); public: - InventionManager(); - bool add_invention( std::string_view identifier, ModifierValue&& values, bool news, Invention::unit_set_t&& activated_units, Invention::building_set_t&& activated_buildings, Invention::crime_set_t&& enabled_crimes, bool unlock_gas_attack, bool unlock_gas_defence ); - IDENTIFIER_REGISTRY_ACCESSORS(invention) - bool load_inventions_file( ModifierManager const& modifier_manager, UnitManager const& unit_manager, BuildingTypeManager const& building_type_manager, CrimeManager const& crime_manager, ast::NodeCPtr root diff --git a/src/openvic-simulation/research/Technology.cpp b/src/openvic-simulation/research/Technology.cpp index f8ebb4b..3ba3624 100644 --- a/src/openvic-simulation/research/Technology.cpp +++ b/src/openvic-simulation/research/Technology.cpp @@ -19,10 +19,6 @@ Technology::Technology( TechnologySchool::TechnologySchool(std::string_view new_identifier, ModifierValue&& new_values) : Modifier { new_identifier, std::move(new_values), 0 } {} -TechnologyManager::TechnologyManager() - : technology_folders { "technology folders" }, technology_areas { "technology areas" }, technologies { "technologies" }, - technology_schools { "technology schools" } {} - bool TechnologyManager::add_technology_folder(std::string_view identifier) { if (identifier.empty()) { Logger::error("Invalid technology folder identifier - empty!"); diff --git a/src/openvic-simulation/research/Technology.hpp b/src/openvic-simulation/research/Technology.hpp index 52db87e..8489e9b 100644 --- a/src/openvic-simulation/research/Technology.hpp +++ b/src/openvic-simulation/research/Technology.hpp @@ -64,28 +64,22 @@ namespace OpenVic { }; struct TechnologyManager { - IdentifierRegistry technology_folders; - IdentifierRegistry technology_areas; - IdentifierRegistry technologies; - IdentifierRegistry technology_schools; + IdentifierRegistry IDENTIFIER_REGISTRY(technology_folder); + IdentifierRegistry IDENTIFIER_REGISTRY(technology_area); + IdentifierRegistry IDENTIFIER_REGISTRY_CUSTOM_PLURAL(technology, technologies); + IdentifierRegistry IDENTIFIER_REGISTRY(technology_school); public: - TechnologyManager(); - bool add_technology_folder(std::string_view identifier); - IDENTIFIER_REGISTRY_ACCESSORS(technology_folder) bool add_technology_area(std::string_view identifier, TechnologyFolder const* folder); - IDENTIFIER_REGISTRY_ACCESSORS(technology_area) bool add_technology( std::string_view identifier, TechnologyArea const* area, Date::year_t year, fixed_point_t cost, bool unciv_military, uint8_t unit, Technology::unit_set_t&& activated_units, Technology::building_set_t&& activated_buildings, ModifierValue&& values); - IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(technology, technologies) bool add_technology_school(std::string_view identifier, ModifierValue&& values); - IDENTIFIER_REGISTRY_ACCESSORS(technology_school) bool load_technology_file_areas(ast::NodeCPtr root); // common/technology.txt bool load_technology_file_schools(ModifierManager const& modifier_manager, ast::NodeCPtr root); // also common/technology.txt -- cgit v1.2.3-56-ga3b1