aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier/Modifier.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-09-22 00:56:01 +0200
committer hop311 <hop3114@gmail.com>2024-10-05 21:33:04 +0200
commit3c25d035484eada675d9d0243a66d1b3e6b97808 (patch)
tree8124322cdd03cb54313ef27da86c699109e4430b /src/openvic-simulation/modifier/Modifier.hpp
parent2bfd651778bff970991f3bd320a78a4008959b4a (diff)
Cache static modifiers in dedicated variables
Diffstat (limited to 'src/openvic-simulation/modifier/Modifier.hpp')
-rw-r--r--src/openvic-simulation/modifier/Modifier.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/openvic-simulation/modifier/Modifier.hpp b/src/openvic-simulation/modifier/Modifier.hpp
index f290da5..aa41ce4 100644
--- a/src/openvic-simulation/modifier/Modifier.hpp
+++ b/src/openvic-simulation/modifier/Modifier.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "openvic-simulation/modifier/StaticModifierCache.hpp"
#include "openvic-simulation/scripts/ConditionScript.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
@@ -140,6 +141,8 @@ namespace OpenVic {
concept ModifierEffectValidator = std::predicate<Fn, ModifierEffect const&>;
struct ModifierManager {
+ friend struct StaticModifierCache;
+
/* Some ModifierEffects are generated mid-load, such as max/min count modifiers for each building, so
* we can't lock it until loading is over. This means we can't rely on locking for pointer stability,
* so instead we store the effects in a deque which doesn't invalidate pointers on insert.
@@ -152,6 +155,8 @@ namespace OpenVic {
IdentifierRegistry<Modifier> IDENTIFIER_REGISTRY(static_modifier);
IdentifierRegistry<TriggeredModifier> IDENTIFIER_REGISTRY(triggered_modifier);
+ StaticModifierCache PROPERTY(static_modifier_cache);
+
/* effect_validator takes in ModifierEffect const& */
NodeTools::key_value_callback_t _modifier_effect_callback(
ModifierValue& modifier, NodeTools::key_value_callback_t default_callback,