From 3c25d035484eada675d9d0243a66d1b3e6b97808 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 21 Sep 2024 23:56:01 +0100 Subject: Cache static modifiers in dedicated variables --- src/openvic-simulation/modifier/Modifier.hpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/openvic-simulation/modifier/Modifier.hpp') 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; 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 IDENTIFIER_REGISTRY(static_modifier); IdentifierRegistry 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, -- cgit v1.2.3-56-ga3b1