aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-06-15 00:06:19 +0200
committer hop311 <hop3114@gmail.com>2024-06-20 20:33:02 +0200
commit41d50b15ac978530a53ed99eea36f180e1d27b16 (patch)
tree236036a544c54d678fc79344677566c3b060d335 /src/openvic-simulation
parentbfd539513af435564daf70f94f6cce146dd5c948 (diff)
Renamed Country to CountryDefinitioncountry-definition
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/DefinitionManager.hpp4
-rw-r--r--src/openvic-simulation/InstanceManager.cpp4
-rw-r--r--src/openvic-simulation/country/CountryDefinition.cpp (renamed from src/openvic-simulation/country/Country.cpp)32
-rw-r--r--src/openvic-simulation/country/CountryDefinition.hpp (renamed from src/openvic-simulation/country/Country.hpp)20
-rw-r--r--src/openvic-simulation/country/CountryInstance.cpp43
-rw-r--r--src/openvic-simulation/country/CountryInstance.hpp14
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp11
-rw-r--r--src/openvic-simulation/diplomacy/CountryRelation.cpp4
-rw-r--r--src/openvic-simulation/history/CountryHistory.cpp15
-rw-r--r--src/openvic-simulation/history/CountryHistory.hpp21
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.cpp270
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.hpp41
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.cpp18
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.hpp10
-rw-r--r--src/openvic-simulation/map/MapInstance.cpp2
-rw-r--r--src/openvic-simulation/map/MapInstance.hpp4
-rw-r--r--src/openvic-simulation/map/Mapmode.cpp2
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp8
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp13
-rw-r--r--src/openvic-simulation/map/State.cpp5
-rw-r--r--src/openvic-simulation/map/State.hpp6
-rw-r--r--src/openvic-simulation/pop/Culture.cpp38
-rw-r--r--src/openvic-simulation/pop/Culture.hpp25
-rw-r--r--src/openvic-simulation/pop/Pop.cpp4
-rw-r--r--src/openvic-simulation/pop/Pop.hpp2
-rw-r--r--src/openvic-simulation/scripts/Condition.cpp10
-rw-r--r--src/openvic-simulation/types/IdentifierRegistry.hpp32
27 files changed, 355 insertions, 303 deletions
diff --git a/src/openvic-simulation/DefinitionManager.hpp b/src/openvic-simulation/DefinitionManager.hpp
index e2e28dc..9b5bf21 100644
--- a/src/openvic-simulation/DefinitionManager.hpp
+++ b/src/openvic-simulation/DefinitionManager.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/diplomacy/DiplomaticAction.hpp"
#include "openvic-simulation/economy/EconomyManager.hpp"
#include "openvic-simulation/history/HistoryManager.hpp"
@@ -29,7 +29,7 @@ namespace OpenVic {
HistoryManager PROPERTY_REF(history_manager);
ResearchManager PROPERTY_REF(research_manager);
PopManager PROPERTY_REF(pop_manager);
- CountryManager PROPERTY_REF(country_manager);
+ CountryDefinitionManager PROPERTY_REF(country_definition_manager);
CrimeManager PROPERTY_REF(crime_manager);
EventManager PROPERTY_REF(event_manager);
DecisionManager PROPERTY_REF(decision_manager);
diff --git a/src/openvic-simulation/InstanceManager.cpp b/src/openvic-simulation/InstanceManager.cpp
index 659931c..7ee5fb8 100644
--- a/src/openvic-simulation/InstanceManager.cpp
+++ b/src/openvic-simulation/InstanceManager.cpp
@@ -98,11 +98,11 @@ bool InstanceManager::load_bookmark(Bookmark const* new_bookmark) {
// TODO - the following arguments are for generating test pop attributes
definition_manager.get_politics_manager().get_ideology_manager(),
definition_manager.get_politics_manager().get_issue_manager(),
- *definition_manager.get_country_manager().get_country_by_identifier("ENG")
+ *definition_manager.get_country_definition_manager().get_country_definition_by_identifier("ENG")
);
ret &= map_instance.get_state_manager().generate_states(map_instance);
- ret &= country_instance_manager.generate_country_instances(definition_manager.get_country_manager());
+ ret &= country_instance_manager.generate_country_instances(definition_manager.get_country_definition_manager());
ret &= country_instance_manager.apply_history_to_countries(
definition_manager.get_history_manager().get_country_manager(), today, unit_instance_manager, map_instance
);
diff --git a/src/openvic-simulation/country/Country.cpp b/src/openvic-simulation/country/CountryDefinition.cpp
index d21df89..e414e9e 100644
--- a/src/openvic-simulation/country/Country.cpp
+++ b/src/openvic-simulation/country/CountryDefinition.cpp
@@ -1,4 +1,4 @@
-#include "Country.hpp"
+#include "CountryDefinition.hpp"
#include <string_view>
@@ -22,7 +22,7 @@ CountryParty::CountryParty(
) : HasIdentifierAndColour { new_identifier, new_ideology.get_colour(), false }, start_date { new_start_date },
end_date { new_end_date }, ideology { new_ideology }, policies { std::move(new_policies) } {}
-Country::Country(
+CountryDefinition::CountryDefinition(
std::string_view new_identifier,
colour_t new_colour,
size_t new_index,
@@ -45,10 +45,10 @@ Country::Country(
secondary_unit_colour { new_secondary_unit_colour },
tertiary_unit_colour { new_tertiary_unit_colour } {}
-bool CountryManager::add_country(
+bool CountryDefinitionManager::add_country(
std::string_view identifier, colour_t colour, GraphicalCultureType const* graphical_culture,
- IdentifierRegistry<CountryParty>&& parties, Country::unit_names_map_t&& unit_names, bool dynamic_tag,
- Country::government_colour_map_t&& alternative_colours
+ IdentifierRegistry<CountryParty>&& parties, CountryDefinition::unit_names_map_t&& unit_names, bool dynamic_tag,
+ CountryDefinition::government_colour_map_t&& alternative_colours
) {
if (identifier.empty()) {
Logger::error("Invalid country identifier - empty!");
@@ -67,22 +67,22 @@ bool CountryManager::add_country(
static constexpr colour_t default_colour = colour_t::fill_as(colour_t::max_value);
- return countries.add_item({
- identifier, colour, countries.size(), *graphical_culture, std::move(parties), std::move(unit_names),
+ return country_definitions.add_item({
+ identifier, colour, get_country_definition_count(), *graphical_culture, std::move(parties), std::move(unit_names),
dynamic_tag, std::move(alternative_colours),
/* Default to country colour for the chest and grey for the others. Update later if necessary. */
colour, default_colour, default_colour
});
}
-bool CountryManager::load_countries(
+bool CountryDefinitionManager::load_countries(
DefinitionManager const& definition_manager, Dataloader const& dataloader, ast::NodeCPtr root
) {
static constexpr std::string_view common_dir = "common/";
bool is_dynamic = false;
const bool ret = expect_dictionary_reserve_length(
- countries,
+ country_definitions,
[this, &definition_manager, &is_dynamic, &dataloader](std::string_view key, ast::NodeCPtr value) -> bool {
if (key == "dynamic_tags") {
return expect_bool([&is_dynamic](bool val) -> bool {
@@ -117,12 +117,12 @@ bool CountryManager::load_countries(
return false;
}
)(root);
- lock_countries();
+ lock_country_definitions();
return ret;
}
-bool CountryManager::load_country_colours(ast::NodeCPtr root){
- return countries.expect_item_dictionary([](Country& country, ast::NodeCPtr colour_node) -> bool {
+bool CountryDefinitionManager::load_country_colours(ast::NodeCPtr root){
+ return country_definitions.expect_item_dictionary([](CountryDefinition& country, ast::NodeCPtr colour_node) -> bool {
return expect_dictionary_keys(
"color1", ONE_EXACTLY, expect_colour(assign_variable_callback(country.primary_unit_colour)),
"color2", ONE_EXACTLY, expect_colour(assign_variable_callback(country.secondary_unit_colour)),
@@ -131,7 +131,7 @@ bool CountryManager::load_country_colours(ast::NodeCPtr root){
})(root);
}
-node_callback_t CountryManager::load_country_party(
+node_callback_t CountryDefinitionManager::load_country_party(
PoliticsManager const& politics_manager, IdentifierRegistry<CountryParty>& country_parties
) const {
return [&politics_manager, &country_parties](ast::NodeCPtr value) -> bool {
@@ -177,14 +177,14 @@ node_callback_t CountryManager::load_country_party(
};
}
-bool CountryManager::load_country_data_file(
+bool CountryDefinitionManager::load_country_data_file(
DefinitionManager const& definition_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root
) {
colour_t colour;
GraphicalCultureType const* graphical_culture;
IdentifierRegistry<CountryParty> parties { "country parties" };
- Country::unit_names_map_t unit_names;
- Country::government_colour_map_t alternative_colours;
+ CountryDefinition::unit_names_map_t unit_names;
+ CountryDefinition::government_colour_map_t alternative_colours;
bool ret = expect_dictionary_keys_and_default(
[&definition_manager, &alternative_colours](std::string_view key, ast::NodeCPtr value) -> bool {
return definition_manager.get_politics_manager().get_government_type_manager().expect_government_type_str(
diff --git a/src/openvic-simulation/country/Country.hpp b/src/openvic-simulation/country/CountryDefinition.hpp
index 001f1ff..70e62b9 100644
--- a/src/openvic-simulation/country/Country.hpp
+++ b/src/openvic-simulation/country/CountryDefinition.hpp
@@ -18,10 +18,10 @@
namespace OpenVic {
struct DefinitionManager;
- struct CountryManager;
+ struct CountryDefinitionManager;
struct CountryParty : HasIdentifierAndColour {
- friend struct CountryManager;
+ friend struct CountryDefinitionManager;
using policy_map_t = ordered_map<IssueGroup const*, Issue const*>;
@@ -41,8 +41,8 @@ namespace OpenVic {
};
/* Generic information about a TAG */
- struct Country : HasIdentifierAndColour {
- friend struct CountryManager;
+ struct CountryDefinition : HasIdentifierAndColour {
+ friend struct CountryDefinitionManager;
using unit_names_map_t = ordered_map<UnitType const*, name_list_t>;
using government_colour_map_t = ordered_map<GovernmentType const*, colour_t>;
@@ -61,7 +61,7 @@ namespace OpenVic {
colour_t PROPERTY(tertiary_unit_colour);
// Unit colours not const due to being added after construction
- Country(
+ CountryDefinition(
std::string_view new_identifier, colour_t new_colour, size_t new_index,
GraphicalCultureType const& new_graphical_culture, IdentifierRegistry<CountryParty>&& new_parties,
unit_names_map_t&& new_unit_names, bool new_dynamic_tag, government_colour_map_t&& new_alternative_colours,
@@ -69,14 +69,14 @@ namespace OpenVic {
);
public:
- Country(Country&&) = default;
+ CountryDefinition(CountryDefinition&&) = default;
// TODO - get_colour including alternative colours
};
- struct CountryManager {
+ struct CountryDefinitionManager {
private:
- IdentifierRegistry<Country> IDENTIFIER_REGISTRY_CUSTOM_PLURAL(country, countries);
+ IdentifierRegistry<CountryDefinition> IDENTIFIER_REGISTRY(country_definition);
NodeTools::node_callback_t load_country_party(
PoliticsManager const& politics_manager, IdentifierRegistry<CountryParty>& country_parties
@@ -85,8 +85,8 @@ namespace OpenVic {
public:
bool add_country(
std::string_view identifier, colour_t colour, GraphicalCultureType const* graphical_culture,
- IdentifierRegistry<CountryParty>&& parties, Country::unit_names_map_t&& unit_names, bool dynamic_tag,
- Country::government_colour_map_t&& alternative_colours
+ IdentifierRegistry<CountryParty>&& parties, CountryDefinition::unit_names_map_t&& unit_names, bool dynamic_tag,
+ CountryDefinition::government_colour_map_t&& alternative_colours
);
bool load_country_colours(ast::NodeCPtr root);
diff --git a/src/openvic-simulation/country/CountryInstance.cpp b/src/openvic-simulation/country/CountryInstance.cpp
index 25f40ed..2debd8a 100644
--- a/src/openvic-simulation/country/CountryInstance.cpp
+++ b/src/openvic-simulation/country/CountryInstance.cpp
@@ -1,23 +1,26 @@
#include "CountryInstance.hpp"
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/history/CountryHistory.hpp"
#include "openvic-simulation/military/UnitInstance.hpp"
using namespace OpenVic;
-CountryInstance::CountryInstance(Country const* new_base_country)
- : base_country { new_base_country }, primary_culture { nullptr }, religion { nullptr }, ruling_party { nullptr },
+CountryInstance::CountryInstance(CountryDefinition const* new_country_definition)
+ : country_definition { new_country_definition }, primary_culture { nullptr }, religion { nullptr }, ruling_party { nullptr },
last_election {}, capital { nullptr }, government_type { nullptr }, plurality { 0 }, national_value { nullptr },
civilised { false }, prestige { 0 } {}
std::string_view CountryInstance::get_identifier() const {
- return base_country != nullptr ? base_country->get_identifier() : "NULL";
+ return country_definition != nullptr ? country_definition->get_identifier() : "NULL";
}
bool CountryInstance::add_accepted_culture(Culture const* new_accepted_culture) {
if (std::find(accepted_cultures.begin(), accepted_cultures.end(), new_accepted_culture) != accepted_cultures.end()) {
- Logger::warning("Attempted to add accepted culture ", new_accepted_culture->get_identifier(), " to country ", base_country->get_identifier(), ": already present!");
+ Logger::warning(
+ "Attempted to add accepted culture ", new_accepted_culture->get_identifier(), " to country ",
+ country_definition->get_identifier(), ": already present!"
+ );
return false;
}
accepted_cultures.push_back(new_accepted_culture);
@@ -27,7 +30,10 @@ bool CountryInstance::add_accepted_culture(Culture const* new_accepted_culture)
bool CountryInstance::remove_accepted_culture(Culture const* culture_to_remove) {
auto existing_entry = std::find(accepted_cultures.begin(), accepted_cultures.end(), culture_to_remove);
if (existing_entry == accepted_cultures.end()) {
- Logger::warning("Attempted to remove accepted culture ", culture_to_remove->get_identifier(), " from country ", base_country->get_identifier(), ": not present!");
+ Logger::warning(
+ "Attempted to remove accepted culture ", culture_to_remove->get_identifier(), " from country ",
+ country_definition->get_identifier(), ": not present!"
+ );
return false;
}
accepted_cultures.erase(existing_entry);
@@ -44,7 +50,10 @@ bool CountryInstance::remove_from_upper_house(Ideology const* party) {
bool CountryInstance::add_reform(Reform const* new_reform) {
if (std::find(reforms.begin(), reforms.end(), new_reform) != reforms.end()) {
- Logger::warning("Attempted to add reform ", new_reform->get_identifier(), " to country ", base_country->get_identifier(), ": already present!");
+ Logger::warning(
+ "Attempted to add reform ", new_reform->get_identifier(), " to country ", country_definition->get_identifier(),
+ ": already present!"
+ );
return false;
}
reforms.push_back(new_reform);
@@ -54,7 +63,10 @@ bool CountryInstance::add_reform(Reform const* new_reform) {
bool CountryInstance::remove_reform(Reform const* reform_to_remove) {
auto existing_entry = std::find(reforms.begin(), reforms.end(), reform_to_remove);
if (existing_entry == reforms.end()) {
- Logger::warning("Attempted to remove reform ", reform_to_remove->get_identifier(), " from country ", base_country->get_identifier(), ": not present!");
+ Logger::warning(
+ "Attempted to remove reform ", reform_to_remove->get_identifier(), " from country ",
+ country_definition->get_identifier(), ": not present!"
+ );
return false;
}
reforms.erase(existing_entry);
@@ -98,11 +110,11 @@ bool CountryInstance::apply_history_to_country(CountryHistoryEntry const* entry)
return ret;
}
-bool CountryInstanceManager::generate_country_instances(CountryManager const& country_manager) {
- reserve_more(country_instances, country_manager.get_country_count());
+bool CountryInstanceManager::generate_country_instances(CountryDefinitionManager const& country_definition_manager) {
+ reserve_more(country_instances, country_definition_manager.get_country_definition_count());
- for (Country const& country : country_manager.get_countries()) {
- country_instances.push_back({ &country });
+ for (CountryDefinition const& country_definition : country_definition_manager.get_country_definitions()) {
+ country_instances.add_item({ &country_definition });
}
return true;
@@ -114,9 +126,10 @@ bool CountryInstanceManager::apply_history_to_countries(
) {
bool ret = true;
- for (CountryInstance& country_instance : country_instances) {
- if (!country_instance.get_base_country()->is_dynamic_tag()) {
- CountryHistoryMap const* history_map = history_manager.get_country_history(country_instance.get_base_country());
+ for (CountryInstance& country_instance : country_instances.get_items()) {
+ if (!country_instance.get_country_definition()->is_dynamic_tag()) {
+ CountryHistoryMap const* history_map =
+ history_manager.get_country_history(country_instance.get_country_definition());
if (history_map != nullptr) {
CountryHistoryEntry const* oob_history_entry = nullptr;
diff --git a/src/openvic-simulation/country/CountryInstance.hpp b/src/openvic-simulation/country/CountryInstance.hpp
index 68d2bb2..45924b2 100644
--- a/src/openvic-simulation/country/CountryInstance.hpp
+++ b/src/openvic-simulation/country/CountryInstance.hpp
@@ -4,10 +4,11 @@
#include "openvic-simulation/types/Date.hpp"
#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
#include "openvic-simulation/utility/Getters.hpp"
namespace OpenVic {
- struct Country;
+ struct CountryDefinition;
struct Culture;
struct Religion;
struct CountryParty;
@@ -21,8 +22,9 @@ namespace OpenVic {
/* Representation of an existing country that is currently in-game. */
struct CountryInstance {
friend struct CountryInstanceManager;
+
private:
- Country const* PROPERTY_RW(base_country);
+ CountryDefinition const* PROPERTY_RW(country_definition);
Culture const* PROPERTY_RW(primary_culture);
std::vector<Culture const*> PROPERTY(accepted_cultures);
Religion const* PROPERTY_RW(religion);
@@ -40,7 +42,7 @@ namespace OpenVic {
std::vector<Reform const*> PROPERTY(reforms); // TODO: should be map of reform groups to active reforms: must set defaults & validate applied history
// TODO: Military units + OOBs; will probably need an extensible deployment class
- CountryInstance(Country const* new_base_country);
+ CountryInstance(CountryDefinition const* new_country_definition);
public:
std::string_view get_identifier() const;
@@ -56,17 +58,17 @@ namespace OpenVic {
bool apply_history_to_country(CountryHistoryEntry const* entry);
};
- struct CountryManager;
+ struct CountryDefinitionManager;
struct CountryHistoryManager;
struct UnitInstanceManager;
struct MapInstance;
struct CountryInstanceManager {
private:
- std::vector<CountryInstance> PROPERTY(country_instances);
+ IdentifierRegistry<CountryInstance> IDENTIFIER_REGISTRY(country_instance);
public:
- bool generate_country_instances(CountryManager const& country_manager);
+ bool generate_country_instances(CountryDefinitionManager const& country_definition_manager);
bool apply_history_to_countries(
CountryHistoryManager const& history_manager, Date date, UnitInstanceManager& unit_instance_manager,
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index a927f5a..dab479f 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -528,7 +528,8 @@ bool Dataloader::_load_history(DefinitionManager& definition_manager, bool unuse
const std::string filename = file.stem().string();
const std::string_view country_id = extract_basic_identifier_prefix(filename);
- Country const* country = definition_manager.get_country_manager().get_country_by_identifier(country_id);
+ CountryDefinition const* country =
+ definition_manager.get_country_definition_manager().get_country_definition_by_identifier(country_id);
if (country == nullptr) {
if (unused_history_file_warnings) {
Logger::warning("Found history file for non-existent country: ", country_id);
@@ -628,7 +629,7 @@ bool Dataloader::_load_history(DefinitionManager& definition_manager, bool unuse
lookup_files_in_dir(diplomacy_history_directory, ".txt"),
[this, &definition_manager, &diplomatic_history_manager](fs::path const& file) -> bool {
return diplomatic_history_manager.load_diplomacy_history_file(
- definition_manager.get_country_manager(), parse_defines(file).get_file_node()
+ definition_manager.get_country_definition_manager(), parse_defines(file).get_file_node()
);
}
);
@@ -1008,20 +1009,20 @@ bool Dataloader::load_defines(DefinitionManager& definition_manager) {
Logger::error("Failed to load bookmarks!");
ret = false;
}
- if (!definition_manager.get_country_manager().load_countries(
+ if (!definition_manager.get_country_definition_manager().load_countries(
definition_manager, *this, parse_defines(lookup_file(countries_file)).get_file_node()
)) {
Logger::error("Failed to load countries!");
ret = false;
}
- if (!definition_manager.get_country_manager().load_country_colours(
+ if (!definition_manager.get_country_definition_manager().load_country_colours(
parse_defines(lookup_file(country_colours_file)).get_file_node()
)) {
Logger::error("Failed to load country colours!");
ret = false;
}
if (!definition_manager.get_pop_manager().get_culture_manager().load_culture_file(
- definition_manager.get_country_manager(), parse_defines(lookup_file(culture_file)).get_file_node()
+ definition_manager.get_country_definition_manager(), parse_defines(lookup_file(culture_file)).get_file_node()
)) {
Logger::error("Failed to load cultures!");
ret = false;
diff --git a/src/openvic-simulation/diplomacy/CountryRelation.cpp b/src/openvic-simulation/diplomacy/CountryRelation.cpp
index 2e058ab..0f97da1 100644
--- a/src/openvic-simulation/diplomacy/CountryRelation.cpp
+++ b/src/openvic-simulation/diplomacy/CountryRelation.cpp
@@ -2,7 +2,7 @@
#include <cassert>
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/country/CountryInstance.hpp"
#include "openvic-simulation/utility/ErrorMacros.hpp"
@@ -11,7 +11,7 @@ using namespace OpenVic;
CountryRelationInstanceProxy::CountryRelationInstanceProxy(std::string_view id) : country_id { id } {}
CountryRelationInstanceProxy::CountryRelationInstanceProxy(CountryInstance const* country)
- : country_id { country->get_base_country()->get_identifier() } {}
+ : country_id { country->get_country_definition()->get_identifier() } {}
CountryRelationInstanceProxy::operator std::string_view() const {
return country_id;
diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp
index b316353..5eba9ee 100644
--- a/src/openvic-simulation/history/CountryHistory.cpp
+++ b/src/openvic-simulation/history/CountryHistory.cpp
@@ -1,14 +1,15 @@
#include "CountryHistory.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/DefinitionManager.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-CountryHistoryEntry::CountryHistoryEntry(Country const& new_country, Date new_date)
+CountryHistoryEntry::CountryHistoryEntry(CountryDefinition const& new_country, Date new_date)
: HistoryEntry { new_date }, country { new_country } {}
-CountryHistoryMap::CountryHistoryMap(Country const& new_country) : country { new_country } {}
+CountryHistoryMap::CountryHistoryMap(CountryDefinition const& new_country) : country { new_country } {}
std::unique_ptr<CountryHistoryEntry> CountryHistoryMap::_make_entry(Date date) const {
return std::unique_ptr<CountryHistoryEntry> { new CountryHistoryEntry { country, date } };
@@ -21,14 +22,14 @@ bool CountryHistoryMap::_load_history_entry(
PoliticsManager const& politics_manager = definition_manager.get_politics_manager();
IssueManager const& issue_manager = politics_manager.get_issue_manager();
CultureManager const& culture_manager = definition_manager.get_pop_manager().get_culture_manager();
- CountryManager const& country_manager = definition_manager.get_country_manager();
+ CountryDefinitionManager const& country_definition_manager = definition_manager.get_country_definition_manager();
TechnologyManager const& technology_manager = definition_manager.get_research_manager().get_technology_manager();
InventionManager const& invention_manager = definition_manager.get_research_manager().get_invention_manager();
DecisionManager const& decision_manager = definition_manager.get_decision_manager();
return expect_dictionary_keys_and_default(
[this, &definition_manager, &dataloader, &deployment_manager, &issue_manager, &technology_manager, &invention_manager,
- &country_manager, &entry](std::string_view key, ast::NodeCPtr value) -> bool {
+ &country_definition_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 {
@@ -109,7 +110,7 @@ bool CountryHistoryMap::_load_history_entry(
assign_variable_callback_pointer_opt(entry.tech_school)
),
"foreign_investment", ZERO_OR_ONE,
- country_manager.expect_country_decimal_map(move_variable_callback(entry.foreign_investment)),
+ country_definition_manager.expect_country_definition_decimal_map(move_variable_callback(entry.foreign_investment)),
"literacy", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(entry.literacy)),
"non_state_culture_literacy", ZERO_OR_ONE,
expect_fixed_point(assign_variable_callback(entry.nonstate_culture_literacy)),
@@ -200,7 +201,7 @@ bool CountryHistoryManager::is_locked() const {
return locked;
}
-CountryHistoryMap const* CountryHistoryManager::get_country_history(Country const* country) const {
+CountryHistoryMap const* CountryHistoryManager::get_country_history(CountryDefinition const* country) const {
if (country == nullptr) {
Logger::error("Attempted to access history of null country");
return nullptr;
@@ -215,7 +216,7 @@ CountryHistoryMap const* CountryHistoryManager::get_country_history(Country cons
}
bool CountryHistoryManager::load_country_history_file(
- DefinitionManager& definition_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root
+ DefinitionManager& definition_manager, Dataloader const& dataloader, CountryDefinition const& country, ast::NodeCPtr root
) {
if (locked) {
Logger::error("Attempted to load country history file for ", country, " after country history registry was locked!");
diff --git a/src/openvic-simulation/history/CountryHistory.hpp b/src/openvic-simulation/history/CountryHistory.hpp
index cf934f5..0de76c6 100644
--- a/src/openvic-simulation/history/CountryHistory.hpp
+++ b/src/openvic-simulation/history/CountryHistory.hpp
@@ -10,7 +10,7 @@
namespace OpenVic {
struct CountryHistoryMap;
- struct Country;
+ struct CountryDefinition;
struct Culture;
struct Religion;
struct CountryParty;
@@ -29,7 +29,7 @@ namespace OpenVic {
friend struct CountryHistoryMap;
private:
- Country const& PROPERTY(country);
+ CountryDefinition const& PROPERTY(country);
std::optional<Culture const*> PROPERTY(primary_culture);
std::vector<Culture const*> PROPERTY(accepted_cultures);
@@ -48,7 +48,7 @@ namespace OpenVic {
std::optional<TechnologySchool const*> PROPERTY(tech_school);
ordered_map<Technology const*, bool> PROPERTY(technologies);
ordered_map<Invention const*, bool> PROPERTY(inventions);
- fixed_point_map_t<Country const*> PROPERTY(foreign_investment);
+ fixed_point_map_t<CountryDefinition const*> PROPERTY(foreign_investment);
std::optional<fixed_point_t> PROPERTY(consciousness);
std::optional<fixed_point_t> PROPERTY(nonstate_consciousness);
std::optional<fixed_point_t> PROPERTY(literacy);
@@ -58,9 +58,9 @@ namespace OpenVic {
string_set_t PROPERTY(country_flags);
string_set_t PROPERTY(global_flags);
ordered_map<GovernmentType const*, GovernmentType const*> PROPERTY(government_flag_overrides);
- ordered_set<Decision const*> decisions;
+ ordered_set<Decision const*> PROPERTY(decisions);
- CountryHistoryEntry(Country const& new_country, Date new_date);
+ CountryHistoryEntry(CountryDefinition const& new_country, Date new_date);
};
class Dataloader;
@@ -71,10 +71,10 @@ namespace OpenVic {
friend struct CountryHistoryManager;
private:
- Country const& PROPERTY(country);
+ CountryDefinition const& PROPERTY(country);
protected:
- CountryHistoryMap(Country const& new_country);
+ CountryHistoryMap(CountryDefinition const& new_country);
std::unique_ptr<CountryHistoryEntry> _make_entry(Date date) const override;
bool _load_history_entry(
@@ -85,7 +85,7 @@ namespace OpenVic {
struct CountryHistoryManager {
private:
- ordered_map<Country const*, CountryHistoryMap> country_histories;
+ ordered_map<CountryDefinition const*, CountryHistoryMap> country_histories;
bool locked = false;
public:
@@ -95,10 +95,11 @@ namespace OpenVic {
void lock_country_histories();
bool is_locked() const;
- CountryHistoryMap const* get_country_history(Country const* country) const;
+ CountryHistoryMap const* get_country_history(CountryDefinition const* country) const;
bool load_country_history_file(
- DefinitionManager& definition_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root
+ DefinitionManager& definition_manager, Dataloader const& dataloader, CountryDefinition const& country,
+ ast::NodeCPtr root
);
};
diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp
index c9b2379..a06c0d1 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.cpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.cpp
@@ -7,17 +7,17 @@ using namespace OpenVic::NodeTools;
WarHistory::added_wargoal_t::added_wargoal_t(
Date new_added,
- Country const* new_actor,
- Country const* new_receiver,
+ CountryDefinition const* new_actor,
+ CountryDefinition const* new_receiver,
WargoalType const* new_wargoal,
- std::optional<Country const*> new_third_party,
+ std::optional<CountryDefinition const*> new_third_party,
std::optional<ProvinceDefinition const*> new_target
) : added { new_added }, actor { new_actor }, receiver { new_receiver }, wargoal { new_wargoal },
third_party { new_third_party }, target { new_target } {}
WarHistory::war_participant_t::war_participant_t(
- Country const* new_country,
- const Period new_period
+ CountryDefinition const* new_country,
+ Period new_period
) : country { new_country }, period { new_period } {}
WarHistory::WarHistory(
@@ -29,22 +29,22 @@ WarHistory::WarHistory(
wargoals { std::move(new_wargoals) } {}
AllianceHistory::AllianceHistory(
- Country const* new_first,
- Country const* new_second,
- const Period new_period
+ CountryDefinition const* new_first,
+ CountryDefinition const* new_second,
+ Period new_period
) : first { new_first }, second { new_second }, period { new_period } {}
ReparationsHistory::ReparationsHistory(
- Country const* new_receiver,
- Country const* new_sender,
- const Period new_period
+ CountryDefinition const* new_receiver,
+ CountryDefinition const* new_sender,
+ Period new_period
) : receiver { new_receiver }, sender { new_sender }, period { new_period } {}
SubjectHistory::SubjectHistory(
- Country const* new_overlord,
- Country const* new_subject,
- const type_t new_type,
- const Period new_period
+ CountryDefinition const* new_overlord,
+ CountryDefinition const* new_subject,
+ type_t new_type,
+ Period new_period
) : overlord { new_overlord }, subject { new_subject }, type { new_type }, period { new_period } {}
void DiplomaticHistoryManager::reserve_more_wars(size_t size) {
@@ -108,19 +108,23 @@ std::vector<WarHistory const*> DiplomaticHistoryManager::get_wars(Date date) con
return ret;
}
-bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& country_manager, ast::NodeCPtr root) {
+bool DiplomaticHistoryManager::load_diplomacy_history_file(
+ CountryDefinitionManager const& country_definition_manager, ast::NodeCPtr root
+) {
return expect_dictionary_keys(
- "alliance", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
- Country const* first = nullptr;
- Country const* second = nullptr;
+ "alliance", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool {
+ CountryDefinition const* first = nullptr;
+ CountryDefinition const* second = nullptr;
Date start {};
std::optional<Date> end {};
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(first)),
- "second", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(second)),
+ "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(first)
+ ),
+ "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(second)
+ ),
"start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)),
"end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end))
)(node);
@@ -128,17 +132,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const&
alliances.push_back({ first, second, { start, end } });
return ret;
},
- "vassal", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
- Country const* overlord = nullptr;
- Country const* subject = nullptr;
+ "vassal", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool {
+ CountryDefinition const* overlord = nullptr;
+ CountryDefinition const* subject = nullptr;
Date start {};
std::optional<Date> end {};
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(overlord)),
- "second", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(subject)),
+ "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(overlord)
+ ),
+ "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(subject)
+ ),
"start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)),
"end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end))
)(node);
@@ -146,17 +152,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const&
subjects.push_back({ overlord, subject, SubjectHistory::type_t::VASSAL, { start, end } });
return ret;
},
- "union", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
- Country const* overlord = nullptr;
- Country const* subject = nullptr;
+ "union", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool {
+ CountryDefinition const* overlord = nullptr;
+ CountryDefinition const* subject = nullptr;
Date start {};
std::optional<Date> end {};
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(overlord)),
- "second", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(subject)),
+ "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(overlord)
+ ),
+ "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(subject)
+ ),
"start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)),
"end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end))
)(node);
@@ -164,17 +172,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const&
subjects.push_back({ overlord, subject, SubjectHistory::type_t::UNION, { start, end } });
return ret;
},
- "substate", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
- Country const* overlord = nullptr;
- Country const* subject = nullptr;
+ "substate", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool {
+ CountryDefinition const* overlord = nullptr;
+ CountryDefinition const* subject = nullptr;
Date start {};
std::optional<Date> end {};
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(overlord)),
- "second", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(subject)),
+ "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(overlord)
+ ),
+ "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(subject)
+ ),
"start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)),
"end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end))
)(node);
@@ -182,17 +192,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const&
subjects.push_back({ overlord, subject, SubjectHistory::type_t::SUBSTATE, { start, end } });
return ret;
},
- "reparations", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool {
- Country const* receiver = nullptr;
- Country const* sender = nullptr;
+ "reparations", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool {
+ CountryDefinition const* receiver = nullptr;
+ CountryDefinition const* sender = nullptr;
Date start {};
std::optional<Date> end {};
bool ret = expect_dictionary_keys(
- "first", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(receiver)),
- "second", ONE_EXACTLY,
- country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(sender)),
+ "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(receiver)
+ ),
+ "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string(
+ assign_variable_callback_pointer(sender)
+ ),
"start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)),
"end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end))
)(node);
@@ -217,111 +229,115 @@ bool DiplomaticHistoryManager::load_war_history_file(DefinitionManager const& de
bool ret = expect_date_str(assign_variable_callback(current_date))(key);
ret &= expect_dictionary_keys(
- "add_attacker", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier(
- [&attackers, &current_date, &name](Country const& country) -> bool {
- for (auto const& attacker : attackers) {
- if (attacker.get_country() == &country) {
- Logger::error(
- "In history of war ", name, " at date ", current_date.to_string(),
- ": Attempted to add attacking country ", attacker.get_country()->get_identifier(),
- " which is already present!"
- );
- return false;
+ "add_attacker", ZERO_OR_MORE,
+ definition_manager.get_country_definition_manager().expect_country_definition_identifier(
+ [&attackers, &current_date, &name](CountryDefinition const& country) -> bool {
+ for (auto const& attacker : attackers) {
+ if (attacker.get_country() == &country) {
+ Logger::error(
+ "In history of war ", name, " at date ", current_date.to_string(),
+ ": Attempted to add attacking country ", attacker.get_country()->get_identifier(),
+ " which is already present!"
+ );
+ return false;
+ }
}
- }
- attackers.push_back({ &country, { current_date, {} } });
- return true;
- }
- ),
- "add_defender", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier(
- [&defenders, &current_date, &name](Country const& country) -> bool {
- for (auto const& defender : defenders) {
- if (defender.get_country() == &country) {
- Logger::error(
- "In history of war ", name, " at date ", current_date.to_string(),
- ": Attempted to add defending country ", defender.get_country()->get_identifier(),
- " which is already present!"
- );
- return false;
- }
+ attackers.push_back({ &country, { current_date, {} } });
+ return true;
}
-
- defenders.push_back({ &country, { current_date, {} } });
- return true;
- }
- ),
- "rem_attacker", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier(
- [&attackers, &current_date, &name](Country const& country) -> bool {
- WarHistory::war_participant_t* participant_to_remove = nullptr;
-
- for (auto& attacker : attackers) {
- if (attacker.country == &country) {
- participant_to_remove = &attacker;
- break;
+ ),
+ "add_defender", ZERO_OR_MORE,
+ definition_manager.get_country_definition_manager().expect_country_definition_identifier(
+ [&defenders, &current_date, &name](CountryDefinition const& country) -> bool {
+ for (auto const& defender : defenders) {
+ if (defender.get_country() == &country) {
+ Logger::error(
+ "In history of war ", name, " at date ", current_date.to_string(),
+ ": Attempted to add defending country ", defender.get_country()->get_identifier(),
+ " which is already present!"
+ );
+ return false;
+ }
}
- }
- if (participant_to_remove == nullptr) {
- Logger::warning(
- "In history of war ", name, " at date ", current_date.to_string(),
- ": Attempted to remove attacking country ", country.get_identifier(),
- " which was not present!"
- );
+ defenders.push_back({ &country, { current_date, {} } });
return true;
}
+ ),
+ "rem_attacker", ZERO_OR_MORE,
+ definition_manager.get_country_definition_manager().expect_country_definition_identifier(
+ [&attackers, &current_date, &name](CountryDefinition const& country) -> bool {
+ WarHistory::war_participant_t* participant_to_remove = nullptr;
+
+ for (auto& attacker : attackers) {
+ if (attacker.country == &country) {
+ participant_to_remove = &attacker;
+ break;
+ }
+ }
- return participant_to_remove->period.try_set_end(current_date);
- }
- ),
- "rem_defender", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier(
- [&defenders, &current_date, &name](Country const& country) -> bool {
- WarHistory::war_participant_t* participant_to_remove = nullptr;
-
- for (auto& defender : defenders) {
- if (defender.country == &country) {
- participant_to_remove = &defender;
- break;
+ if (participant_to_remove == nullptr) {
+ Logger::warning(
+ "In history of war ", name, " at date ", current_date.to_string(),
+ ": Attempted to remove attacking country ", country.get_identifier(),
+ " which was not present!"
+ );
+ return true;
}
- }
- if (participant_to_remove == nullptr) {
- Logger::warning(
- "In history of war ", name, " at date ", current_date.to_string(),
- ": Attempted to remove attacking country ", country.get_identifier(),
- " which was not present!"
- );
- return true;
+ return participant_to_remove->period.try_set_end(current_date);
}
+ ),
+ "rem_defender", ZERO_OR_MORE,
+ definition_manager.get_country_definition_manager().expect_country_definition_identifier(
+ [&defenders, &current_date, &name](CountryDefinition const& country) -> bool {
+ WarHistory::war_participant_t* participant_to_remove = nullptr;
+
+ for (auto& defender : defenders) {
+ if (defender.country == &country) {
+ participant_to_remove = &defender;
+ break;
+ }
+ }
- return participant_to_remove->period.try_set_end(current_date);
- }
- ),
+ if (participant_to_remove == nullptr) {
+ Logger::warning(
+ "In history of war ", name, " at date ", current_date.to_string(),
+ ": Attempted to remove attacking country ", country.get_identifier(),
+ " which was not present!"
+ );
+ return true;
+ }
+
+ return participant_to_remove->period.try_set_end(current_date);
+ }
+ ),
"war_goal", ZERO_OR_MORE, [&definition_manager, &wargoals, &current_date](ast::NodeCPtr value) -> bool {
- Country const* actor = nullptr;
- Country const* receiver = nullptr;
+ CountryDefinition const* actor = nullptr;
+ CountryDefinition const* receiver = nullptr;
WargoalType const* type = nullptr;
- std::optional<Country const*> third_party {};
+ std::optional<CountryDefinition const*> third_party {};
std::optional<ProvinceDefinition const*> target {};
bool ret = expect_dictionary_keys(
"actor", ONE_EXACTLY,
- definition_manager.get_country_manager().expect_country_identifier(
+ definition_manager.get_country_definition_manager().expect_country_definition_identifier(
assign_variable_callback_pointer(actor)
),
"receiver", ONE_EXACTLY,
- definition_manager.get_country_manager().expect_country_identifier(
+ definition_manager.get_country_definition_manager().expect_country_definition_identifier(
assign_variable_callback_pointer(receiver)
),
"casus_belli", ONE_EXACTLY, definition_manager.get_military_manager().get_wargoal_type_manager()
.expect_wargoal_type_identifier(assign_variable_callback_pointer(type)),
"country", ZERO_OR_ONE,
- definition_manager.get_country_manager().expect_country_identifier(
- assign_variable_callback_pointer(*third_party)
+ definition_manager.get_country_definition_manager().expect_country_definition_identifier(
+ assign_variable_callback_pointer_opt(third_party)
),
"state_province_id", ZERO_OR_ONE,
definition_manager.get_map_definition().expect_province_definition_identifier(
- assign_variable_callback_pointer(*target)
+ assign_variable_callback_pointer_opt(target)
)
)(value);
diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp
index 6055806..c6c6911 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.hpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.hpp
@@ -10,7 +10,7 @@
namespace OpenVic {
struct DiplomaticHistoryManager;
- struct Country;
+ struct CountryDefinition;
struct WargoalType;
struct ProvinceDefinition;
@@ -22,17 +22,18 @@ namespace OpenVic {
private:
Date PROPERTY_CUSTOM_PREFIX(added, get_date);
- Country const* PROPERTY(actor);
- Country const* PROPERTY(receiver);
+ CountryDefinition const* PROPERTY(actor);
+ CountryDefinition const* PROPERTY(receiver);
WargoalType const* PROPERTY(wargoal);
// TODO - could these just be nullptr when unset rather than using optionals?
- std::optional<Country const*> PROPERTY(third_party);
+ std::optional<CountryDefinition const*> PROPERTY(third_party);
std::optional<ProvinceDefinition const*> PROPERTY(target);
added_wargoal_t(
- Date new_added, Country const* new_actor, Country const* new_receiver, WargoalType const* new_wargoal,
- std::optional<Country const*> new_third_party, std::optional<ProvinceDefinition const*> new_target
+ Date new_added, CountryDefinition const* new_actor, CountryDefinition const* new_receiver,
+ WargoalType const* new_wargoal, std::optional<CountryDefinition const*> new_third_party,
+ std::optional<ProvinceDefinition const*> new_target
);
};
@@ -40,10 +41,10 @@ namespace OpenVic {
friend struct DiplomaticHistoryManager;
private:
- Country const* PROPERTY(country);
+ CountryDefinition const* PROPERTY(country);
Period PROPERTY(period);
- war_participant_t(Country const* new_country, const Period period);
+ war_participant_t(CountryDefinition const* new_country, Period period);
};
private:
@@ -64,22 +65,22 @@ namespace OpenVic {
friend struct DiplomaticHistoryManager;
private:
- Country const* PROPERTY(first);
- Country const* PROPERTY(second);
+ CountryDefinition const* PROPERTY(first);
+ CountryDefinition const* PROPERTY(second);
const Period PROPERTY(period);
- AllianceHistory(Country const* new_first, Country const* new_second, const Period period);
+ AllianceHistory(CountryDefinition const* new_first, CountryDefinition const* new_second, Period period);
};
struct ReparationsHistory {
friend struct DiplomaticHistoryManager;
private:
- Country const* PROPERTY(receiver);
- Country const* PROPERTY(sender);
+ CountryDefinition const* PROPERTY(receiver);
+ CountryDefinition const* PROPERTY(sender);
const Period PROPERTY(period);
- ReparationsHistory(Country const* new_receiver, Country const* new_sender, const Period period);
+ ReparationsHistory(CountryDefinition const* new_receiver, CountryDefinition const* new_sender, Period period);
};
struct SubjectHistory {
@@ -92,15 +93,17 @@ namespace OpenVic {
};
private:
- Country const* PROPERTY(overlord);
- Country const* PROPERTY(subject);
+ CountryDefinition const* PROPERTY(overlord);
+ CountryDefinition const* PROPERTY(subject);
const type_t PROPERTY_CUSTOM_PREFIX(type, get_subject);
const Period PROPERTY(period);
- SubjectHistory(Country const* new_overlord, Country const* new_subject, const type_t new_type, const Period period);
+ SubjectHistory(
+ CountryDefinition const* new_overlord, CountryDefinition const* new_subject, type_t new_type, Period period
+ );
};
- struct CountryManager;
+ struct CountryDefinitionManager;
struct DefinitionManager;
struct DiplomaticHistoryManager {
@@ -125,7 +128,7 @@ namespace OpenVic {
* should be checked for by functions that use get_wars() */
std::vector<WarHistory const*> get_wars(Date date) const;
- bool load_diplomacy_history_file(CountryManager const& country_manager, ast::NodeCPtr root);
+ bool load_diplomacy_history_file(CountryDefinitionManager const& country_definition_manager, ast::NodeCPtr root);
bool load_war_history_file(DefinitionManager const& definition_manager, ast::NodeCPtr root);
};
}
diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp
index ffbda51..f2291e8 100644
--- a/src/openvic-simulation/history/ProvinceHistory.cpp
+++ b/src/openvic-simulation/history/ProvinceHistory.cpp
@@ -19,7 +19,7 @@ bool ProvinceHistoryMap::_load_history_entry(
DefinitionManager const& definition_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root
) {
BuildingTypeManager const& building_type_manager = definition_manager.get_economy_manager().get_building_type_manager();
- CountryManager const& country_manager = definition_manager.get_country_manager();
+ CountryDefinitionManager const& country_definition_manager = definition_manager.get_country_definition_manager();
GoodDefinitionManager const& good_definition_manager =
definition_manager.get_economy_manager().get_good_definition_manager();
IdeologyManager const& ideology_manager = definition_manager.get_politics_manager().get_ideology_manager();
@@ -53,12 +53,16 @@ bool ProvinceHistoryMap::_load_history_entry(
return _load_history_sub_entry_callback(definition_manager, entry.get_date(), value, key, value);
},
- "owner", ZERO_OR_ONE,
- country_manager.expect_country_identifier(assign_variable_callback_pointer_opt(entry.owner, true)),
- "controller", ZERO_OR_ONE,
- country_manager.expect_country_identifier(assign_variable_callback_pointer_opt(entry.controller, 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(
+ "owner", ZERO_OR_ONE, country_definition_manager.expect_country_definition_identifier(
+ assign_variable_callback_pointer_opt(entry.owner, true)
+ ),
+ "controller", ZERO_OR_ONE, country_definition_manager.expect_country_definition_identifier(
+ assign_variable_callback_pointer_opt(entry.controller, true)
+ ),
+ "add_core", ZERO_OR_MORE, country_definition_manager.expect_country_definition_identifier(
+ vector_callback_pointer(entry.add_cores)
+ ),
+ "remove_core", ZERO_OR_MORE, country_definition_manager.expect_country_definition_identifier(
vector_callback_pointer(entry.remove_cores)
),
"colonial", ZERO_OR_ONE,
diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp
index 7c283f4..d6bf150 100644
--- a/src/openvic-simulation/history/ProvinceHistory.hpp
+++ b/src/openvic-simulation/history/ProvinceHistory.hpp
@@ -15,7 +15,7 @@
namespace OpenVic {
struct ProvinceHistoryMap;
struct ProvinceDefinition;
- struct Country;
+ struct CountryDefinition;
struct GoodDefinition;
struct TerrainType;
struct Ideology;
@@ -27,12 +27,12 @@ namespace OpenVic {
private:
ProvinceDefinition const& PROPERTY(province);
- std::optional<Country const*> PROPERTY(owner);
- std::optional<Country const*> PROPERTY(controller);
+ std::optional<CountryDefinition const*> PROPERTY(owner);
+ std::optional<CountryDefinition const*> PROPERTY(controller);
std::optional<ProvinceInstance::colony_status_t> PROPERTY(colonial);
std::optional<bool> PROPERTY(slave);
- std::vector<Country const*> PROPERTY(add_cores);
- std::vector<Country const*> PROPERTY(remove_cores);
+ std::vector<CountryDefinition const*> PROPERTY(add_cores);
+ std::vector<CountryDefinition const*> PROPERTY(remove_cores);
std::optional<GoodDefinition const*> PROPERTY(rgo);
std::optional<ProvinceInstance::life_rating_t> PROPERTY(life_rating);
std::optional<TerrainType const*> PROPERTY(terrain_type);
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp
index 093d341..1547ade 100644
--- a/src/openvic-simulation/map/MapInstance.cpp
+++ b/src/openvic-simulation/map/MapInstance.cpp
@@ -86,7 +86,7 @@ bool MapInstance::setup(BuildingTypeManager const& building_type_manager) {
bool MapInstance::apply_history_to_provinces(
ProvinceHistoryManager const& history_manager, Date date, IdeologyManager const& ideology_manager,
- IssueManager const& issue_manager, Country const& country
+ IssueManager const& issue_manager, CountryDefinition const& country
) {
bool ret = true;
diff --git a/src/openvic-simulation/map/MapInstance.hpp b/src/openvic-simulation/map/MapInstance.hpp
index 353a3a4..2c0ff74 100644
--- a/src/openvic-simulation/map/MapInstance.hpp
+++ b/src/openvic-simulation/map/MapInstance.hpp
@@ -12,7 +12,7 @@ namespace OpenVic {
struct ProvinceHistoryManager;
struct IdeologyManager;
struct IssueManager;
- struct Country;
+ struct CountryDefinition;
/* REQUIREMENTS:
* MAP-4
@@ -47,7 +47,7 @@ namespace OpenVic {
bool setup(BuildingTypeManager const& building_type_manager);
bool apply_history_to_provinces(
ProvinceHistoryManager const& history_manager, Date date, IdeologyManager const& ideology_manager,
- IssueManager const& issue_manager, Country const& country
+ IssueManager const& issue_manager, CountryDefinition const& country
);
void update_gamestate(Date today);
diff --git a/src/openvic-simulation/map/Mapmode.cpp b/src/openvic-simulation/map/Mapmode.cpp
index 410ea2b..f03b0e8 100644
--- a/src/openvic-simulation/map/Mapmode.cpp
+++ b/src/openvic-simulation/map/Mapmode.cpp
@@ -2,7 +2,7 @@
#include <cassert>
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/map/MapDefinition.hpp"
#include "openvic-simulation/map/MapInstance.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index 2a0863d..967d72b 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -1,6 +1,6 @@
#include "ProvinceInstance.hpp"
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/history/ProvinceHistory.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
#include "openvic-simulation/military/UnitInstance.hpp"
@@ -176,7 +176,7 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const* ent
if (entry->get_owner()) owner = *entry->get_owner();
if (entry->get_controller()) controller = *entry->get_controller();
if (entry->get_slave()) slave = *entry->get_slave();
- for (Country const* core : entry->get_remove_cores()) {
+ for (CountryDefinition const* core : entry->get_remove_cores()) {
const typename decltype(cores)::iterator existing_core = std::find(cores.begin(), cores.end(), core);
if (existing_core != cores.end()) {
cores.erase(existing_core);
@@ -186,7 +186,7 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const* ent
);
}
}
- for (Country const* core : entry->get_add_cores()) {
+ for (CountryDefinition const* core : entry->get_add_cores()) {
const typename decltype(cores)::iterator existing_core = std::find(cores.begin(), cores.end(), core);
if (existing_core == cores.end()) {
cores.push_back(core);
@@ -215,7 +215,7 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const* ent
}
void ProvinceInstance::setup_pop_test_values(
- IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country
+ IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country
) {
for (Pop& pop : pops) {
pop.setup_pop_test_values(ideology_manager, issue_manager, country);
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index 67ce423..8e8ec93 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -11,7 +11,7 @@ namespace OpenVic {
struct ProvinceDefinition;
struct TerrainType;
struct State;
- struct Country;
+ struct CountryDefinition;
struct Crime;
struct GoodDefinition;
struct ArmyInstance;
@@ -31,16 +31,17 @@ namespace OpenVic {
enum struct colony_status_t : uint8_t { STATE, PROTECTORATE, COLONY };
+ private:
ProvinceDefinition const& PROPERTY(province_definition);
- /* Mutable attributes (reset before loading history) */
TerrainType const* PROPERTY(terrain_type);
life_rating_t PROPERTY(life_rating);
colony_status_t PROPERTY(colony_status);
State const* PROPERTY_RW(state);
- Country const* PROPERTY(owner);
- Country const* PROPERTY(controller);
- std::vector<Country const*> PROPERTY(cores);
+ CountryDefinition const* PROPERTY(owner);
+ CountryDefinition const* PROPERTY(controller);
+ // Cores being CountryDefinitions means then they won't be affected by tag switched (as desired)
+ std::vector<CountryDefinition const*> PROPERTY(cores);
bool PROPERTY(slave);
Crime const* PROPERTY_RW(crime);
// TODO - change this into a factory-like structure
@@ -86,7 +87,7 @@ namespace OpenVic {
bool apply_history_to_province(ProvinceHistoryEntry const* entry);
void setup_pop_test_values(
- IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country
+ IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country
);
};
}
diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp
index 46ff11d..42d84cc 100644
--- a/src/openvic-simulation/map/State.cpp
+++ b/src/openvic-simulation/map/State.cpp
@@ -1,6 +1,5 @@
#include "State.hpp"
-#include "openvic-simulation/country/Country.hpp"
#include "openvic-simulation/map/MapDefinition.hpp"
#include "openvic-simulation/map/MapInstance.hpp"
#include "openvic-simulation/map/ProvinceInstance.hpp"
@@ -9,8 +8,8 @@
using namespace OpenVic;
State::State(
- StateSet const& new_state_set, Country const* owner, ProvinceInstance* capital, std::vector<ProvinceInstance*>&& provinces,
- ProvinceInstance::colony_status_t colony_status
+ StateSet const& new_state_set, CountryDefinition const* owner, ProvinceInstance* capital,
+ std::vector<ProvinceInstance*>&& provinces, ProvinceInstance::colony_status_t colony_status
) : state_set { new_state_set }, owner { owner }, capital { capital }, provinces { std::move(provinces) },
colony_status { colony_status } {}
diff --git a/src/openvic-simulation/map/State.hpp b/src/openvic-simulation/map/State.hpp
index ff8acfa..6111668 100644
--- a/src/openvic-simulation/map/State.hpp
+++ b/src/openvic-simulation/map/State.hpp
@@ -9,7 +9,7 @@
namespace OpenVic {
struct StateManager;
struct StateSet;
- struct Country;
+ struct CountryDefinition;
struct ProvinceInstance;
struct State {
@@ -17,7 +17,7 @@ namespace OpenVic {
private:
StateSet const& PROPERTY(state_set);
- Country const* PROPERTY(owner);
+ CountryDefinition const* PROPERTY(owner);
ProvinceInstance* PROPERTY(capital);
std::vector<ProvinceInstance*> PROPERTY(provinces);
ProvinceInstance::colony_status_t PROPERTY(colony_status);
@@ -25,7 +25,7 @@ namespace OpenVic {
Pop::pop_size_t PROPERTY(total_population);
State(
- StateSet const& new_state_set, Country const* owner, ProvinceInstance* capital,
+ StateSet const& new_state_set, CountryDefinition const* owner, ProvinceInstance* capital,
std::vector<ProvinceInstance*>&& provinces, ProvinceInstance::colony_status_t colony_status
);
diff --git a/src/openvic-simulation/pop/Culture.cpp b/src/openvic-simulation/pop/Culture.cpp
index 18ed3d8..93d4d19 100644
--- a/src/openvic-simulation/pop/Culture.cpp
+++ b/src/openvic-simulation/pop/Culture.cpp
@@ -1,6 +1,6 @@
#include "Culture.hpp"
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/dataloader/NodeTools.hpp"
#include "openvic-simulation/types/Colour.hpp"
@@ -11,13 +11,13 @@ GraphicalCultureType::GraphicalCultureType(std::string_view new_identifier) : Ha
CultureGroup::CultureGroup(
std::string_view new_identifier, std::string_view new_leader, GraphicalCultureType const& new_unit_graphical_culture_type,
- bool new_is_overseas, Country const* new_union_country
+ bool new_is_overseas, CountryDefinition const* new_union_country
) : HasIdentifier { new_identifier }, leader { new_leader }, unit_graphical_culture_type { new_unit_graphical_culture_type },
is_overseas { new_is_overseas }, union_country { new_union_country } {}
Culture::Culture(
std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, name_list_t&& new_first_names,
- name_list_t&& new_last_names, fixed_point_t new_radicalism, Country const* new_primary_country
+ name_list_t&& new_last_names, fixed_point_t new_radicalism, CountryDefinition const* new_primary_country
) : HasIdentifierAndColour { new_identifier, new_colour, false }, group { new_group },
first_names { std::move(new_first_names) }, last_names { std::move(new_last_names) }, radicalism { new_radicalism },
primary_country { new_primary_country } {}
@@ -34,7 +34,7 @@ bool CultureManager::add_graphical_culture_type(std::string_view identifier) {
bool CultureManager::add_culture_group(
std::string_view identifier, std::string_view leader, GraphicalCultureType const* graphical_culture_type, bool is_overseas,
- Country const* union_country
+ CountryDefinition const* union_country
) {
if (!graphical_culture_types.is_locked()) {
Logger::error("Cannot register culture groups until graphical culture types are locked!");
@@ -57,7 +57,7 @@ bool CultureManager::add_culture_group(
bool CultureManager::add_culture(
std::string_view identifier, colour_t colour, CultureGroup const& group, name_list_t&& first_names,
- name_list_t&& last_names, fixed_point_t radicalism, Country const* primary_country
+ name_list_t&& last_names, fixed_point_t radicalism, CountryDefinition const* primary_country
) {
if (!culture_groups.is_locked()) {
Logger::error("Cannot register cultures until culture groups are locked!");
@@ -95,20 +95,21 @@ bool CultureManager::load_graphical_culture_type_file(ast::NodeCPtr root) {
}
bool CultureManager::_load_culture_group(
- CountryManager const& country_manager, size_t& total_expected_cultures, std::string_view culture_group_key,
- ast::NodeCPtr culture_group_node
+ CountryDefinitionManager const& country_definition_manager, size_t& total_expected_cultures,
+ std::string_view culture_group_key, ast::NodeCPtr culture_group_node
) {
std::string_view leader {};
GraphicalCultureType const* unit_graphical_culture_type = default_graphical_culture_type;
bool is_overseas = true;
- Country const* union_country = nullptr;
+ CountryDefinition const* union_country = nullptr;
bool ret = expect_dictionary_keys_and_default(
increment_callback(total_expected_cultures),
"leader", ONE_EXACTLY, expect_identifier(assign_variable_callback(leader)),
"unit", ZERO_OR_ONE,
expect_graphical_culture_type_identifier(assign_variable_callback_pointer(unit_graphical_culture_type)),
- "union", ZERO_OR_ONE, country_manager.expect_country_identifier(assign_variable_callback_pointer(union_country)),
+ "union", ZERO_OR_ONE,
+ country_definition_manager.expect_country_definition_identifier(assign_variable_callback_pointer(union_country)),
"is_overseas", ZERO_OR_ONE, expect_bool(assign_variable_callback(is_overseas))
)(culture_group_node);
ret &= add_culture_group(culture_group_key, leader, unit_graphical_culture_type, is_overseas, union_country);
@@ -116,20 +117,21 @@ bool CultureManager::_load_culture_group(
}
bool CultureManager::_load_culture(
- CountryManager const& country_manager, CultureGroup const& culture_group, std::string_view culture_key,
+ CountryDefinitionManager const& country_definition_manager, CultureGroup const& culture_group, std::string_view culture_key,
ast::NodeCPtr culture_node
) {
colour_t colour = colour_t::null();
name_list_t first_names {}, last_names {};
fixed_point_t radicalism = 0;
- Country const* primary_country = nullptr;
+ CountryDefinition const* primary_country = nullptr;
bool ret = expect_dictionary_keys(
"color", ONE_EXACTLY, expect_colour(assign_variable_callback(colour)),
"first_names", ONE_EXACTLY, name_list_callback(move_variable_callback(first_names)),
"last_names", ONE_EXACTLY, name_list_callback(move_variable_callback(last_names)),
"radicalism", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(radicalism)),
- "primary", ZERO_OR_ONE, country_manager.expect_country_identifier(assign_variable_callback_pointer(primary_country))
+ "primary", ZERO_OR_ONE,
+ country_definition_manager.expect_country_definition_identifier(assign_variable_callback_pointer(primary_country))
)(culture_node);
ret &= add_culture(
culture_key, colour, culture_group, std::move(first_names), std::move(last_names), radicalism, primary_country
@@ -157,7 +159,7 @@ bool CultureManager::_load_culture(
* POP-267, POP-268, POP-269, POP-270, POP-271, POP-272, POP-273, POP-274, POP-275, POP-276, POP-277, POP-278, POP-279,
* POP-280, POP-281, POP-282, POP-283, POP-284
*/
-bool CultureManager::load_culture_file(CountryManager const& country_manager, ast::NodeCPtr root) {
+bool CultureManager::load_culture_file(CountryDefinitionManager const& country_definition_manager, ast::NodeCPtr root) {
if (!graphical_culture_types.is_locked()) {
Logger::error("Cannot load culture groups until graphical culture types are locked!");
return false;
@@ -165,24 +167,24 @@ bool CultureManager::load_culture_file(CountryManager const& country_manager, as
size_t total_expected_cultures = 0;
bool ret = expect_dictionary_reserve_length(culture_groups,
- [this, &country_manager, &total_expected_cultures](
+ [this, &country_definition_manager, &total_expected_cultures](
std::string_view key, ast::NodeCPtr value
) -> bool {
- return _load_culture_group(country_manager, total_expected_cultures, key, value);
+ return _load_culture_group(country_definition_manager, total_expected_cultures, key, value);
}
)(root);
lock_culture_groups();
reserve_more_cultures(total_expected_cultures);
ret &= expect_culture_group_dictionary(
- [this, &country_manager](CultureGroup const& culture_group, ast::NodeCPtr culture_group_value) -> bool {
+ [this, &country_definition_manager](CultureGroup const& culture_group, ast::NodeCPtr culture_group_value) -> bool {
return expect_dictionary(
- [this, &country_manager, &culture_group](std::string_view key, ast::NodeCPtr value) -> bool {
+ [this, &country_definition_manager, &culture_group](std::string_view key, ast::NodeCPtr value) -> bool {
static const string_set_t reserved_keys = { "leader", "unit", "union", "is_overseas" };
if (reserved_keys.contains(key)) {
return true;
}
- return _load_culture(country_manager, culture_group, key, value);
+ return _load_culture(country_definition_manager, culture_group, key, value);
}
)(culture_group_value);
}
diff --git a/src/openvic-simulation/pop/Culture.hpp b/src/openvic-simulation/pop/Culture.hpp
index 72ea3ee..9fe06de 100644
--- a/src/openvic-simulation/pop/Culture.hpp
+++ b/src/openvic-simulation/pop/Culture.hpp
@@ -5,8 +5,8 @@
namespace OpenVic {
struct CultureManager;
- struct Country;
- struct CountryManager;
+ struct CountryDefinition;
+ struct CountryDefinitionManager;
struct GraphicalCultureType : HasIdentifier {
friend struct CultureManager;
@@ -25,11 +25,12 @@ namespace OpenVic {
std::string PROPERTY(leader);
GraphicalCultureType const& PROPERTY(unit_graphical_culture_type);
bool PROPERTY(is_overseas);
- Country const* PROPERTY(union_country);
+ CountryDefinition const* PROPERTY(union_country);
CultureGroup(
std::string_view new_identifier, std::string_view new_leader,
- GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas, Country const* new_union_country
+ GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas,
+ CountryDefinition const* new_union_country
);
public:
@@ -44,11 +45,11 @@ namespace OpenVic {
name_list_t PROPERTY(first_names);
name_list_t PROPERTY(last_names);
fixed_point_t PROPERTY(radicalism);
- Country const* PROPERTY(primary_country);
+ CountryDefinition const* PROPERTY(primary_country);
Culture(
std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, name_list_t&& new_first_names,
- name_list_t&& new_last_names, fixed_point_t new_radicalism, Country const* new_primary_country
+ name_list_t&& new_last_names, fixed_point_t new_radicalism, CountryDefinition const* new_primary_country
);
public:
@@ -64,12 +65,12 @@ namespace OpenVic {
GraphicalCultureType const* PROPERTY(default_graphical_culture_type);
bool _load_culture_group(
- CountryManager const& country_manager, size_t& total_expected_cultures,
+ CountryDefinitionManager const& country_definition_manager, size_t& total_expected_cultures,
std::string_view culture_group_key, ast::NodeCPtr culture_group_node
);
bool _load_culture(
- CountryManager const& country_manager, CultureGroup const& culture_group, std::string_view culture_key,
- ast::NodeCPtr node
+ CountryDefinitionManager const& country_definition_manager, CultureGroup const& culture_group,
+ std::string_view culture_key, ast::NodeCPtr node
);
public:
@@ -79,15 +80,15 @@ namespace OpenVic {
bool add_culture_group(
std::string_view identifier, std::string_view leader, GraphicalCultureType const* graphical_culture_type,
- bool is_overseas, Country const* union_country
+ bool is_overseas, CountryDefinition const* union_country
);
bool add_culture(
std::string_view identifier, colour_t colour, CultureGroup const& group, name_list_t&& first_names,
- name_list_t&& last_names, fixed_point_t radicalism, Country const* primary_country
+ name_list_t&& last_names, fixed_point_t radicalism, CountryDefinition const* primary_country
);
bool load_graphical_culture_type_file(ast::NodeCPtr root);
- bool load_culture_file(CountryManager const& country_manager, ast::NodeCPtr root);
+ bool load_culture_file(CountryDefinitionManager const& country_definition_manager, ast::NodeCPtr root);
};
}
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index b1bf56f..4f8bdcb 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -1,6 +1,6 @@
#include "Pop.hpp"
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/military/UnitType.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/politics/Issue.hpp"
@@ -50,7 +50,7 @@ Pop::Pop(
}
void Pop::setup_pop_test_values(
- IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country
+ IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country
) {
/* Returns +/- range% of size. */
const auto test_size = [this](int32_t range) -> pop_size_t {
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index a5033ef..b069f02 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -87,7 +87,7 @@ namespace OpenVic {
Pop& operator=(Pop&&) = delete;
void setup_pop_test_values(
- IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country
+ IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country
);
};
diff --git a/src/openvic-simulation/scripts/Condition.cpp b/src/openvic-simulation/scripts/Condition.cpp
index e5679f8..7abd717 100644
--- a/src/openvic-simulation/scripts/Condition.cpp
+++ b/src/openvic-simulation/scripts/Condition.cpp
@@ -352,7 +352,7 @@ bool ConditionManager::setup_conditions(DefinitionManager const& definition_mana
/* Scopes from other registries */
import_identifiers(
- definition_manager.get_country_manager().get_country_identifiers(),
+ definition_manager.get_country_definition_manager().get_country_definition_identifiers(),
GROUP,
COUNTRY,
COUNTRY,
@@ -484,7 +484,9 @@ callback_t<std::string_view> ConditionManager::expect_parse_identifier(
EXPECT_CALL_PLACEHOLDER(GLOBAL_FLAG);
EXPECT_CALL_PLACEHOLDER(COUNTRY_FLAG);
EXPECT_CALL_PLACEHOLDER(PROVINCE_FLAG);
- EXPECT_CALL(COUNTRY_TAG, country, definition_manager.get_country_manager(), "THIS", "FROM", "OWNER");
+ EXPECT_CALL(
+ COUNTRY_TAG, country_definition, definition_manager.get_country_definition_manager(), "THIS", "FROM", "OWNER"
+ );
EXPECT_CALL(PROVINCE_ID, province_definition, definition_manager.get_map_definition(), "THIS", "FROM");
EXPECT_CALL(REGION, region, definition_manager.get_map_definition());
EXPECT_CALL(IDEOLOGY, ideology, definition_manager.get_politics_manager().get_ideology_manager());
@@ -507,7 +509,9 @@ callback_t<std::string_view> ConditionManager::expect_parse_identifier(
EXPECT_CALL(MODIFIER, triggered_modifier, definition_manager.get_modifier_manager());
EXPECT_CALL(MODIFIER, static_modifier, definition_manager.get_modifier_manager());
EXPECT_CALL(NATIONAL_VALUE, national_value, definition_manager.get_politics_manager().get_national_value_manager());
- EXPECT_CALL(CULTURE_UNION, country, definition_manager.get_country_manager(), "THIS", "FROM", "THIS_UNION");
+ EXPECT_CALL(
+ CULTURE_UNION, country_definition, definition_manager.get_country_definition_manager(), "THIS", "FROM", "THIS_UNION"
+ );
EXPECT_CALL(CONTINENT, continent, definition_manager.get_map_definition());
EXPECT_CALL(CRIME, crime_modifier, definition_manager.get_crime_manager());
EXPECT_CALL(TERRAIN, terrain_type, definition_manager.get_map_definition().get_terrain_type_manager());
diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp
index 8c8ba11..fe83a43 100644
--- a/src/openvic-simulation/types/IdentifierRegistry.hpp
+++ b/src/openvic-simulation/types/IdentifierRegistry.hpp
@@ -4,7 +4,6 @@
#include "openvic-simulation/dataloader/NodeTools.hpp"
#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp"
-#include "openvic-simulation/types/HasIdentifier.hpp"
#include "openvic-simulation/utility/Getters.hpp"
#include "openvic-simulation/utility/Logger.hpp"
@@ -28,6 +27,11 @@ namespace OpenVic {
return true;
}
+ template<typename T>
+ concept HasGetIdentifier = requires(T const& t) {
+ { t.get_identifier() } -> std::same_as<std::string_view>;
+ };
+
/* Registry Value Info - the type that is being registered, and a unique identifier string getter. */
template<typename ValueInfo>
concept RegistryValueInfo = requires(
@@ -37,8 +41,8 @@ namespace OpenVic {
{ ValueInfo::get_external_value(item) } -> std::same_as<typename ValueInfo::external_value_type&>;
{ ValueInfo::get_external_value(const_item) } -> std::same_as<typename ValueInfo::external_value_type const&>;
};
- template<std::derived_from<HasIdentifier> Value>
- struct RegistryValueInfoHasIdentifier {
+ template<HasGetIdentifier Value>
+ struct RegistryValueInfoHasGetIdentifier {
using internal_value_type = Value;
using external_value_type = Value;
@@ -484,34 +488,34 @@ namespace OpenVic {
RegistryStorageInfo<StorageInfo, typename RegistryItemInfoInstance<typename ValueInfo::internal_value_type>::item_type>
using InstanceRegistry = UniqueKeyRegistry<ValueInfo, RegistryItemInfoInstance, StorageInfo, Case>;
- /* HasIdentifier Specialisations */
+ /* HasGetIdentifier Specialisations */
template<
- std::derived_from<HasIdentifier> Value, template<typename> typename StorageInfo = RegistryStorageInfoVector,
+ HasGetIdentifier Value, template<typename> typename StorageInfo = RegistryStorageInfoVector,
StringMapCase Case = StringMapCaseSensitive
>
- using IdentifierRegistry = ValueRegistry<RegistryValueInfoHasIdentifier<Value>, StorageInfo, Case>;
+ using IdentifierRegistry = ValueRegistry<RegistryValueInfoHasGetIdentifier<Value>, StorageInfo, Case>;
template<
- std::derived_from<HasIdentifier> Value, template<typename> typename StorageInfo = RegistryStorageInfoVector,
+ HasGetIdentifier Value, template<typename> typename StorageInfo = RegistryStorageInfoVector,
StringMapCase Case = StringMapCaseSensitive
>
using IdentifierPointerRegistry =
- ValueRegistry<RegistryValueInfoPointer<RegistryValueInfoHasIdentifier<Value>>, StorageInfo, Case>;
+ ValueRegistry<RegistryValueInfoPointer<RegistryValueInfoHasGetIdentifier<Value>>, StorageInfo, Case>;
template<
- std::derived_from<HasIdentifier> Value, template<typename> typename StorageInfo = RegistryStorageInfoVector,
+ HasGetIdentifier Value, template<typename> typename StorageInfo = RegistryStorageInfoVector,
StringMapCase Case = StringMapCaseSensitive
>
- using IdentifierInstanceRegistry = InstanceRegistry<RegistryValueInfoHasIdentifier<Value>, StorageInfo, Case>;
+ using IdentifierInstanceRegistry = InstanceRegistry<RegistryValueInfoHasGetIdentifier<Value>, StorageInfo, Case>;
- /* Case-Insensitive HasIdentifier Specialisations */
- template<std::derived_from<HasIdentifier> Value, template<typename> typename StorageInfo = RegistryStorageInfoVector>
+ /* Case-Insensitive HasGetIdentifier Specialisations */
+ template<HasGetIdentifier Value, template<typename> typename StorageInfo = RegistryStorageInfoVector>
using CaseInsensitiveIdentifierRegistry = IdentifierRegistry<Value, StorageInfo, StringMapCaseInsensitive>;
- template<std::derived_from<HasIdentifier> Value, template<typename> typename StorageInfo = RegistryStorageInfoVector>
+ template<HasGetIdentifier Value, template<typename> typename StorageInfo = RegistryStorageInfoVector>
using CaseInsensitiveIdentifierPointerRegistry = IdentifierPointerRegistry<Value, StorageInfo, StringMapCaseInsensitive>;
- template<std::derived_from<HasIdentifier> Value, template<typename> typename StorageInfo = RegistryStorageInfoVector>
+ template<HasGetIdentifier Value, template<typename> typename StorageInfo = RegistryStorageInfoVector>
using CaseInsensitiveIdentifierInstanceRegistry = IdentifierInstanceRegistry<Value, StorageInfo, StringMapCaseInsensitive>;
/* Macros to generate declaration and constant accessor methods for a UniqueKeyRegistry member variable. */