aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2024-10-31 20:44:49 +0100
committer GitHub <noreply@github.com>2024-10-31 20:44:49 +0100
commitc6f7c8047abbe0a91b2a88365eee2259d8a91a65 (patch)
treec8c1c67b0006c65541b4f9d8897e8b9137f5346c
parentc763a0aedd834432b54b6e49c6bc7e1936be1131 (diff)
parent2cebd422b1f34d5f82e0576afcf786c9b5c57271 (diff)
Merge pull request #221 from OpenVicProject/correct_rgo_size
Correct rgo size calcuation
-rw-r--r--src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp12
-rw-r--r--src/openvic-simulation/modifier/ModifierEffectCache.cpp2
-rw-r--r--src/openvic-simulation/modifier/ModifierEffectCache.hpp2
-rw-r--r--src/openvic-simulation/modifier/ModifierManager.cpp12
4 files changed, 24 insertions, 4 deletions
diff --git a/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp b/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
index df91645..70cb64d 100644
--- a/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
+++ b/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
@@ -83,12 +83,20 @@ Pop::pop_size_t ResourceGatheringOperation::update_size_and_return_total_worker_
}
}
}
+
+ fixed_point_t base_size_modifier = fixed_point_t::_1();
+ if (production_type.is_farm()) {
+ base_size_modifier += location.get_modifier_effect_value_nullcheck(modifier_effect_cache.get_farm_rgo_size_local());
+ }
+ if (production_type.is_mine()) {
+ base_size_modifier += location.get_modifier_effect_value_nullcheck(modifier_effect_cache.get_mine_rgo_size_local());
+ }
const fixed_point_t base_workforce_size = production_type.get_base_workforce_size();
- if (size_modifier == fixed_point_t::_0()) {
+ if (base_size_modifier == fixed_point_t::_0()) {
size_multiplier = 0;
} else {
- size_multiplier = ((total_worker_count_in_province / (size_modifier * base_workforce_size)).ceil() * fixed_point_t::_1_50()).floor();
+ size_multiplier = ((total_worker_count_in_province / (base_size_modifier * base_workforce_size)).ceil() * fixed_point_t::_1_50()).floor();
}
max_employee_count_cache = (size_modifier * size_multiplier * base_workforce_size).floor();
return total_worker_count_in_province;
diff --git a/src/openvic-simulation/modifier/ModifierEffectCache.cpp b/src/openvic-simulation/modifier/ModifierEffectCache.cpp
index afb733a..a02dcb6 100644
--- a/src/openvic-simulation/modifier/ModifierEffectCache.cpp
+++ b/src/openvic-simulation/modifier/ModifierEffectCache.cpp
@@ -181,6 +181,7 @@ ModifierEffectCache::ModifierEffectCache()
farm_rgo_throughput_global { nullptr },
farm_rgo_output_global { nullptr },
farm_rgo_output_local { nullptr },
+ farm_rgo_size_fake { nullptr },
farm_rgo_size_global { nullptr },
farm_rgo_size_local { nullptr },
immigrant_attract { nullptr },
@@ -202,6 +203,7 @@ ModifierEffectCache::ModifierEffectCache()
mine_rgo_throughput_global { nullptr },
mine_rgo_output_global { nullptr },
mine_rgo_output_local { nullptr },
+ mine_rgo_size_fake { nullptr },
mine_rgo_size_global { nullptr },
mine_rgo_size_local { nullptr },
movement_cost_base { nullptr },
diff --git a/src/openvic-simulation/modifier/ModifierEffectCache.hpp b/src/openvic-simulation/modifier/ModifierEffectCache.hpp
index 757eca0..7d08d29 100644
--- a/src/openvic-simulation/modifier/ModifierEffectCache.hpp
+++ b/src/openvic-simulation/modifier/ModifierEffectCache.hpp
@@ -151,6 +151,7 @@ namespace OpenVic {
ModifierEffect const* PROPERTY(farm_rgo_throughput_global);
ModifierEffect const* PROPERTY(farm_rgo_output_global);
ModifierEffect const* PROPERTY(farm_rgo_output_local);
+ ModifierEffect const* PROPERTY(farm_rgo_size_fake);
ModifierEffect const* PROPERTY(farm_rgo_size_global);
ModifierEffect const* PROPERTY(farm_rgo_size_local);
ModifierEffect const* PROPERTY(immigrant_attract);
@@ -172,6 +173,7 @@ namespace OpenVic {
ModifierEffect const* PROPERTY(mine_rgo_throughput_global);
ModifierEffect const* PROPERTY(mine_rgo_output_global);
ModifierEffect const* PROPERTY(mine_rgo_output_local);
+ ModifierEffect const* PROPERTY(mine_rgo_size_fake);
ModifierEffect const* PROPERTY(mine_rgo_size_global);
ModifierEffect const* PROPERTY(mine_rgo_size_local);
ModifierEffect const* PROPERTY(movement_cost_base);
diff --git a/src/openvic-simulation/modifier/ModifierManager.cpp b/src/openvic-simulation/modifier/ModifierManager.cpp
index a5ef8a8..ea2e0fd 100644
--- a/src/openvic-simulation/modifier/ModifierManager.cpp
+++ b/src/openvic-simulation/modifier/ModifierManager.cpp
@@ -428,7 +428,11 @@ bool ModifierManager::setup_modifier_effects() {
ret &= register_base_province_modifier_effect(
modifier_effect_cache.farm_rgo_output_local, "farm_rgo_eff", true, PROPORTION_DECIMAL, "TECH_FARM_OUTPUT"
);
- ret &= register_shared_tech_country_modifier_effect(
+ ret &= register_base_country_modifier_effect(
+ modifier_effect_cache.farm_rgo_size_fake, "farm_rgo_size", true, PROPORTION_DECIMAL,
+ ModifierEffect::make_default_modifier_effect_localisation_key("farm_size"), has_no_effect
+ );
+ ret &= register_technology_modifier_effect(
modifier_effect_cache.farm_rgo_size_global, "farm_rgo_size", true, PROPORTION_DECIMAL,
ModifierEffect::make_default_modifier_effect_localisation_key("farm_size")
);
@@ -499,7 +503,11 @@ bool ModifierManager::setup_modifier_effects() {
ret &= register_base_province_modifier_effect(
modifier_effect_cache.mine_rgo_output_local, "mine_rgo_eff", true, PROPORTION_DECIMAL, "TECH_MINE_OUTPUT"
);
- ret &= register_shared_tech_country_modifier_effect(
+ ret &= register_base_country_modifier_effect(
+ modifier_effect_cache.mine_rgo_size_fake, "mine_rgo_size", true, PROPORTION_DECIMAL,
+ ModifierEffect::make_default_modifier_effect_localisation_key("mine_size"), has_no_effect
+ );
+ ret &= register_technology_modifier_effect(
modifier_effect_cache.mine_rgo_size_global, "mine_rgo_size", true, PROPORTION_DECIMAL,
ModifierEffect::make_default_modifier_effect_localisation_key("mine_size")
);