aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Crime.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-09-21 15:34:22 +0200
committer GitHub <noreply@github.com>2024-09-21 15:34:22 +0200
commit4b69a91a6db50f86efec503b56b07573c692df9f (patch)
tree68fca0f77f6b20f3e1fe98d32a5a79311cfd3edc /src/openvic-simulation/map/Crime.cpp
parent85da7fb84197d617d1b3cde6969bf7bcfbb93d1d (diff)
parente35ff8ed703b0b6a5496a21a29e0b274c6a36874 (diff)
Merge pull request #204 from OpenVicProject/fix-modifiers
Fix modifiers
Diffstat (limited to 'src/openvic-simulation/map/Crime.cpp')
-rw-r--r--src/openvic-simulation/map/Crime.cpp12
1 files changed, 9 insertions, 3 deletions
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;
}