aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2024-09-22 14:24:52 +0200
committer wvpm <24685035+wvpm@users.noreply.github.com>2024-09-22 14:24:52 +0200
commita8d1e28de1dab36a407ea540e2d1393bc2478d15 (patch)
tree4386bf94d5cfe047b2863e48925805d78a2b6040 /src/openvic-simulation/map
parent5a819de3019f8497dddae8e76d01f48cf8a86adb (diff)
Link trade_goods in history to RGO instance for province.
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp43
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp12
2 files changed, 29 insertions, 26 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());
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index 9899a16..5863a97 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -12,6 +12,7 @@
#include "openvic-simulation/types/HasIdentifier.hpp"
#include "openvic-simulation/types/OrderedContainers.hpp"
#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp"
+#include "economy/production/ResourceGatheringOperation.hpp"
namespace OpenVic {
@@ -74,7 +75,7 @@ namespace OpenVic {
bool PROPERTY(slave);
Crime const* PROPERTY_RW(crime);
- ProductionType const* PROPERTY_RW_ACCESS(rgo_production_type, public);
+ ResourceGatheringOperation* PROPERTY(rgo);
IdentifierRegistry<BuildingInstance> IDENTIFIER_REGISTRY(building);
ordered_set<ArmyInstance*> PROPERTY(armies);
ordered_set<NavyInstance*> PROPERTY(navies);
@@ -115,13 +116,8 @@ namespace OpenVic {
return controller;
}
- GoodDefinition const* get_rgo_good() const {
- GoodDefinition const* rgo_good { nullptr };
- if(rgo_production_type != nullptr) {
- rgo_good = rgo_production_type->get_output_good();
- }
- return rgo_good;
- }
+ GoodDefinition const* get_rgo_good() const;
+ void set_rgo_production_type(ProductionType const& production_type);
bool set_owner(CountryInstance* new_owner);
bool set_controller(CountryInstance* new_controller);