@@ -837,14 +837,10 @@ bool CountryInstance::apply_history_to_country(CountryHistoryEntry const& entry,
837837 }
838838 apply_foreign_investments (entry.get_foreign_investment (), instance_manager.get_country_instance_manager ());
839839
840- // These need to be applied to pops
841- // entry.get_consciousness();
842- // entry.get_nonstate_consciousness();
843- // entry.get_literacy();
844- // entry.get_nonstate_culture_literacy();
845-
846840 set_optional (releasable_vassal, entry.is_releasable_vassal ());
847- // entry.get_colonial_points();
841+
842+ // TODO - entry.get_colonial_points();
843+
848844 for (std::string const & flag : entry.get_country_flags ()) {
849845 ret &= set_flag (flag, true );
850846 }
@@ -1445,15 +1441,32 @@ bool CountryInstanceManager::apply_history_to_countries(InstanceManager& instanc
14451441 history_manager.get_country_history (country_instance.get_country_definition ());
14461442
14471443 if (history_map != nullptr ) {
1444+ static constexpr fixed_point_t DEFAULT_STATE_CULTURE_LITERACY = fixed_point_t::_0_50 ();
14481445 CountryHistoryEntry const * oob_history_entry = nullptr ;
1446+ std::optional<fixed_point_t > state_culture_consciousness;
1447+ std::optional<fixed_point_t > nonstate_culture_consciousness;
1448+ fixed_point_t state_culture_literacy = DEFAULT_STATE_CULTURE_LITERACY;
1449+ std::optional<fixed_point_t > nonstate_culture_literacy;
14491450
14501451 for (auto const & [entry_date, entry] : history_map->get_entries ()) {
14511452 if (entry_date <= today) {
14521453 ret &= country_instance.apply_history_to_country (*entry, instance_manager);
14531454
1454- if (entry->get_inital_oob ()) {
1455+ if (entry->get_inital_oob (). has_value () ) {
14551456 oob_history_entry = entry.get ();
14561457 }
1458+ if (entry->get_consciousness ().has_value ()) {
1459+ state_culture_consciousness = entry->get_consciousness ();
1460+ }
1461+ if (entry->get_nonstate_consciousness ().has_value ()) {
1462+ nonstate_culture_consciousness = entry->get_nonstate_consciousness ();
1463+ }
1464+ if (entry->get_literacy ().has_value ()) {
1465+ state_culture_literacy = *entry->get_literacy ();
1466+ }
1467+ if (entry->get_nonstate_culture_literacy ().has_value ()) {
1468+ nonstate_culture_literacy = entry->get_nonstate_culture_literacy ();
1469+ }
14571470 } else {
14581471 // All foreign investments are applied regardless of the bookmark's date
14591472 country_instance.apply_foreign_investments (entry->get_foreign_investment (), *this );
@@ -1465,6 +1478,28 @@ bool CountryInstanceManager::apply_history_to_countries(InstanceManager& instanc
14651478 map_instance, country_instance, *oob_history_entry->get_inital_oob ()
14661479 );
14671480 }
1481+
1482+ // TODO - check if better to do "if"s then "for"s, so looping multiple times rather than having lots of
1483+ // redundant "if" statements?
1484+ for (ProvinceInstance* province : country_instance.get_owned_provinces ()) {
1485+ for (Pop& pop : province->get_mutable_pops ()) {
1486+ if (country_instance.is_primary_or_accepted_culture (pop.get_culture ())) {
1487+ pop.set_literacy (state_culture_literacy);
1488+
1489+ if (state_culture_consciousness.has_value ()) {
1490+ pop.set_consciousness (*state_culture_consciousness);
1491+ }
1492+ } else {
1493+ if (nonstate_culture_literacy.has_value ()) {
1494+ pop.set_literacy (*nonstate_culture_literacy);
1495+ }
1496+
1497+ if (nonstate_culture_consciousness.has_value ()) {
1498+ pop.set_consciousness (*nonstate_culture_consciousness);
1499+ }
1500+ }
1501+ }
1502+ }
14681503 } else {
14691504 Logger::error (" Country " , country_instance.get_identifier (), " has no history!" );
14701505 ret = false ;
0 commit comments