aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history/ProvinceHistory.cpp
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/history/ProvinceHistory.cpp
parent5a819de3019f8497dddae8e76d01f48cf8a86adb (diff)
Link trade_goods in history to RGO instance for province.
Diffstat (limited to 'src/openvic-simulation/history/ProvinceHistory.cpp')
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.cpp17
1 files changed, 16 insertions, 1 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)