aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/history')
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.cpp17
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.hpp2
2 files changed, 17 insertions, 2 deletions
diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp
index ef8793b..7d3d6eb 100644
--- a/src/openvic-simulation/history/ProvinceHistory.cpp
+++ b/src/openvic-simulation/history/ProvinceHistory.cpp
@@ -1,7 +1,10 @@
#include "ProvinceHistory.hpp"
#include "openvic-simulation/DefinitionManager.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
+#include "dataloader/NodeTools.hpp"
+#include "types/IdentifierRegistry.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -57,6 +60,9 @@ bool ProvinceHistoryMap::_load_history_entry(
};
};
+ constexpr bool allow_empty_true = true;
+ constexpr bool do_warn = true;
+
return expect_dictionary_keys_and_default(
[this, &definition_manager, &building_type_manager, &entry](
std::string_view key, ast::NodeCPtr value) -> bool {
@@ -98,7 +104,16 @@ bool ProvinceHistoryMap::_load_history_entry(
expect_identifier(expect_mapped_string(colony_status_map, assign_variable_callback(entry.colonial))),
"is_slave", ZERO_OR_ONE, expect_bool(assign_variable_callback(entry.slave)),
"trade_goods", ZERO_OR_ONE,
- good_definition_manager.expect_good_definition_identifier(assign_variable_callback_pointer_opt(entry.rgo)),
+ good_definition_manager.expect_good_definition_identifier_or_string(
+ [&definition_manager, &entry](GoodDefinition const& rgo_good) ->bool {
+ entry.rgo_production_type = definition_manager.get_economy_manager().get_production_type_manager().get_good_to_rgo_production_type()[rgo_good];
+ return entry.rgo_production_type != nullptr;
+ //we expect the good to have an rgo production type
+ //Victoria 2 treats this as null, but clearly the modder wanted there to be a good
+ },
+ allow_empty_true, //could be explicitly setting trade_goods to null
+ do_warn //could be typo in good identifier
+ ),
"life_rating", ZERO_OR_ONE, expect_uint<ProvinceInstance::life_rating_t>(assign_variable_callback(entry.life_rating)),
"terrain", ZERO_OR_ONE, terrain_type_manager.expect_terrain_type_identifier(
assign_variable_callback_pointer_opt(entry.terrain_type)
diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp
index 99ea2af..db6b57f 100644
--- a/src/openvic-simulation/history/ProvinceHistory.hpp
+++ b/src/openvic-simulation/history/ProvinceHistory.hpp
@@ -32,7 +32,7 @@ namespace OpenVic {
std::optional<ProvinceInstance::colony_status_t> PROPERTY(colonial);
std::optional<bool> PROPERTY(slave);
ordered_map<CountryDefinition const*, bool> PROPERTY(cores);
- std::optional<GoodDefinition const*> PROPERTY(rgo);
+ ProductionType const* PROPERTY(rgo_production_type);
std::optional<ProvinceInstance::life_rating_t> PROPERTY(life_rating);
std::optional<TerrainType const*> PROPERTY(terrain_type);
ordered_map<BuildingType const*, BuildingType::level_t> PROPERTY(province_buildings);