aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2024-11-03 22:23:39 +0100
committer wvpm <24685035+wvpm@users.noreply.github.com>2024-11-03 22:39:01 +0100
commit4eba08af501560e9139a562c53fbbc8b694fb4cf (patch)
treee9553d2f4ed09abb920921006b976c7ef4baa46c /src/openvic-simulation/map
parent19026ff6aee8748df4777ec044065d13460e806a (diff)
ModifierEffectCache & location to fieldsto_fields
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
-rw-r--r--src/openvic-simulation/map/State.cpp12
-rw-r--r--src/openvic-simulation/map/State.hpp6
6 files changed, 40 insertions, 30 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp
index 80aad5e..85ff042 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.initialise_rgo();
}
- state_manager.tick(today, modifier_effect_cache);
+ state_manager.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 5a3dda2..775dcad 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 {},
@@ -371,14 +373,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>
@@ -418,6 +417,8 @@ bool ProvinceInstance::setup(BuildingTypeManager const& building_type_manager) {
return false;
}
+ rgo.setup_location_ptr(*this);
+
bool ret = true;
if (!province_definition.is_water()) {
@@ -482,8 +483,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();
diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp
index a13c271..0987c50 100644
--- a/src/openvic-simulation/map/State.cpp
+++ b/src/openvic-simulation/map/State.cpp
@@ -98,9 +98,9 @@ void State::update_gamestate() {
industrial_power = total_factory_levels_in_state * workforce_scalar;
}
-void State::state_tick(const Date today, ModifierEffectCache const& modifier_effect_cache) {
+void State::state_tick(const Date today) {
for (ProvinceInstance* province : provinces) {
- province->province_tick(today, modifier_effect_cache);
+ province->province_tick(today);
}
}
@@ -126,9 +126,9 @@ void StateSet::update_gamestate() {
}
}
-void StateSet::tick(const Date today, ModifierEffectCache const& modifier_effect_cache) {
+void StateSet::tick(const Date today) {
for (State& state : states) {
- state.state_tick(today, modifier_effect_cache);
+ state.state_tick(today);
}
}
@@ -233,8 +233,8 @@ void StateManager::update_gamestate() {
}
}
-void StateManager::tick(const Date today, ModifierEffectCache const& modifier_effect_cache) {
+void StateManager::tick(const Date today) {
for (StateSet& state_set : state_sets) {
- state_set.tick(today, modifier_effect_cache);
+ state_set.tick(today);
}
} \ No newline at end of file
diff --git a/src/openvic-simulation/map/State.hpp b/src/openvic-simulation/map/State.hpp
index e1f5953..55cd9e7 100644
--- a/src/openvic-simulation/map/State.hpp
+++ b/src/openvic-simulation/map/State.hpp
@@ -49,7 +49,7 @@ namespace OpenVic {
std::string get_identifier() const;
void update_gamestate();
- void state_tick(const Date today, ModifierEffectCache const& modifier_effect_cache);
+ void state_tick(const Date today);
IndexedMap<PopType, std::vector<Pop*>>& get_mutable_pops_cache_by_type();
};
@@ -70,7 +70,7 @@ namespace OpenVic {
size_t get_state_count() const;
void update_gamestate();
- void tick(const Date today, ModifierEffectCache const& modifier_effect_cache);
+ void tick(const Date today);
};
struct MapInstance;
@@ -94,6 +94,6 @@ namespace OpenVic {
void reset();
void update_gamestate();
- void tick(const Date today, ModifierEffectCache const& modifier_effect_cache);
+ void tick(const Date today);
};
}