aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/history/CountryHistory.cpp36
-rw-r--r--src/openvic-simulation/history/CountryHistory.hpp9
2 files changed, 38 insertions, 7 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);
}
diff --git a/src/openvic-simulation/history/CountryHistory.hpp b/src/openvic-simulation/history/CountryHistory.hpp
index ed200bf..0ffab23 100644
--- a/src/openvic-simulation/history/CountryHistory.hpp
+++ b/src/openvic-simulation/history/CountryHistory.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <map>
+#include <unordered_map>
#include <vector>
#include "openvic-simulation/country/Country.hpp"
@@ -16,6 +17,8 @@
#include "openvic-simulation/pop/Religion.hpp"
#include "openvic-simulation/types/Colour.hpp"
#include "openvic-simulation/types/Date.hpp"
+#include "openvic-simulation/research/Invention.hpp"
+#include "openvic-simulation/research/Technology.hpp"
namespace OpenVic {
struct CountryHistoryMap;
@@ -40,8 +43,10 @@ namespace OpenVic {
std::optional<fixed_point_t> PROPERTY(prestige);
std::vector<Reform const*> PROPERTY(reforms);
std::optional<Deployment const*> PROPERTY(inital_oob);
- // TODO: technologies, tech schools, and inventions when PR#51 merged
- // TODO: starting foreign investment
+ std::optional<TechnologySchool const*> PROPERTY(tech_school);
+ std::map<Technology const*, bool> PROPERTY(technologies);
+ std::map<Invention const*, bool> PROPERTY(inventions);
+ fixed_point_map_t<Country const*> PROPERTY(foreign_investment);
CountryHistoryEntry(Country const& new_country, Date new_date);
};