aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-07-17 00:57:50 +0200
committer hop311 <hop3114@gmail.com>2024-07-17 00:58:05 +0200
commitf83e869def6608f64606aead24ad1cfbb6f5c72a (patch)
treefae6a1086f3ae698c4fb3f18340c5ed5f580c889 /src/openvic-simulation/dataloader
parente8a3b33f13ebdf3a388b4996308b4db9763dc375 (diff)
Add IndexedMap and use in low key count, high value density casesindexed-map
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp5
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.hpp21
2 files changed, 25 insertions, 1 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index f42a518..4fbd86b 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -538,7 +538,10 @@ bool Dataloader::_load_history(DefinitionManager& definition_manager, bool unuse
}
return country_history_manager.load_country_history_file(
- definition_manager, *this, *country, parse_defines(file).get_file_node()
+ definition_manager, *this, *country,
+ definition_manager.get_politics_manager().get_ideology_manager().get_ideologies(),
+ definition_manager.get_politics_manager().get_government_type_manager().get_government_types(),
+ parse_defines(file).get_file_node()
);
}
);
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp
index b0bb723..e53e896 100644
--- a/src/openvic-simulation/dataloader/NodeTools.hpp
+++ b/src/openvic-simulation/dataloader/NodeTools.hpp
@@ -12,6 +12,7 @@
#include "openvic-simulation/types/Colour.hpp"
#include "openvic-simulation/types/Date.hpp"
#include "openvic-simulation/types/HasIdentifier.hpp"
+#include "openvic-simulation/types/IndexedMap.hpp"
#include "openvic-simulation/types/OrderedContainers.hpp"
#include "openvic-simulation/types/Vector.hpp"
#include "openvic-simulation/utility/Getters.hpp"
@@ -537,6 +538,26 @@ namespace OpenVic {
};
}
+ template<typename Key, typename Value>
+ Callback<Value> auto map_callback(
+ IndexedMap<Key, Value>& map, Key const* key, bool warn = false
+ ) {
+ return [&map, key, warn](Value value) -> bool {
+ if (key == nullptr) {
+ Logger::error("Null key in map_callback");
+ return false;
+ }
+ Value& map_value = map[*key];
+ bool ret = true;
+ if (map_value != Value {}) {
+ Logger::warn_or_error(warn, "Duplicate map entry with key: \"", key, "\"");
+ ret = warn;
+ }
+ map_value = std::move(value);
+ return ret;
+ };
+ }
+
/* Often used for rotations which must be negated due to OpenVic's coordinate system being orientated
* oppositely to Vic2's. */
template<typename T = fixed_point_t>