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/Bookmark.cpp7
-rw-r--r--src/openvic-simulation/history/CountryHistory.cpp5
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.cpp28
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.hpp4
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.cpp22
5 files changed, 27 insertions, 39 deletions
diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp
index 483b49b..e9543be 100644
--- a/src/openvic-simulation/history/Bookmark.cpp
+++ b/src/openvic-simulation/history/Bookmark.cpp
@@ -3,10 +3,9 @@
#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp>
#include "openvic-simulation/dataloader/NodeTools.hpp"
-
-#include "types/Date.hpp"
-#include "types/IdentifierRegistry.hpp"
-#include "utility/Logger.hpp"
+#include "openvic-simulation/types/Date.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
+#include "openvic-simulation/utility/Logger.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp
index 04a5e09..d312261 100644
--- a/src/openvic-simulation/history/CountryHistory.cpp
+++ b/src/openvic-simulation/history/CountryHistory.cpp
@@ -59,10 +59,7 @@ bool CountryHistoryMap::_load_history_entry(
"primary_culture", ZERO_OR_ONE,
culture_manager.expect_culture_identifier(assign_variable_callback_pointer(entry.primary_culture)),
"culture", ZERO_OR_MORE, culture_manager.expect_culture_identifier(
- [&entry](Culture const& culture) -> bool {
- entry.accepted_cultures.push_back(&culture);
- return true;
- }
+ vector_callback_pointer(entry.accepted_cultures)
),
"religion", ZERO_OR_ONE, game_manager.get_pop_manager().get_religion_manager().expect_religion_identifier(
assign_variable_callback_pointer(entry.religion)
diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp
index 79ac907..ce55001 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.cpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.cpp
@@ -79,16 +79,16 @@ std::vector<WarHistory const*> DiplomaticHistoryManager::get_wars(Date date) con
return ret;
}
-bool DiplomaticHistoryManager::load_diplomacy_history_file(GameManager& game_manager, ast::NodeCPtr root) {
+bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& country_manager, ast::NodeCPtr root) {
return expect_dictionary_keys(
- "alliance", ZERO_OR_MORE, [this, &game_manager](ast::NodeCPtr node) -> bool {
+ "alliance", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
Country const* first;
Country const* second;
Date start, end;
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY, expect_identifier_or_string(game_manager.get_country_manager().expect_country_str(assign_variable_callback_pointer(first))),
- "second", ONE_EXACTLY, expect_identifier_or_string(game_manager.get_country_manager().expect_country_str(assign_variable_callback_pointer(second))),
+ "first", ONE_EXACTLY, expect_identifier_or_string(country_manager.expect_country_str(assign_variable_callback_pointer(first))),
+ "second", ONE_EXACTLY, expect_identifier_or_string(country_manager.expect_country_str(assign_variable_callback_pointer(second))),
"start_date", ONE_EXACTLY, expect_identifier_or_string(expect_date_str(assign_variable_callback(start))),
"end_date", ONE_EXACTLY, expect_identifier_or_string(expect_date_str(assign_variable_callback(end)))
)(node);
@@ -96,14 +96,14 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(GameManager& game_man
alliances.push_back({ first, second, start, end });
return ret;
},
- "vassal", ZERO_OR_MORE, [this, &game_manager](ast::NodeCPtr node) -> bool {
+ "vassal", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
Country const* overlord;
Country const* subject;
Date start, end;
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY, expect_identifier_or_string(game_manager.get_country_manager().expect_country_str(assign_variable_callback_pointer(overlord))),
- "second", ONE_EXACTLY, expect_identifier_or_string(game_manager.get_country_manager().expect_country_str(assign_variable_callback_pointer(subject))),
+ "first", ONE_EXACTLY, expect_identifier_or_string(country_manager.expect_country_str(assign_variable_callback_pointer(overlord))),
+ "second", ONE_EXACTLY, expect_identifier_or_string(country_manager.expect_country_str(assign_variable_callback_pointer(subject))),
"start_date", ONE_EXACTLY, expect_identifier_or_string(expect_date_str(assign_variable_callback(start))),
"end_date", ONE_EXACTLY, expect_identifier_or_string(expect_date_str(assign_variable_callback(end)))
)(node);
@@ -111,14 +111,14 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(GameManager& game_man
subjects.push_back({ overlord, subject, SubjectHistory::type_t::VASSAL, start, end });
return ret;
},
- "union", ZERO_OR_MORE, [this, &game_manager](ast::NodeCPtr node) -> bool {
+ "union", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
Country const* overlord;
Country const* subject;
Date start, end;
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY, game_manager.get_country_manager().expect_country_identifier(assign_variable_callback_pointer(overlord)),
- "second", ONE_EXACTLY, game_manager.get_country_manager().expect_country_identifier(assign_variable_callback_pointer(subject)),
+ "first", ONE_EXACTLY, country_manager.expect_country_identifier(assign_variable_callback_pointer(overlord)),
+ "second", ONE_EXACTLY, country_manager.expect_country_identifier(assign_variable_callback_pointer(subject)),
"start_date", ONE_EXACTLY, expect_date(assign_variable_callback(start)),
"end_date", ONE_EXACTLY, expect_date(assign_variable_callback(end))
)(node);
@@ -126,14 +126,14 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(GameManager& game_man
subjects.push_back({ overlord, subject, SubjectHistory::type_t::UNION, start, end });
return ret;
},
- "substate", ZERO_OR_MORE, [this, &game_manager](ast::NodeCPtr node) -> bool {
+ "substate", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
Country const* overlord;
Country const* subject;
Date start, end;
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY, game_manager.get_country_manager().expect_country_identifier(assign_variable_callback_pointer(overlord)),
- "second", ONE_EXACTLY, game_manager.get_country_manager().expect_country_identifier(assign_variable_callback_pointer(subject)),
+ "first", ONE_EXACTLY, country_manager.expect_country_identifier(assign_variable_callback_pointer(overlord)),
+ "second", ONE_EXACTLY, country_manager.expect_country_identifier(assign_variable_callback_pointer(subject)),
"start_date", ONE_EXACTLY, expect_date(assign_variable_callback(start)),
"end_date", ONE_EXACTLY, expect_date(assign_variable_callback(end))
)(node);
@@ -144,7 +144,7 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(GameManager& game_man
)(root);
}
-bool DiplomaticHistoryManager::load_war_history_file(GameManager& game_manager, ast::NodeCPtr root) {
+bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_manager, ast::NodeCPtr root) {
std::string name = "";
std::vector<WarHistory::war_participant_t> attackers;
std::vector<WarHistory::war_participant_t> defenders;
diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp
index 4d620b5..3e877eb 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.hpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.hpp
@@ -98,7 +98,7 @@ namespace OpenVic {
/* Returns all wars that begin before date. NOTE: Some wargoals may be added or countries may join after date, should be checked for by functions that use get_wars() */
std::vector<WarHistory const*> get_wars(Date date) const;
- bool load_diplomacy_history_file(GameManager& game_manager, ast::NodeCPtr root);
- bool load_war_history_file(GameManager& game_manager, ast::NodeCPtr root);
+ bool load_diplomacy_history_file(CountryManager const& country_manager, ast::NodeCPtr root);
+ bool load_war_history_file(GameManager const& game_manager, ast::NodeCPtr root);
};
} // namespace OpenVic \ No newline at end of file
diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp
index 991dfee..d9d3ef6 100644
--- a/src/openvic-simulation/history/ProvinceHistory.cpp
+++ b/src/openvic-simulation/history/ProvinceHistory.cpp
@@ -18,7 +18,7 @@ std::unique_ptr<ProvinceHistoryEntry> ProvinceHistoryMap::_make_entry(Date date)
bool ProvinceHistoryMap::_load_history_entry(
GameManager const& game_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root
) {
- BuildingManager const& building_manager = game_manager.get_economy_manager().get_building_manager();
+ BuildingTypeManager const& building_type_manager = game_manager.get_economy_manager().get_building_type_manager();
CountryManager const& country_manager = game_manager.get_country_manager();
GoodManager const& good_manager = game_manager.get_economy_manager().get_good_manager();
IdeologyManager const& ideology_manager = game_manager.get_politics_manager().get_ideology_manager();
@@ -30,10 +30,10 @@ bool ProvinceHistoryMap::_load_history_entry(
};
return expect_dictionary_keys_and_default(
- [this, &game_manager, &building_manager, &entry](
+ [this, &game_manager, &building_type_manager, &entry](
std::string_view key, ast::NodeCPtr value) -> bool {
// used for province buildings like forts or railroads
- BuildingType const* building_type = building_manager.get_building_type_by_identifier(key);
+ BuildingType const* building_type = building_type_manager.get_building_type_by_identifier(key);
if (building_type != nullptr) {
return expect_uint<BuildingType::level_t>([&entry, building_type](BuildingType::level_t level) -> bool {
entry.province_buildings[building_type] = level;
@@ -47,17 +47,9 @@ bool ProvinceHistoryMap::_load_history_entry(
country_manager.expect_country_identifier(assign_variable_callback_pointer(entry.owner)),
"controller", ZERO_OR_ONE,
country_manager.expect_country_identifier(assign_variable_callback_pointer(entry.controller)),
- "add_core", ZERO_OR_MORE, country_manager.expect_country_identifier(
- [&entry](Country const& core) -> bool {
- entry.add_cores.push_back(&core);
- return true;
- }
- ),
+ "add_core", ZERO_OR_MORE, country_manager.expect_country_identifier(vector_callback_pointer(entry.add_cores)),
"remove_core", ZERO_OR_MORE, country_manager.expect_country_identifier(
- [&entry](Country const& core) -> bool {
- entry.remove_cores.push_back(&core);
- return true;
- }
+ vector_callback_pointer(entry.remove_cores)
),
"colonial", ZERO_OR_ONE,
expect_identifier(expect_mapped_string(colony_status_map, assign_variable_callback(entry.colonial))),
@@ -82,13 +74,13 @@ bool ProvinceHistoryMap::_load_history_entry(
entry.party_loyalties[ideology] = amount;
return ret;
},
- "state_building", ZERO_OR_MORE, [&building_manager, &entry](ast::NodeCPtr node) -> bool {
+ "state_building", ZERO_OR_MORE, [&building_type_manager, &entry](ast::NodeCPtr node) -> bool {
BuildingType const* building_type = nullptr;
uint8_t level = 0;
const bool ret = expect_dictionary_keys(
"level", ONE_EXACTLY, expect_uint(assign_variable_callback(level)),
- "building", ONE_EXACTLY, building_manager.expect_building_type_identifier(
+ "building", ONE_EXACTLY, building_type_manager.expect_building_type_identifier(
assign_variable_callback_pointer(building_type)
),
"upgrade", ZERO_OR_ONE, success_callback // doesn't appear to have an effect