aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/ProvinceInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map/ProvinceInstance.cpp')
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index 1d69fec..d35c44e 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -1,13 +1,14 @@
#include "ProvinceInstance.hpp"
#include "openvic-simulation/country/CountryInstance.hpp"
-#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/economy/production/ProductionType.hpp"
#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"
+#include "economy/production/ResourceGatheringOperation.hpp"
+#include "types/fixed_point/FixedPoint.hpp"
using namespace OpenVic;
@@ -25,7 +26,7 @@ ProvinceInstance::ProvinceInstance(
cores {},
slave { false },
crime { nullptr },
- rgo_production_type { nullptr },
+ rgo { nullptr },
buildings { "buildings", false },
armies {},
navies {},
@@ -37,6 +38,21 @@ ProvinceInstance::ProvinceInstance(
religion_distribution {},
max_supported_regiments { 0 } {}
+ GoodDefinition const* ProvinceInstance::get_rgo_good() const {
+ if(rgo == nullptr) { return nullptr; }
+ return rgo->get_production_type()->get_output_good();
+ }
+ void ProvinceInstance::set_rgo_production_type(ProductionType const& production_type) {
+ if(production_type.get_template_type() != ProductionType::template_type_t::RGO) {
+ //error
+ }
+
+ //recalculate rgo size?
+ //convert pops farmers <> labourers
+
+ rgo->set_production_type(&production_type);
+ }
+
bool ProvinceInstance::set_owner(CountryInstance* new_owner) {
bool ret = true;
@@ -282,23 +298,14 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const& ent
}
}
- auto const& rgo_good_optional = entry.get_rgo();
- if(rgo_good_optional.has_value()) {
- GoodDefinition const* const rgo_good = rgo_good_optional.value();
- if(rgo_good != nullptr) {
- IndexedMap<GoodDefinition, ProductionType const*> const& good_to_rgo_production_type = production_type_manager.get_good_to_rgo_production_type();
- ProductionType const* rgo_production_type = good_to_rgo_production_type[*rgo_good];
- if(rgo_production_type!= nullptr) {
- set_rgo_production_type(rgo_production_type);
- }
- else {
- //error we expect the good to have an rgo production type but there is none
- //Victoria 2 treats this as null, but clearly the modder wanted there to be a good
- }
- }
- //else explicitly set null, no-op
+ ProductionType const* const rgo_production_type = entry.get_rgo_production_type();
+ if(rgo_production_type != nullptr) {
+ constexpr fixed_point_t size_multiplier = fixed_point_t::_1();
+ rgo = new ResourceGatheringOperation {
+ rgo_production_type,
+ size_multiplier
+ };
}
- //else default null, no-op
set_optional(life_rating, entry.get_life_rating());
set_optional(terrain_type, entry.get_terrain_type());