aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/history')
-rw-r--r--src/openvic-simulation/history/CountryHistory.cpp44
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.cpp2
2 files changed, 33 insertions, 13 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(
diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp
index 9fd6060..088ec0a 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.cpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.cpp
@@ -221,7 +221,7 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man
bool ret = expect_dictionary_keys(
"actor", ONE_EXACTLY, game_manager.get_country_manager().expect_country_identifier(assign_variable_callback_pointer(actor)),
"receiver", ONE_EXACTLY, game_manager.get_country_manager().expect_country_identifier(assign_variable_callback_pointer(receiver)),
- "casus_belli", ONE_EXACTLY, game_manager.get_military_manager().get_wargoal_manager().expect_wargoal_type_identifier(assign_variable_callback_pointer(type)),
+ "casus_belli", ONE_EXACTLY, game_manager.get_military_manager().get_wargoal_type_manager().expect_wargoal_type_identifier(assign_variable_callback_pointer(type)),
"country", ZERO_OR_ONE, game_manager.get_country_manager().expect_country_identifier(assign_variable_callback_pointer(*third_party)),
"state_province_id", ZERO_OR_ONE, game_manager.get_map().expect_province_identifier(assign_variable_callback_pointer(*target))
)(value);