aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/ProvinceInstance.cpp
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2024-09-22 20:44:08 +0200
committer wvpm <24685035+wvpm@users.noreply.github.com>2024-09-22 20:44:08 +0200
commit873229df9f38ff19eb23018fd522bb313e511085 (patch)
tree3fc318ff2c945e29c352864d0244c301344572de /src/openvic-simulation/map/ProvinceInstance.cpp
parent26cbbc7612ce2f42cfd44f099aa72898656691a7 (diff)
Refactored RGO into part of ProvinceInstance
Diffstat (limited to 'src/openvic-simulation/map/ProvinceInstance.cpp')
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index 98e8fcb..e8361da 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -1,4 +1,5 @@
#include "ProvinceInstance.hpp"
+#include <cstddef>
#include "openvic-simulation/country/CountryInstance.hpp"
#include "openvic-simulation/economy/production/ProductionType.hpp"
@@ -27,7 +28,7 @@ ProvinceInstance::ProvinceInstance(
cores {},
slave { false },
crime { nullptr },
- rgo { nullptr },
+ rgo { ResourceGatheringOperation {} },
buildings { "buildings", false },
armies {},
navies {},
@@ -40,15 +41,15 @@ ProvinceInstance::ProvinceInstance(
max_supported_regiments { 0 } {}
GoodDefinition const* ProvinceInstance::get_rgo_good() const {
- if(rgo == nullptr) { return nullptr; }
- return rgo->get_production_type()->get_output_good();
+ if(!rgo.is_valid()) { return nullptr; }
+ return rgo.get_production_type()->get_output_good();
}
void ProvinceInstance::set_rgo_production_type(ProductionType const& rgo_production_type) {
if(rgo_production_type.get_template_type() != ProductionType::template_type_t::RGO) {
//error
}
convert_rgo_worker_pops_to_equivalent(rgo_production_type);
- rgo->set_production_type(&rgo_production_type);
+ rgo.set_production_type(&rgo_production_type);
}
bool ProvinceInstance::set_owner(CountryInstance* new_owner) {
@@ -362,10 +363,8 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const& ent
void ProvinceInstance::setup_rgo(ProductionType const& rgo_production_type) {
convert_rgo_worker_pops_to_equivalent(rgo_production_type);
- rgo = new ResourceGatheringOperation {
- &rgo_production_type,
- calculate_rgo_size(rgo_production_type)
- };
+ rgo.set_size_multiplier(calculate_rgo_size(rgo_production_type));
+ rgo.set_production_type(&rgo_production_type);
}
void ProvinceInstance::setup_pop_test_values(IssueManager const& issue_manager) {