aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/misc/Modifier.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-01-13 21:14:06 +0100
committer hop311 <hop3114@gmail.com>2024-01-13 21:48:08 +0100
commit70948572ef0fb5c6dae453c410fdaedfab36741b (patch)
tree8e2f7f4de34ec3d62e55f9918ce26900c16a5d0f /src/openvic-simulation/misc/Modifier.hpp
parent046e5619277c6f3dffbb29244b4b88029da31bee (diff)
Reworked UniqueKeyRegistry template params + added support for std::deque storage
Diffstat (limited to 'src/openvic-simulation/misc/Modifier.hpp')
-rw-r--r--src/openvic-simulation/misc/Modifier.hpp11
1 files changed, 4 insertions, 7 deletions
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<ModifierEffect> std::make_unique<ModifierEffect>(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<ModifierEffect> IDENTIFIER_REGISTRY(modifier_effect);
+ CaseInsensitiveIdentifierRegistry<ModifierEffect, RegistryStorageInfoDeque> IDENTIFIER_REGISTRY(modifier_effect);
case_insensitive_string_set_t complex_modifiers;
IdentifierRegistry<Modifier> IDENTIFIER_REGISTRY(event_modifier);