From 3fcdd0c7fce2de4cbe14a0cc3d6fb4c2731b93d9 Mon Sep 17 00:00:00 2001 From: hop311 Date: Fri, 20 Sep 2024 22:45:19 +0100 Subject: Add modifier type enum --- src/openvic-simulation/map/Crime.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/openvic-simulation/map/Crime.cpp') diff --git a/src/openvic-simulation/map/Crime.cpp b/src/openvic-simulation/map/Crime.cpp index 03da0fc..fb521ad 100644 --- a/src/openvic-simulation/map/Crime.cpp +++ b/src/openvic-simulation/map/Crime.cpp @@ -6,16 +6,18 @@ using namespace OpenVic::NodeTools; Crime::Crime( std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon, ConditionScript&& new_trigger, bool new_default_active -) : TriggeredModifier { new_identifier, std::move(new_values), new_icon, std::move(new_trigger) }, +) : TriggeredModifier { new_identifier, std::move(new_values), modifier_type_t::CRIME, new_icon, std::move(new_trigger) }, default_active { new_default_active } {} bool CrimeManager::add_crime_modifier( - std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon, ConditionScript&& trigger, bool default_active + std::string_view identifier, ModifierValue&& values, IconModifier::icon_t icon, ConditionScript&& trigger, + bool default_active ) { if (identifier.empty()) { Logger::error("Invalid crime modifier effect identifier - empty!"); return false; } + return crime_modifiers.add_item( { identifier, std::move(values), icon, std::move(trigger), default_active }, duplicate_warning_callback ); @@ -26,7 +28,7 @@ bool CrimeManager::load_crime_modifiers(ModifierManager const& modifier_manager, crime_modifiers, [this, &modifier_manager](std::string_view key, ast::NodeCPtr value) -> bool { ModifierValue modifier_value; - Modifier::icon_t icon = 0; + IconModifier::icon_t icon = 0; ConditionScript trigger { scope_t::PROVINCE, scope_t::NO_SCOPE, scope_t::NO_SCOPE }; bool default_active = false; bool ret = modifier_manager.expect_modifier_value_and_keys( @@ -39,14 +41,18 @@ bool CrimeManager::load_crime_modifiers(ModifierManager const& modifier_manager, return ret; } )(root); + lock_crime_modifiers(); + return ret; } bool CrimeManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; + for (Crime& crime : crime_modifiers.get_items()) { ret &= crime.parse_scripts(definition_manager); } + return ret; } -- cgit v1.2.3-56-ga3b1