@@ -1420,7 +1420,15 @@ fixed_point_t CountryInstance::get_modifier_effect_value(ModifierEffect const& e
1420
1420
}
1421
1421
1422
1422
void CountryInstance::update_gamestate (InstanceManager& instance_manager) {
1423
- if (!is_civilised ()) {
1423
+ DefinitionManager const & definition_manager = instance_manager.get_definition_manager ();
1424
+ DefineManager const & define_manager = definition_manager.get_define_manager ();
1425
+ ModifierEffectCache const & modifier_effect_cache = definition_manager.get_modifier_manager ().get_modifier_effect_cache ();
1426
+
1427
+ if (is_civilised ()) {
1428
+ civilisation_progress = fixed_point_t::_0 ();
1429
+ } else {
1430
+ civilisation_progress = get_modifier_effect_value (*modifier_effect_cache.get_civilization_progress_modifier ());
1431
+
1424
1432
if (civilisation_progress <= PRIMITIVE_CIVILISATION_PROGRESS) {
1425
1433
country_status = COUNTRY_STATUS_PRIMITIVE;
1426
1434
} else if (civilisation_progress <= UNCIVILISED_CIVILISATION_PROGRESS) {
@@ -1449,10 +1457,6 @@ void CountryInstance::update_gamestate(InstanceManager& instance_manager) {
1449
1457
}
1450
1458
}
1451
1459
1452
- DefinitionManager const & definition_manager = instance_manager.get_definition_manager ();
1453
- DefineManager const & define_manager = definition_manager.get_define_manager ();
1454
- ModifierEffectCache const & modifier_effect_cache = definition_manager.get_modifier_manager ().get_modifier_effect_cache ();
1455
-
1456
1460
// Order of updates might need to be changed/functions split up to account for dependencies
1457
1461
// Updates population stats (including research and leadership points from pops)
1458
1462
_update_population ();
@@ -1499,7 +1503,7 @@ void CountryInstance::country_reset_before_tick() {
1499
1503
for (auto pair : goods_data) {
1500
1504
pair.second .clear_daily_recorded_data ();
1501
1505
}
1502
-
1506
+
1503
1507
taxable_income_by_pop_type.fill (fixed_point_t::_0 ());
1504
1508
}
1505
1509
@@ -1704,19 +1708,26 @@ void CountryInstanceManager::update_rankings(Date today, DefineManager const& de
1704
1708
// Demote great powers who have been below the max great power rank for longer than the demotion grace period and
1705
1709
// remove them from the list. We don't just demote them all and clear the list as when rebuilding we'd need to look
1706
1710
// ahead for countries below the max great power rank but still within the demotion grace period.
1707
- for (CountryInstance* great_power : great_powers) {
1708
- if (great_power->get_total_rank () > max_great_power_rank && great_power->get_lose_great_power_date () < today) {
1709
- great_power->country_status = COUNTRY_STATUS_CIVILISED;
1711
+ std::erase_if (great_powers, [max_great_power_rank, today](CountryInstance* great_power) -> bool {
1712
+ if (OV_likely (great_power->get_country_status () == COUNTRY_STATUS_GREAT_POWER)) {
1713
+ if (OV_unlikely (
1714
+ great_power->get_total_rank () > max_great_power_rank && great_power->get_lose_great_power_date () < today
1715
+ )) {
1716
+ great_power->country_status = COUNTRY_STATUS_CIVILISED;
1717
+ return true ;
1718
+ } else {
1719
+ return false ;
1720
+ }
1710
1721
}
1711
- }
1712
- std::erase_if (great_powers, [](CountryInstance const * country) -> bool {
1713
- return country->get_country_status () != COUNTRY_STATUS_GREAT_POWER;
1722
+ return true ;
1714
1723
});
1715
1724
1716
1725
// Demote all secondary powers and clear the list. We will rebuilt the whole list from scratch, so there's no need to
1717
1726
// keep countries which are still above the max secondary power rank (they might become great powers instead anyway).
1718
1727
for (CountryInstance* secondary_power : secondary_powers) {
1719
- secondary_power->country_status = COUNTRY_STATUS_CIVILISED;
1728
+ if (secondary_power->country_status == COUNTRY_STATUS_SECONDARY_POWER) {
1729
+ secondary_power->country_status = COUNTRY_STATUS_CIVILISED;
1730
+ }
1720
1731
}
1721
1732
secondary_powers.clear ();
1722
1733
@@ -1845,7 +1856,11 @@ bool CountryInstanceManager::apply_history_to_countries(InstanceManager& instanc
1845
1856
UnitInstanceManager& unit_instance_manager = instance_manager.get_unit_instance_manager ();
1846
1857
MapInstance& map_instance = instance_manager.get_map_instance ();
1847
1858
1859
+ const Date starting_last_war_loss_date = today - RECENT_TIME_LIMIT;
1860
+
1848
1861
for (CountryInstance& country_instance : country_instances.get_items ()) {
1862
+ country_instance.last_war_loss_date = starting_last_war_loss_date;
1863
+
1849
1864
if (!country_instance.get_country_definition ()->is_dynamic_tag ()) {
1850
1865
CountryHistoryMap const * history_map =
1851
1866
history_manager.get_country_history (country_instance.get_country_definition ());
@@ -1931,6 +1946,10 @@ void CountryInstanceManager::update_gamestate(InstanceManager& instance_manager)
1931
1946
country.update_gamestate (instance_manager);
1932
1947
}
1933
1948
1949
+ // TODO - work out how to have ranking effects applied (e.g. static modifiers) applied at game start
1950
+ // we can't just move update_rankings to the top of this function as it will choose initial GPs based on
1951
+ // incomplete scores. Although we should check if the base game includes all info or if it really does choose
1952
+ // starting GPs based purely on stuff like prestige which is set by history before the first game update.
1934
1953
update_rankings (instance_manager.get_today (), instance_manager.get_definition_manager ().get_define_manager ());
1935
1954
}
1936
1955
0 commit comments