aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history/CountryHistory.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-01-02 15:40:00 +0100
committer GitHub <noreply@github.com>2024-01-02 15:40:00 +0100
commit4c8da86c3bede8834f381fa63edaa3e140131f69 (patch)
treeff3433a63e91b9239eb7226e75054314182d6c1f /src/openvic-simulation/history/CountryHistory.cpp
parent66b80459c9d49895de902432bce11176b1270878 (diff)
parent5f64f983d0cead266a28791be42162c443fd2a75 (diff)
Merge pull request #112 from OpenVicProject/script-framework
Added framework for loading all Conditions and Effects
Diffstat (limited to 'src/openvic-simulation/history/CountryHistory.cpp')
-rw-r--r--src/openvic-simulation/history/CountryHistory.cpp44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp
index 48b30e6..681b2b9 100644
--- a/src/openvic-simulation/history/CountryHistory.cpp
+++ b/src/openvic-simulation/history/CountryHistory.cpp
@@ -52,20 +52,40 @@ bool CountryHistoryMap::_load_history_entry(
})(value);
}
- Technology const* technology = technology_manager.get_technology_by_identifier(key);
- if (technology != nullptr) {
- bool flag;
- if (expect_int_bool(assign_variable_callback(flag))(value)) {
- return entry.technologies.emplace(technology, flag).second;
- } else return false;
+ {
+ Technology const* technology = technology_manager.get_technology_by_identifier(key);
+ if (technology != nullptr) {
+ return expect_int_bool(
+ [&entry, technology](bool flag) -> bool {
+ if (!entry.technologies.emplace(technology, flag).second) {
+ Logger::error(
+ "Duplicate entry for technology ", technology->get_identifier(), " in history of ",
+ entry.get_country().get_identifier(), " at date ", entry.get_date()
+ );
+ return false;
+ }
+ return true;
+ }
+ )(value);
+ }
}
- Invention const* invention = invention_manager.get_invention_by_identifier(key);
- if (invention != nullptr) {
- bool flag;
- if (expect_bool(assign_variable_callback(flag))(value)) {
- return entry.inventions.emplace(invention, flag).second;
- } else return false;
+ {
+ Invention const* invention = invention_manager.get_invention_by_identifier(key);
+ if (invention != nullptr) {
+ return expect_bool(
+ [&entry, invention](bool flag) -> bool {
+ if (!entry.inventions.emplace(invention, flag).second) {
+ Logger::error(
+ "Duplicate entry for invention ", invention->get_identifier(), " in history of ",
+ entry.get_country().get_identifier(), " at date ", entry.get_date()
+ );
+ return false;
+ }
+ return true;
+ }
+ )(value);
+ }
}
return _load_history_sub_entry_callback(