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.cpp19
-rw-r--r--src/openvic-simulation/map/MapInstance.hpp5
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp19
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp9
4 files changed, 31 insertions, 21 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp
index 240bec5..860ec10 100644
--- a/src/openvic-simulation/map/MapInstance.cpp
+++ b/src/openvic-simulation/map/MapInstance.cpp
@@ -43,6 +43,7 @@ ProvinceDefinition::index_t MapInstance::get_selected_province_index() const {
bool MapInstance::setup(
BuildingTypeManager const& building_type_manager,
+ ModifierEffectCache const& modifier_effect_cache,
decltype(ProvinceInstance::pop_type_distribution)::keys_t const& pop_type_keys,
decltype(ProvinceInstance::ideology_distribution)::keys_t const& ideology_keys
) {
@@ -60,7 +61,12 @@ bool MapInstance::setup(
province_instances.reserve(map_definition.get_province_definition_count());
for (ProvinceDefinition const& province : map_definition.get_province_definitions()) {
- ret &= province_instances.add_item({ province, pop_type_keys, ideology_keys });
+ ret &= province_instances.add_item({
+ modifier_effect_cache,
+ province,
+ pop_type_keys,
+ ideology_keys
+ });
}
province_instances.lock();
@@ -152,20 +158,19 @@ void MapInstance::update_gamestate(const Date today, DefineManager const& define
state_manager.update_gamestate();
}
-void MapInstance::map_tick(const Date today, ModifierEffectCache const& modifier_effect_cache) {
+void MapInstance::map_tick(const Date today) {
for (ProvinceInstance& province : province_instances.get_items()) {
- province.province_tick(today, modifier_effect_cache);
+ province.province_tick(today);
}
}
void MapInstance::initialise_for_new_game(
const Date today,
- DefineManager const& define_manager,
- ModifierEffectCache const& modifier_effect_cache
+ DefineManager const& define_manager
) {
update_gamestate(today, define_manager);
for (ProvinceInstance& province : province_instances.get_items()) {
- province.initialise_rgo(modifier_effect_cache);
- province.province_tick(today, modifier_effect_cache);
+ province.initialise_rgo();
+ province.province_tick(today);
}
} \ No newline at end of file
diff --git a/src/openvic-simulation/map/MapInstance.hpp b/src/openvic-simulation/map/MapInstance.hpp
index 1ca28d2..a498061 100644
--- a/src/openvic-simulation/map/MapInstance.hpp
+++ b/src/openvic-simulation/map/MapInstance.hpp
@@ -44,6 +44,7 @@ namespace OpenVic {
bool setup(
BuildingTypeManager const& building_type_manager,
+ ModifierEffectCache const& modifier_effect_cache,
decltype(ProvinceInstance::pop_type_distribution)::keys_t const& pop_type_keys,
decltype(ProvinceInstance::ideology_distribution)::keys_t const& ideology_keys
);
@@ -54,7 +55,7 @@ namespace OpenVic {
void update_modifier_sums(const Date today, StaticModifierCache const& static_modifier_cache);
void update_gamestate(const Date today, DefineManager const& define_manager);
- void map_tick(const Date today, ModifierEffectCache const& modifier_effect_cache);
- void initialise_for_new_game(const Date today, DefineManager const& define_manager, ModifierEffectCache const& modifier_effect_cache);
+ void map_tick(const Date today);
+ void initialise_for_new_game(const Date today, DefineManager const& define_manager);
};
}
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index 2c4479e..b5cca55 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -18,7 +18,9 @@
using namespace OpenVic;
ProvinceInstance::ProvinceInstance(
- ProvinceDefinition const& new_province_definition, decltype(pop_type_distribution)::keys_t const& pop_type_keys,
+ ModifierEffectCache const& new_modifier_effect_cache,
+ ProvinceDefinition const& new_province_definition,
+ decltype(pop_type_distribution)::keys_t const& pop_type_keys,
decltype(ideology_distribution)::keys_t const& ideology_keys
) : HasIdentifierAndColour { new_province_definition },
province_definition { new_province_definition },
@@ -33,7 +35,7 @@ ProvinceInstance::ProvinceInstance(
event_modifiers {},
slave { false },
crime { nullptr },
- rgo { pop_type_keys },
+ rgo { new_modifier_effect_cache, pop_type_keys },
buildings { "buildings", false },
armies {},
navies {},
@@ -368,14 +370,11 @@ void ProvinceInstance::update_gamestate(const Date today, DefineManager const& d
_update_pops(define_manager);
}
-void ProvinceInstance::province_tick(const Date today, ModifierEffectCache const& modifier_effect_cache) {
+void ProvinceInstance::province_tick(const Date today) {
for (BuildingInstance& building : buildings.get_items()) {
building.tick(today);
}
- rgo.rgo_tick(
- *this,
- modifier_effect_cache
- );
+ rgo.rgo_tick();
}
template<UnitType::branch_t Branch>
@@ -415,6 +414,8 @@ bool ProvinceInstance::setup(BuildingTypeManager const& building_type_manager) {
return false;
}
+ rgo.setup_location_ptr(*this);
+
bool ret = true;
if (!province_definition.is_water()) {
@@ -479,8 +480,8 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const& ent
return ret;
}
-void ProvinceInstance::initialise_rgo(ModifierEffectCache const& modifier_effect_cache) {
- rgo.initialise_rgo_size_multiplier(*this, modifier_effect_cache);
+void ProvinceInstance::initialise_rgo() {
+ rgo.initialise_rgo_size_multiplier();
}
void ProvinceInstance::setup_pop_test_values(IssueManager const& issue_manager) {
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index ec83af4..997d025 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -7,6 +7,7 @@
#include "openvic-simulation/economy/production/ResourceGatheringOperation.hpp"
#include "openvic-simulation/military/UnitInstance.hpp"
#include "openvic-simulation/military/UnitType.hpp"
+#include "openvic-simulation/modifier/ModifierEffectCache.hpp"
#include "openvic-simulation/modifier/ModifierSum.hpp"
#include "openvic-simulation/pop/Pop.hpp"
#include "openvic-simulation/types/HasIdentifier.hpp"
@@ -103,7 +104,9 @@ namespace OpenVic {
size_t PROPERTY(max_supported_regiments);
ProvinceInstance(
- ProvinceDefinition const& new_province_definition, decltype(pop_type_distribution)::keys_t const& pop_type_keys,
+ ModifierEffectCache const& new_modifier_effect_cache,
+ ProvinceDefinition const& new_province_definition,
+ decltype(pop_type_distribution)::keys_t const& pop_type_keys,
decltype(ideology_distribution)::keys_t const& ideology_keys
);
@@ -150,7 +153,7 @@ namespace OpenVic {
std::vector<ModifierSum::modifier_entry_t> get_contributing_modifiers(ModifierEffect const& effect) const;
void update_gamestate(const Date today, DefineManager const& define_manager);
- void province_tick(const Date today, ModifierEffectCache const& modifier_effect_cache);
+ void province_tick(const Date today);
template<UnitType::branch_t Branch>
bool add_unit_instance_group(UnitInstanceGroup<Branch>& group);
@@ -160,7 +163,7 @@ namespace OpenVic {
bool setup(BuildingTypeManager const& building_type_manager);
bool apply_history_to_province(ProvinceHistoryEntry const& entry, CountryInstanceManager& country_manager);
- void initialise_rgo(ModifierEffectCache const& modifier_effect_cache);
+ void initialise_rgo();
void setup_pop_test_values(IssueManager const& issue_manager);
State* get_mutable_state();