From 70948572ef0fb5c6dae453c410fdaedfab36741b Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 13 Jan 2024 20:14:06 +0000 Subject: Reworked UniqueKeyRegistry template params + added support for std::deque storage --- src/openvic-simulation/misc/Modifier.hpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/openvic-simulation/misc/Modifier.hpp') diff --git a/src/openvic-simulation/misc/Modifier.hpp b/src/openvic-simulation/misc/Modifier.hpp index 83efe9b..abb3891 100644 --- a/src/openvic-simulation/misc/Modifier.hpp +++ b/src/openvic-simulation/misc/Modifier.hpp @@ -3,13 +3,12 @@ #include "openvic-simulation/scripts/ConditionScript.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" -#include "dataloader/NodeTools.hpp" - - namespace OpenVic { struct ModifierManager; struct ModifierEffect : HasIdentifier { + friend struct ModifierManager; + enum class format_t { PROPORTION_DECIMAL, /* An unscaled fraction/ratio, with 1 being "full"/"whole" */ PERCENTAGE_DECIMAL, /* A fraction/ratio scaled so that 100 is "full"/"whole" */ @@ -17,8 +16,6 @@ namespace OpenVic { INT /* A discrete quantity, e.g. building count limit */ }; - friend std::unique_ptr std::make_unique(std::string_view&&, bool&&, format_t&&); - private: /* If true, positive values will be green and negative values will be red. * If false, the colours will be switced. @@ -115,10 +112,10 @@ namespace OpenVic { struct ModifierManager { /* 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 use an IdentifierInstanceRegistry (using std::unique_ptr's under the hood). + * so instead we store the effects in a deque which doesn't invalidate pointers on insert. */ private: - CaseInsensitiveIdentifierInstanceRegistry IDENTIFIER_REGISTRY(modifier_effect); + CaseInsensitiveIdentifierRegistry IDENTIFIER_REGISTRY(modifier_effect); case_insensitive_string_set_t complex_modifiers; IdentifierRegistry IDENTIFIER_REGISTRY(event_modifier); -- cgit v1.2.3-56-ga3b1