aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/MapInstance.cpp4
-rw-r--r--src/openvic-simulation/map/MapInstance.hpp2
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp29
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp6
-rw-r--r--src/openvic-simulation/map/State.cpp6
-rw-r--r--src/openvic-simulation/map/State.hpp2
6 files changed, 38 insertions, 11 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp
index ea174eb..0ce8cea 100644
--- a/src/openvic-simulation/map/MapInstance.cpp
+++ b/src/openvic-simulation/map/MapInstance.cpp
@@ -118,9 +118,9 @@ bool MapInstance::apply_history_to_provinces(
return ret;
}
-void MapInstance::update_gamestate(Date today) {
+void MapInstance::update_gamestate(Date today, DefineManager const& define_manager) {
for (ProvinceInstance& province : province_instances.get_items()) {
- province.update_gamestate(today);
+ province.update_gamestate(today, define_manager);
}
state_manager.update_gamestate();
diff --git a/src/openvic-simulation/map/MapInstance.hpp b/src/openvic-simulation/map/MapInstance.hpp
index d2d9a26..99c13d3 100644
--- a/src/openvic-simulation/map/MapInstance.hpp
+++ b/src/openvic-simulation/map/MapInstance.hpp
@@ -52,7 +52,7 @@ namespace OpenVic {
IssueManager const& issue_manager
);
- void update_gamestate(Date today);
+ void update_gamestate(Date today, DefineManager const& define_manager);
void tick(Date today);
};
}
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index f95ee21..06b3f1e 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -4,6 +4,7 @@
#include "openvic-simulation/history/ProvinceHistory.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
#include "openvic-simulation/military/UnitInstanceGroup.hpp"
+#include "openvic-simulation/misc/Define.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
using namespace OpenVic;
@@ -31,7 +32,8 @@ ProvinceInstance::ProvinceInstance(
pop_type_distribution { &pop_type_keys },
ideology_distribution { &ideology_keys },
culture_distribution {},
- religion_distribution {} {}
+ religion_distribution {},
+ max_supported_regiments { 0 } {}
bool ProvinceInstance::set_owner(CountryInstance* new_owner) {
bool ret = true;
@@ -92,6 +94,10 @@ bool ProvinceInstance::remove_core(CountryInstance& core_to_remove) {
}
}
+bool ProvinceInstance::is_owner_core() const {
+ return owner != nullptr && cores.contains(owner);
+}
+
bool ProvinceInstance::expand_building(size_t building_index) {
BuildingInstance* building = buildings.get_item_by_index(building_index);
if (building == nullptr) {
@@ -136,7 +142,7 @@ size_t ProvinceInstance::get_pop_count() const {
/* REQUIREMENTS:
* MAP-65, MAP-68, MAP-70, MAP-234
*/
-void ProvinceInstance::_update_pops() {
+void ProvinceInstance::_update_pops(DefineManager const& define_manager) {
total_population = 0;
average_literacy = 0;
average_consciousness = 0;
@@ -147,7 +153,18 @@ void ProvinceInstance::_update_pops() {
culture_distribution.clear();
religion_distribution.clear();
- for (Pop const& pop : pops) {
+ max_supported_regiments = 0;
+
+ using enum colony_status_t;
+
+ const fixed_point_t pop_size_per_regiment_multiplier =
+ colony_status == PROTECTORATE ? define_manager.get_pop_size_per_regiment_protectorate_multiplier()
+ : colony_status == COLONY ? define_manager.get_pop_size_per_regiment_colony_multiplier()
+ : is_owner_core() ? fixed_point_t::_1() : define_manager.get_pop_size_per_regiment_non_core_multiplier();
+
+ for (Pop& pop : pops) {
+ pop.update_gamestate(define_manager, owner, pop_size_per_regiment_multiplier);
+
total_population += pop.get_size();
average_literacy += pop.get_literacy();
average_consciousness += pop.get_consciousness();
@@ -157,6 +174,8 @@ void ProvinceInstance::_update_pops() {
ideology_distribution += pop.get_ideologies();
culture_distribution[&pop.get_culture()] += pop.get_size();
religion_distribution[&pop.get_religion()] += pop.get_size();
+
+ max_supported_regiments += pop.get_max_supported_regiments();
}
if (total_population > 0) {
@@ -166,11 +185,11 @@ void ProvinceInstance::_update_pops() {
}
}
-void ProvinceInstance::update_gamestate(Date today) {
+void ProvinceInstance::update_gamestate(Date today, DefineManager const& define_manager) {
for (BuildingInstance& building : buildings.get_items()) {
building.update_gamestate(today);
}
- _update_pops();
+ _update_pops(define_manager);
}
void ProvinceInstance::tick(Date today) {
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index 7ba35cd..fa0be98 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -88,6 +88,7 @@ namespace OpenVic {
IndexedMap<Ideology, fixed_point_t> PROPERTY(ideology_distribution);
fixed_point_map_t<Culture const*> PROPERTY(culture_distribution);
fixed_point_map_t<Religion const*> PROPERTY(religion_distribution);
+ size_t PROPERTY(max_supported_regiments);
ProvinceInstance(
ProvinceDefinition const& new_province_definition, decltype(pop_type_distribution)::keys_t const& pop_type_keys,
@@ -95,7 +96,7 @@ namespace OpenVic {
);
void _add_pop(Pop&& pop);
- void _update_pops();
+ void _update_pops(DefineManager const& define_manager);
public:
ProvinceInstance(ProvinceInstance&&) = default;
@@ -115,6 +116,7 @@ namespace OpenVic {
bool set_controller(CountryInstance* new_controller);
bool add_core(CountryInstance& new_core);
bool remove_core(CountryInstance& core_to_remove);
+ bool is_owner_core() const;
bool expand_building(size_t building_index);
@@ -122,7 +124,7 @@ namespace OpenVic {
bool add_pop_vec(std::vector<PopBase> const& pop_vec);
size_t get_pop_count() const;
- void update_gamestate(Date today);
+ void update_gamestate(Date today, DefineManager const& define_manager);
void tick(Date today);
template<UnitType::branch_t Branch>
diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp
index 90cbace..020b6f1 100644
--- a/src/openvic-simulation/map/State.cpp
+++ b/src/openvic-simulation/map/State.cpp
@@ -22,7 +22,8 @@ State::State(
provinces { std::move(new_provinces) },
colony_status { new_colony_status },
pop_type_distribution { &pop_type_keys },
- industrial_power { 0 } {}
+ industrial_power { 0 },
+ max_supported_regiments { 0 } {}
std::string State::get_identifier() const {
return StringUtils::append_string_views(
@@ -37,6 +38,7 @@ void State::update_gamestate() {
average_consciousness = 0;
average_militancy = 0;
pop_type_distribution.clear();
+ max_supported_regiments = 0;
for (ProvinceInstance const* province : provinces) {
total_population += province->get_total_population();
@@ -48,6 +50,8 @@ void State::update_gamestate() {
average_militancy += province->get_average_militancy() * province_population;
pop_type_distribution += province->get_pop_type_distribution();
+
+ max_supported_regiments += province->get_max_supported_regiments();
}
if (total_population > 0) {
diff --git a/src/openvic-simulation/map/State.hpp b/src/openvic-simulation/map/State.hpp
index 6035e10..596206a 100644
--- a/src/openvic-simulation/map/State.hpp
+++ b/src/openvic-simulation/map/State.hpp
@@ -33,6 +33,8 @@ namespace OpenVic {
fixed_point_t PROPERTY(industrial_power);
+ size_t PROPERTY(max_supported_regiments);
+
State(
StateSet const& new_state_set,
CountryInstance* new_owner,