aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/country/CountryInstance.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-08-30 23:29:03 +0200
committer GitHub <noreply@github.com>2024-08-30 23:29:03 +0200
commit6c88ecaf2d158dfff1e0b88f0509782e1a15ae3d (patch)
tree894e8c0514a572bb4cc64216f40833995660b22d /src/openvic-simulation/country/CountryInstance.cpp
parent68fca4f504e7f178f69d0dfd64e90ffb1d579322 (diff)
parent8d5068c1db9a02a34d675536f41aee61ec3e482a (diff)
Merge pull request #188 from OpenVicProject/gov-flag-type
Load government flag overrides from history and apply them
Diffstat (limited to 'src/openvic-simulation/country/CountryInstance.cpp')
-rw-r--r--src/openvic-simulation/country/CountryInstance.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/openvic-simulation/country/CountryInstance.cpp b/src/openvic-simulation/country/CountryInstance.cpp
index 0b27b78..3c2e7bb 100644
--- a/src/openvic-simulation/country/CountryInstance.cpp
+++ b/src/openvic-simulation/country/CountryInstance.cpp
@@ -16,6 +16,7 @@ CountryInstance::CountryInstance(
decltype(technologies)::keys_t const& technology_keys,
decltype(inventions)::keys_t const& invention_keys,
decltype(upper_house)::keys_t const& ideology_keys,
+ decltype(government_flag_overrides)::keys_t const& government_type_keys,
decltype(pop_type_distribution)::keys_t const& pop_type_keys
) : /* Main attributes */
country_definition { new_country_definition },
@@ -52,6 +53,8 @@ CountryInstance::CountryInstance(
ruling_party { nullptr },
upper_house { &ideology_keys },
reforms {},
+ government_flag_overrides { &government_type_keys },
+ flag_government_type { nullptr },
suppression_points { 0 },
infamy { 0 },
plurality { 0 },
@@ -300,7 +303,7 @@ bool CountryInstance::apply_history_to_country(CountryHistoryEntry const* entry,
for (std::string const& flag : entry->get_global_flags()) {
// TODO - set global flag
}
- // entry->get_government_flag_overrides();
+ government_flag_overrides.write_non_empty_values(entry->get_government_flag_overrides());
for (Decision const* decision : entry->get_decisions()) {
// TODO - take decision
}
@@ -393,6 +396,16 @@ void CountryInstance::update_gamestate() {
colour = ERROR_COLOUR;
}
+ if (government_type != nullptr) {
+ flag_government_type = government_flag_overrides[*government_type];
+
+ if (flag_government_type == nullptr) {
+ flag_government_type = government_type;
+ }
+ } else {
+ flag_government_type = nullptr;
+ }
+
// Order of updates might need to be changed/functions split up to account for dependencies
_update_production();
_update_budget();
@@ -421,12 +434,15 @@ bool CountryInstanceManager::generate_country_instances(
decltype(CountryInstance::technologies)::keys_t const& technology_keys,
decltype(CountryInstance::inventions)::keys_t const& invention_keys,
decltype(CountryInstance::upper_house)::keys_t const& ideology_keys,
+ decltype(CountryInstance::government_flag_overrides)::keys_t const& government_type_keys,
decltype(CountryInstance::pop_type_distribution)::keys_t const& pop_type_keys
) {
reserve_more(country_instances, country_definition_manager.get_country_definition_count());
for (CountryDefinition const& country_definition : country_definition_manager.get_country_definitions()) {
- country_instances.add_item({ &country_definition, technology_keys, invention_keys, ideology_keys, pop_type_keys });
+ country_instances.add_item({
+ &country_definition, technology_keys, invention_keys, ideology_keys, government_type_keys, pop_type_keys
+ });
}
return true;