aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history/CountryHistory.cpp
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2023-12-09 15:18:43 +0100
committer zaaarf <me@zaaarf.foo>2023-12-09 15:18:43 +0100
commit5688655934d8851a09ebfbc1149fadf3a5bafdd0 (patch)
tree74ea31d31c9ea76f536a295ab5a899d5dc107963 /src/openvic-simulation/history/CountryHistory.cpp
parentabb0804b015d8444542af7a6c5db728c0fde4cfb (diff)
feat: loading techs, inventions and foreign investments in country history
Diffstat (limited to 'src/openvic-simulation/history/CountryHistory.cpp')
-rw-r--r--src/openvic-simulation/history/CountryHistory.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp
index d312261..b42149b 100644
--- a/src/openvic-simulation/history/CountryHistory.cpp
+++ b/src/openvic-simulation/history/CountryHistory.cpp
@@ -21,10 +21,13 @@ bool CountryHistoryMap::_load_history_entry(
PoliticsManager const& politics_manager = game_manager.get_politics_manager();
IssueManager const& issue_manager = politics_manager.get_issue_manager();
CultureManager const& culture_manager = game_manager.get_pop_manager().get_culture_manager();
+ CountryManager const& country_manager = game_manager.get_country_manager();
+ TechnologyManager const& technology_manager = game_manager.get_research_manager().get_technology_manager();
+ InventionManager const& invention_manager = game_manager.get_research_manager().get_invention_manager();
return expect_dictionary_keys_and_default(
- [this, &game_manager, &dataloader, &deployment_manager, &issue_manager, &entry](
- std::string_view key, ast::NodeCPtr value) -> bool {
+ [this, &game_manager, &dataloader, &deployment_manager, &issue_manager,
+ &technology_manager, &invention_manager, &country_manager, &entry](std::string_view key, ast::NodeCPtr value) -> bool {
ReformGroup const* reform_group = issue_manager.get_reform_group_by_identifier(key);
if (reform_group != nullptr) {
return issue_manager.expect_reform_identifier([&entry, reform_group](Reform const& reform) -> bool {
@@ -46,7 +49,28 @@ bool CountryHistoryMap::_load_history_entry(
return true;
})(value);
}
- // TODO: technologies & inventions
+
+ Technology const* technology = technology_manager.get_technology_by_identifier(key);
+ if (technology != nullptr) {
+ uint8_t flag = -1;
+ if (expect_uint(assign_variable_callback(flag))(value)) {
+ if (flag == 1) return entry.technologies.emplace(technology, true).second;
+ else if (flag == 0) return entry.technologies.emplace(technology, false).second;
+ else {
+ Logger::warning("Refusing to load country history technology with non-boolean value: ", key, ", ", flag);
+ return true;
+ }
+ } else return false;
+ }
+
+ 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;
+ }
+
return _load_history_sub_entry_callback(
game_manager, dataloader, deployment_manager, entry.get_date(), value, key, value, key_value_success_callback
);
@@ -93,8 +117,10 @@ bool CountryHistoryMap::_load_history_entry(
return ret;
}
),
- "schools", ZERO_OR_ONE, success_callback, // TODO: technology school
- "foreign_investment", ZERO_OR_ONE, success_callback // TODO: foreign investment
+ "schools", ZERO_OR_ONE, technology_manager.expect_technology_school_identifier(
+ assign_variable_callback_pointer(entry.tech_school)
+ ),
+ "foreign_investment", ZERO_OR_ONE, country_manager.expect_country_decimal_map(move_variable_callback(entry.foreign_investment))
)(root);
}