aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/GameManager.cpp4
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp16
-rw-r--r--src/openvic-simulation/economy/ArtisanalProducer.cpp13
-rw-r--r--src/openvic-simulation/economy/ArtisanalProducer.hpp12
-rw-r--r--src/openvic-simulation/economy/BuildingInstance.cpp9
-rw-r--r--src/openvic-simulation/economy/BuildingType.cpp53
-rw-r--r--src/openvic-simulation/economy/BuildingType.hpp8
-rw-r--r--src/openvic-simulation/economy/EconomyManager.hpp16
-rw-r--r--src/openvic-simulation/economy/FactoryProducer.cpp55
-rw-r--r--src/openvic-simulation/economy/FactoryProducer.hpp32
-rw-r--r--src/openvic-simulation/economy/GoodDefinition.cpp (renamed from src/openvic-simulation/economy/Good.cpp)43
-rw-r--r--src/openvic-simulation/economy/GoodDefinition.hpp (renamed from src/openvic-simulation/economy/Good.hpp)27
-rw-r--r--src/openvic-simulation/economy/GoodInstance.cpp20
-rw-r--r--src/openvic-simulation/economy/GoodInstance.hpp33
-rw-r--r--src/openvic-simulation/economy/ProductionType.cpp72
-rw-r--r--src/openvic-simulation/economy/ProductionType.hpp30
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.cpp5
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.hpp4
-rw-r--r--src/openvic-simulation/map/Mapmode.cpp10
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp26
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp6
-rw-r--r--src/openvic-simulation/military/UnitType.cpp12
-rw-r--r--src/openvic-simulation/military/UnitType.hpp10
-rw-r--r--src/openvic-simulation/politics/NationalFocus.cpp71
-rw-r--r--src/openvic-simulation/politics/NationalFocus.hpp6
-rw-r--r--src/openvic-simulation/politics/PoliticsManager.hpp6
-rw-r--r--src/openvic-simulation/pop/Pop.cpp26
-rw-r--r--src/openvic-simulation/pop/Pop.hpp24
-rw-r--r--src/openvic-simulation/scripts/Condition.cpp4
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp4
-rw-r--r--src/openvic-simulation/types/HasIdentifier.hpp6
31 files changed, 409 insertions, 254 deletions
diff --git a/src/openvic-simulation/GameManager.cpp b/src/openvic-simulation/GameManager.cpp
index fff806c..3ede804 100644
--- a/src/openvic-simulation/GameManager.cpp
+++ b/src/openvic-simulation/GameManager.cpp
@@ -44,8 +44,8 @@ bool GameManager::reset() {
session_start = time(nullptr);
simulation_clock.reset();
today = {};
- economy_manager.get_good_manager().reset_to_defaults();
- bool ret = map_instance.reset(economy_manager.get_building_type_manager());
+ bool ret = economy_manager.setup_good_instances();
+ ret &= map_instance.reset(economy_manager.get_building_type_manager());
set_gamestate_needs_update();
return ret;
}
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index ae115d3..8219e51 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -317,7 +317,7 @@ bool Dataloader::_load_interface_files(UIManager& ui_manager) const {
bool Dataloader::_load_pop_types(GameManager& game_manager) {
PopManager& pop_manager = game_manager.get_pop_manager();
- GoodManager const& good_manager = game_manager.get_economy_manager().get_good_manager();
+ GoodDefinitionManager const& good_definition_manager = game_manager.get_economy_manager().get_good_definition_manager();
IdeologyManager const& ideology_manager = game_manager.get_politics_manager().get_ideology_manager();
static constexpr std::string_view pop_type_directory = "poptypes";
@@ -328,9 +328,9 @@ bool Dataloader::_load_pop_types(GameManager& game_manager) {
bool ret = apply_to_files(
pop_type_files,
- [this, &pop_manager, &good_manager, &ideology_manager](fs::path const& file) -> bool {
+ [this, &pop_manager, &good_definition_manager, &ideology_manager](fs::path const& file) -> bool {
return pop_manager.load_pop_type_file(
- file.stem().string(), good_manager, ideology_manager, parse_defines_cached(file).get_file_node()
+ file.stem().string(), good_definition_manager, ideology_manager, parse_defines_cached(file).get_file_node()
);
}
);
@@ -367,7 +367,7 @@ bool Dataloader::_load_units(GameManager& game_manager) const {
unit_files,
[&game_manager, &unit_type_manager](fs::path const& file) -> bool {
return unit_type_manager.load_unit_type_file(
- game_manager.get_economy_manager().get_good_manager(),
+ game_manager.get_economy_manager().get_good_definition_manager(),
game_manager.get_map_definition().get_terrain_type_manager(),
game_manager.get_modifier_manager(),
parse_defines(file).get_file_node()
@@ -388,11 +388,11 @@ bool Dataloader::_load_units(GameManager& game_manager) const {
bool Dataloader::_load_goods(GameManager& game_manager) const {
static constexpr std::string_view goods_file = "common/goods.txt";
- GoodManager& good_manager = game_manager.get_economy_manager().get_good_manager();
+ GoodDefinitionManager& good_definition_manager = game_manager.get_economy_manager().get_good_definition_manager();
- bool ret = good_manager.load_goods_file(parse_defines(lookup_file(goods_file)).get_file_node());
+ bool ret = good_definition_manager.load_goods_file(parse_defines(lookup_file(goods_file)).get_file_node());
- if (!good_manager.generate_modifiers(game_manager.get_modifier_manager())) {
+ if (!good_definition_manager.generate_modifiers(game_manager.get_modifier_manager())) {
Logger::error("Failed to generate good-based modifiers!");
ret = false;
}
@@ -943,7 +943,7 @@ bool Dataloader::load_defines(GameManager& game_manager) {
ret = false;
}
if (!game_manager.get_politics_manager().load_national_foci_file(
- game_manager.get_pop_manager(), game_manager.get_economy_manager().get_good_manager(),
+ game_manager.get_pop_manager(), game_manager.get_economy_manager().get_good_definition_manager(),
game_manager.get_modifier_manager(), parse_defines_cached(lookup_file(national_foci_file)).get_file_node()
)) {
Logger::error("Failed to load national foci!");
diff --git a/src/openvic-simulation/economy/ArtisanalProducer.cpp b/src/openvic-simulation/economy/ArtisanalProducer.cpp
index 52cfa4f..d5cc3d3 100644
--- a/src/openvic-simulation/economy/ArtisanalProducer.cpp
+++ b/src/openvic-simulation/economy/ArtisanalProducer.cpp
@@ -3,8 +3,11 @@
using namespace OpenVic;
ArtisanalProducer::ArtisanalProducer(
- ProductionType const& new_production_type, Good::good_map_t&& new_stockpile, const fixed_point_t new_current_production,
- Good::good_map_t&& new_current_needs
-)
- : production_type { new_production_type }, stockpile { std::move(new_stockpile) },
- current_production { new_current_production }, current_needs { std::move(new_current_needs) } {}
+ ProductionType const& new_production_type,
+ GoodDefinition::good_definition_map_t&& new_stockpile,
+ fixed_point_t new_current_production,
+ GoodDefinition::good_definition_map_t&& new_current_needs
+) : production_type { new_production_type },
+ stockpile { std::move(new_stockpile) },
+ current_production { new_current_production },
+ current_needs { std::move(new_current_needs) } {}
diff --git a/src/openvic-simulation/economy/ArtisanalProducer.hpp b/src/openvic-simulation/economy/ArtisanalProducer.hpp
index 36de2f2..ed5b231 100644
--- a/src/openvic-simulation/economy/ArtisanalProducer.hpp
+++ b/src/openvic-simulation/economy/ArtisanalProducer.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/economy/ProductionType.hpp"
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
#include "openvic-simulation/utility/Getters.hpp"
@@ -9,14 +9,16 @@ namespace OpenVic {
class ArtisanalProducer final {
private:
ProductionType const& PROPERTY(production_type);
- Good::good_map_t PROPERTY(stockpile);
+ GoodDefinition::good_definition_map_t PROPERTY(stockpile);
fixed_point_t PROPERTY(current_production);
- Good::good_map_t PROPERTY(current_needs);
+ GoodDefinition::good_definition_map_t PROPERTY(current_needs);
public:
ArtisanalProducer(
- ProductionType const& new_production_type, Good::good_map_t&& new_stockpile,
- const fixed_point_t new_current_production, Good::good_map_t&& new_current_needs
+ ProductionType const& new_production_type,
+ GoodDefinition::good_definition_map_t&& new_stockpile,
+ fixed_point_t new_current_production,
+ GoodDefinition::good_definition_map_t&& new_current_needs
);
};
}
diff --git a/src/openvic-simulation/economy/BuildingInstance.cpp b/src/openvic-simulation/economy/BuildingInstance.cpp
index f72c713..7616e09 100644
--- a/src/openvic-simulation/economy/BuildingInstance.cpp
+++ b/src/openvic-simulation/economy/BuildingInstance.cpp
@@ -3,8 +3,13 @@
using namespace OpenVic;
BuildingInstance::BuildingInstance(BuildingType const& new_building_type, level_t new_level)
- : HasIdentifier { new_building_type.get_identifier() }, building_type { new_building_type }, level { new_level },
- expansion_state { ExpansionState::CannotExpand }, start_date {}, end_date {}, expansion_progress { 0.0f } {}
+ : HasIdentifier { new_building_type },
+ building_type { new_building_type },
+ level { new_level },
+ expansion_state { ExpansionState::CannotExpand },
+ start_date {},
+ end_date {},
+ expansion_progress { 0.0f } {}
bool BuildingInstance::_can_expand() const {
return level < building_type.get_max_level();
diff --git a/src/openvic-simulation/economy/BuildingType.cpp b/src/openvic-simulation/economy/BuildingType.cpp
index e7d358a..d096166 100644
--- a/src/openvic-simulation/economy/BuildingType.cpp
+++ b/src/openvic-simulation/economy/BuildingType.cpp
@@ -5,18 +5,33 @@ using namespace OpenVic::NodeTools;
BuildingType::BuildingType(
std::string_view identifier, building_type_args_t& building_type_args
-) : HasIdentifier { identifier }, type { building_type_args.type }, modifier { std::move(building_type_args.modifier) },
- on_completion { building_type_args.on_completion }, completion_size { building_type_args.completion_size },
- max_level { building_type_args.max_level }, goods_cost { std::move(building_type_args.goods_cost) },
- cost { building_type_args.cost }, build_time { building_type_args.build_time }, on_map { building_type_args.on_map },
- default_enabled { building_type_args.default_enabled }, production_type { building_type_args.production_type },
- pop_build_factory { building_type_args.pop_build_factory }, strategic_factory { building_type_args.strategic_factory },
- advanced_factory { building_type_args.advanced_factory }, fort_level { building_type_args.fort_level },
- naval_capacity { building_type_args.naval_capacity }, colonial_points { std::move(building_type_args.colonial_points) },
- in_province { building_type_args.in_province }, one_per_state { building_type_args.one_per_state },
- colonial_range { building_type_args.colonial_range }, infrastructure { building_type_args.infrastructure },
- spawn_railway_track { building_type_args.spawn_railway_track }, sail { building_type_args.sail },
- steam { building_type_args.steam }, capital { building_type_args.capital }, port { building_type_args.port } {}
+) : HasIdentifier { identifier },
+ type { building_type_args.type },
+ modifier { std::move(building_type_args.modifier) },
+ on_completion { building_type_args.on_completion },
+ completion_size { building_type_args.completion_size },
+ max_level { building_type_args.max_level },
+ goods_cost { std::move(building_type_args.goods_cost) },
+ cost { building_type_args.cost },
+ build_time { building_type_args.build_time },
+ on_map { building_type_args.on_map },
+ default_enabled { building_type_args.default_enabled },
+ production_type { building_type_args.production_type },
+ pop_build_factory { building_type_args.pop_build_factory },
+ strategic_factory { building_type_args.strategic_factory },
+ advanced_factory { building_type_args.advanced_factory },
+ fort_level { building_type_args.fort_level },
+ naval_capacity { building_type_args.naval_capacity },
+ colonial_points { std::move(building_type_args.colonial_points) },
+ in_province { building_type_args.in_province },
+ one_per_state { building_type_args.one_per_state },
+ colonial_range { building_type_args.colonial_range },
+ infrastructure { building_type_args.infrastructure },
+ spawn_railway_track { building_type_args.spawn_railway_track },
+ sail { building_type_args.sail },
+ steam { building_type_args.steam },
+ capital { building_type_args.capital },
+ port { building_type_args.port } {}
BuildingTypeManager::BuildingTypeManager() : port_building_type { nullptr } {}
@@ -38,12 +53,13 @@ bool BuildingTypeManager::add_building_type(
}
bool BuildingTypeManager::load_buildings_file(
- GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, ModifierManager& modifier_manager,
- ast::NodeCPtr root
+ GoodDefinitionManager const& good_definition_manager, ProductionTypeManager const& production_type_manager,
+ ModifierManager& modifier_manager, ast::NodeCPtr root
) {
bool ret = expect_dictionary_reserve_length(
- building_types,
- [this, &good_manager, &production_type_manager, &modifier_manager](std::string_view key, ast::NodeCPtr value) -> bool {
+ building_types, [this, &good_definition_manager, &production_type_manager, &modifier_manager](
+ std::string_view key, ast::NodeCPtr value
+ ) -> bool {
BuildingType::building_type_args_t building_type_args {};
bool ret = modifier_manager.expect_modifier_value_and_keys(move_variable_callback(building_type_args.modifier),
@@ -52,8 +68,9 @@ bool BuildingTypeManager::load_buildings_file(
"completion_size", ZERO_OR_ONE,
expect_fixed_point(assign_variable_callback(building_type_args.completion_size)),
"max_level", ONE_EXACTLY, expect_uint(assign_variable_callback(building_type_args.max_level)),
- "goods_cost", ONE_EXACTLY,
- good_manager.expect_good_decimal_map(move_variable_callback(building_type_args.goods_cost)),
+ "goods_cost", ONE_EXACTLY, good_definition_manager.expect_good_definition_decimal_map(
+ move_variable_callback(building_type_args.goods_cost)
+ ),
"cost", ZERO_OR_MORE, expect_fixed_point(assign_variable_callback(building_type_args.cost)),
"time", ONE_EXACTLY, expect_days(assign_variable_callback(building_type_args.build_time)),
"visibility", ONE_EXACTLY, expect_bool([key](bool visibility) -> bool {
diff --git a/src/openvic-simulation/economy/BuildingType.hpp b/src/openvic-simulation/economy/BuildingType.hpp
index 38b7c50..977d6ec 100644
--- a/src/openvic-simulation/economy/BuildingType.hpp
+++ b/src/openvic-simulation/economy/BuildingType.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "openvic-simulation/misc/Modifier.hpp"
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/economy/ProductionType.hpp"
#include "openvic-simulation/types/Date.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
@@ -27,7 +27,7 @@ namespace OpenVic {
ModifierValue modifier;
fixed_point_t completion_size = 0, cost = 0, colonial_range = 0, infrastructure = 0;
BuildingType::level_t max_level = 0, fort_level = 0;
- Good::good_map_t goods_cost;
+ GoodDefinition::good_definition_map_t goods_cost;
Timespan build_time;
bool on_map = false, default_enabled = false, pop_build_factory = false, strategic_factory = false,
advanced_factory = false, in_province = false, one_per_state = false, spawn_railway_track = false,
@@ -46,7 +46,7 @@ namespace OpenVic {
std::string PROPERTY(on_completion); // probably sound played on completion
fixed_point_t PROPERTY(completion_size);
level_t PROPERTY(max_level);
- Good::good_map_t PROPERTY(goods_cost);
+ GoodDefinition::good_definition_map_t PROPERTY(goods_cost);
fixed_point_t PROPERTY(cost);
Timespan PROPERTY(build_time); // time
bool PROPERTY(on_map); // onmap
@@ -94,7 +94,7 @@ namespace OpenVic {
bool add_building_type(std::string_view identifier, BuildingType::building_type_args_t& building_type_args);
bool load_buildings_file(
- GoodManager const& good_manager, ProductionTypeManager const& production_type_manager,
+ GoodDefinitionManager const& good_definition_manager, ProductionTypeManager const& production_type_manager,
ModifierManager& modifier_manager, ast::NodeCPtr root
);
};
diff --git a/src/openvic-simulation/economy/EconomyManager.hpp b/src/openvic-simulation/economy/EconomyManager.hpp
index adeabd9..caac9c2 100644
--- a/src/openvic-simulation/economy/EconomyManager.hpp
+++ b/src/openvic-simulation/economy/EconomyManager.hpp
@@ -1,23 +1,31 @@
#pragma once
#include "openvic-simulation/economy/BuildingType.hpp"
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
+#include "openvic-simulation/economy/GoodInstance.hpp"
#include "openvic-simulation/economy/ProductionType.hpp"
namespace OpenVic {
struct EconomyManager {
private:
BuildingTypeManager PROPERTY_REF(building_type_manager);
- GoodManager PROPERTY_REF(good_manager);
+ GoodDefinitionManager PROPERTY_REF(good_definition_manager);
+ GoodInstanceManager PROPERTY_REF(good_instance_manager);
ProductionTypeManager PROPERTY_REF(production_type_manager);
public:
inline bool load_production_types_file(PopManager const& pop_manager, ast::NodeCPtr root) {
- return production_type_manager.load_production_types_file(good_manager, pop_manager, root);
+ return production_type_manager.load_production_types_file(good_definition_manager, pop_manager, root);
}
inline bool load_buildings_file(ModifierManager& modifier_manager, ast::NodeCPtr root) {
- return building_type_manager.load_buildings_file(good_manager, production_type_manager, modifier_manager, root);
+ return building_type_manager.load_buildings_file(
+ good_definition_manager, production_type_manager, modifier_manager, root
+ );
+ }
+
+ inline bool setup_good_instances() {
+ return good_instance_manager.setup_good_instances(good_definition_manager);
}
};
}
diff --git a/src/openvic-simulation/economy/FactoryProducer.cpp b/src/openvic-simulation/economy/FactoryProducer.cpp
index 81ebd4a..2ef9fa8 100644
--- a/src/openvic-simulation/economy/FactoryProducer.cpp
+++ b/src/openvic-simulation/economy/FactoryProducer.cpp
@@ -3,25 +3,44 @@
using namespace OpenVic;
FactoryProducer::FactoryProducer(
- ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
- const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
- const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
- Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday,
- const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday,
- const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days, const uint32_t new_subsidised_days,
- const uint32_t new_days_without_input, const uint8_t new_hiring_priority, const uint8_t new_profit_history_current,
+ ProductionType const& new_production_type,
+ fixed_point_t new_size_multiplier,
+ fixed_point_t new_revenue_yesterday,
+ fixed_point_t new_output_quantity_yesterday,
+ fixed_point_t new_unsold_quantity_yesterday,
+ ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
+ GoodDefinition::good_definition_map_t&& new_stockpile,
+ fixed_point_t new_budget,
+ fixed_point_t new_balance_yesterday,
+ fixed_point_t new_received_investments_yesterday,
+ fixed_point_t new_market_spendings_yesterday,
+ fixed_point_t new_paychecks_yesterday,
+ uint32_t new_unprofitable_days,
+ uint32_t new_subsidised_days,
+ uint32_t new_days_without_input,
+ uint8_t new_hiring_priority,
+ uint8_t new_profit_history_current,
daily_profit_history_t&& new_daily_profit_history
-)
- : production_type { new_production_type }, size_multiplier { new_size_multiplier },
- revenue_yesterday { new_revenue_yesterday }, output_quantity_yesterday { new_output_quantity_yesterday },
- unsold_quantity_yesterday { new_unsold_quantity_yesterday }, employees { std::move(new_employees) },
- stockpile { std::move(new_stockpile) }, budget { new_budget }, balance_yesterday { new_balance_yesterday },
- received_investments_yesterday { new_received_investments_yesterday },
- market_spendings_yesterday { new_market_spendings_yesterday }, paychecks_yesterday { new_paychecks_yesterday },
- unprofitable_days { new_unprofitable_days }, subsidised_days { new_subsidised_days },
- days_without_input { new_days_without_input }, hiring_priority { new_hiring_priority },
- profit_history_current { new_profit_history_current }, daily_profit_history { std::move(new_daily_profit_history) } {}
-FactoryProducer::FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier)
+) : production_type { new_production_type },
+ size_multiplier { new_size_multiplier },
+ revenue_yesterday { new_revenue_yesterday },
+ output_quantity_yesterday { new_output_quantity_yesterday },
+ unsold_quantity_yesterday { new_unsold_quantity_yesterday },
+ employees { std::move(new_employees) },
+ stockpile { std::move(new_stockpile) },
+ budget { new_budget },
+ balance_yesterday { new_balance_yesterday },
+ received_investments_yesterday { new_received_investments_yesterday },
+ market_spendings_yesterday { new_market_spendings_yesterday },
+ paychecks_yesterday { new_paychecks_yesterday },
+ unprofitable_days { new_unprofitable_days },
+ subsidised_days { new_subsidised_days },
+ days_without_input { new_days_without_input },
+ hiring_priority { new_hiring_priority },
+ profit_history_current { new_profit_history_current },
+ daily_profit_history { std::move(new_daily_profit_history) } {}
+
+FactoryProducer::FactoryProducer(ProductionType const& new_production_type, fixed_point_t new_size_multiplier)
: FactoryProducer { new_production_type, new_size_multiplier, 0, 0, 0, {}, {}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {} } {}
fixed_point_t FactoryProducer::get_profitability_yesterday() const {
diff --git a/src/openvic-simulation/economy/FactoryProducer.hpp b/src/openvic-simulation/economy/FactoryProducer.hpp
index 623ec48..ee658a5 100644
--- a/src/openvic-simulation/economy/FactoryProducer.hpp
+++ b/src/openvic-simulation/economy/FactoryProducer.hpp
@@ -2,7 +2,7 @@
#include <cstdint>
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/economy/ProductionType.hpp"
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
#include "openvic-simulation/utility/Getters.hpp"
@@ -21,7 +21,7 @@ namespace OpenVic {
fixed_point_t PROPERTY(unsold_quantity_yesterday);
fixed_point_t PROPERTY(size_multiplier);
ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees);
- Good::good_map_t PROPERTY(stockpile);
+ GoodDefinition::good_definition_map_t PROPERTY(stockpile);
fixed_point_t PROPERTY(budget);
fixed_point_t PROPERTY(balance_yesterday);
fixed_point_t PROPERTY(received_investments_yesterday);
@@ -34,16 +34,26 @@ namespace OpenVic {
public:
FactoryProducer(
- ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
- const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
- const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
- Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday,
- const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday,
- const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days,
- const uint32_t new_subsidised_days, const uint32_t new_days_without_input, const uint8_t new_hiring_priority,
- const uint8_t new_profit_history_current, daily_profit_history_t&& new_daily_profit_history
+ ProductionType const& new_production_type,
+ fixed_point_t new_size_multiplier,
+ fixed_point_t new_revenue_yesterday,
+ fixed_point_t new_output_quantity_yesterday,
+ fixed_point_t new_unsold_quantity_yesterday,
+ ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
+ GoodDefinition::good_definition_map_t&& new_stockpile,
+ fixed_point_t new_budget,
+ fixed_point_t new_balance_yesterday,
+ fixed_point_t new_received_investments_yesterday,
+ fixed_point_t new_market_spendings_yesterday,
+ fixed_point_t new_paychecks_yesterday,
+ uint32_t new_unprofitable_days,
+ uint32_t new_subsidised_days,
+ uint32_t new_days_without_input,
+ uint8_t new_hiring_priority,
+ uint8_t new_profit_history_current,
+ daily_profit_history_t&& new_daily_profit_history
);
- FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier);
+ FactoryProducer(ProductionType const& new_production_type, fixed_point_t new_size_multiplier);
fixed_point_t get_profitability_yesterday() const;
fixed_point_t get_average_profitability_last_seven_days() const;
diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/GoodDefinition.cpp
index 961a82d..5a3d632 100644
--- a/src/openvic-simulation/economy/Good.cpp
+++ b/src/openvic-simulation/economy/GoodDefinition.cpp
@@ -1,4 +1,4 @@
-#include "Good.hpp"
+#include "GoodDefinition.hpp"
#include <cassert>
@@ -7,7 +7,7 @@ using namespace OpenVic::NodeTools;
GoodCategory::GoodCategory(std::string_view new_identifier) : HasIdentifier { new_identifier } {}
-Good::Good(
+GoodDefinition::GoodDefinition(
std::string_view new_identifier, colour_t new_colour, index_t new_index, GoodCategory const& new_category,
price_t new_base_price, bool new_available_from_start, bool new_tradeable, bool new_money, bool new_overseas_penalty
) : HasIdentifierAndColour { new_identifier, new_colour, false }, index { new_index }, category { new_category },
@@ -16,12 +16,7 @@ Good::Good(
assert(base_price > NULL_PRICE);
}
-void Good::reset_to_defaults() {
- available = available_from_start;
- price = base_price;
-}
-
-bool GoodManager::add_good_category(std::string_view identifier) {
+bool GoodDefinitionManager::add_good_category(std::string_view identifier) {
if (identifier.empty()) {
Logger::error("Invalid good category identifier - empty!");
return false;
@@ -29,31 +24,25 @@ bool GoodManager::add_good_category(std::string_view identifier) {
return good_categories.add_item({ identifier });
}
-bool GoodManager::add_good(
- std::string_view identifier, colour_t colour, GoodCategory const& category, Good::price_t base_price,
+bool GoodDefinitionManager::add_good_definition(
+ std::string_view identifier, colour_t colour, GoodCategory const& category, GoodDefinition::price_t base_price,
bool available_from_start, bool tradeable, bool money, bool overseas_penalty
) {
if (identifier.empty()) {
Logger::error("Invalid good identifier - empty!");
return false;
}
- if (base_price <= Good::NULL_PRICE) {
+ if (base_price <= GoodDefinition::NULL_PRICE) {
Logger::error("Invalid base price for ", identifier, ": ", base_price);
return false;
}
- return goods.add_item({
- identifier, colour, get_good_count(), category, base_price, available_from_start,
+ return good_definitions.add_item({
+ identifier, colour, get_good_definition_count(), category, base_price, available_from_start,
tradeable, money, overseas_penalty
});
}
-void GoodManager::reset_to_defaults() {
- for (Good& good : goods.get_items()) {
- good.reset_to_defaults();
- }
-}
-
-bool GoodManager::load_goods_file(ast::NodeCPtr root) {
+bool GoodDefinitionManager::load_goods_file(ast::NodeCPtr root) {
size_t total_expected_goods = 0;
bool ret = expect_dictionary_reserve_length(
good_categories,
@@ -64,11 +53,11 @@ bool GoodManager::load_goods_file(ast::NodeCPtr root) {
}
)(root);
lock_good_categories();
- reserve_more_goods(total_expected_goods);
+ reserve_more_good_definitions(total_expected_goods);
ret &= expect_good_category_dictionary([this](GoodCategory const& good_category, ast::NodeCPtr good_category_value) -> bool {
return expect_dictionary([this, &good_category](std::string_view key, ast::NodeCPtr value) -> bool {
colour_t colour = colour_t::null();
- Good::price_t base_price;
+ GoodDefinition::price_t base_price;
bool available_from_start = true, tradeable = true;
bool money = false, overseas_penalty = false;
@@ -80,22 +69,22 @@ bool GoodManager::load_goods_file(ast::NodeCPtr root) {
"money", ZERO_OR_ONE, expect_bool(assign_variable_callback(money)),
"overseas_penalty", ZERO_OR_ONE, expect_bool(assign_variable_callback(overseas_penalty))
)(value);
- ret &= add_good(
+ ret &= add_good_definition(
key, colour, good_category, base_price, available_from_start, tradeable, money, overseas_penalty
);
return ret;
})(good_category_value);
})(root);
- lock_goods();
+ lock_good_definitions();
return ret;
}
-bool GoodManager::generate_modifiers(ModifierManager& modifier_manager) const {
+bool GoodDefinitionManager::generate_modifiers(ModifierManager& modifier_manager) const {
bool ret = true;
const auto good_modifier = [this, &modifier_manager, &ret](std::string_view name, bool is_positive_good) -> void {
ret &= modifier_manager.register_complex_modifier(name);
- for (Good const& good : get_goods()) {
+ for (GoodDefinition const& good : get_good_definitions()) {
ret &= modifier_manager.add_modifier_effect(
ModifierManager::get_flat_identifier(name, good.get_identifier()), is_positive_good
);
@@ -112,7 +101,7 @@ bool GoodManager::generate_modifiers(ModifierManager& modifier_manager) const {
good_modifier("rgo_goods_throughput", true);
good_modifier("rgo_size", true);
- for (Good const& good : get_goods()) {
+ for (GoodDefinition const& good : get_good_definitions()) {
ret &= modifier_manager.add_modifier_effect(good.get_identifier(), true, ModifierEffect::format_t::PERCENTAGE_DECIMAL);
}
diff --git a/src/openvic-simulation/economy/Good.hpp b/src/openvic-simulation/economy/GoodDefinition.hpp
index d9d4251..0a3ad5c 100644
--- a/src/openvic-simulation/economy/Good.hpp
+++ b/src/openvic-simulation/economy/GoodDefinition.hpp
@@ -4,10 +4,10 @@
#include "openvic-simulation/types/IdentifierRegistry.hpp"
namespace OpenVic {
- struct GoodManager;
+ struct GoodDefinitionManager;
struct GoodCategory : HasIdentifier {
- friend struct GoodManager;
+ friend struct GoodDefinitionManager;
private:
GoodCategory(std::string_view new_identifier);
@@ -28,15 +28,15 @@ namespace OpenVic {
* ECON-238, ECON-239, ECON-240, ECON-241, ECON-242, ECON-243, ECON-244, ECON-245, ECON-246, ECON-247, ECON-248, ECON-249,
* ECON-250, ECON-251, ECON-252, ECON-253, ECON-254, ECON-255, ECON-256, ECON-257, ECON-258, ECON-259, ECON-260, ECON-261
*/
- struct Good : HasIdentifierAndColour {
- friend struct GoodManager;
+ struct GoodDefinition : HasIdentifierAndColour {
+ friend struct GoodDefinitionManager;
using index_t = size_t;
using price_t = fixed_point_t;
static constexpr price_t NULL_PRICE = fixed_point_t::_0();
- using good_map_t = fixed_point_map_t<Good const*>;
+ using good_definition_map_t = fixed_point_map_t<GoodDefinition const*>;
private:
const index_t PROPERTY(index);
@@ -47,34 +47,29 @@ namespace OpenVic {
const bool PROPERTY(money);
const bool PROPERTY(overseas_penalty);
- price_t PROPERTY_RW(price);
- bool PROPERTY_RW(available);
-
- Good(
+ GoodDefinition(
std::string_view new_identifier, colour_t new_colour, index_t new_index, GoodCategory const& new_category,
price_t new_base_price, bool new_available_from_start, bool new_tradeable, bool new_money,
bool new_overseas_penalty
);
public:
- Good(Good&&) = default;
- void reset_to_defaults();
+ GoodDefinition(GoodDefinition&&) = default;
};
- struct GoodManager {
+ struct GoodDefinitionManager {
private:
IdentifierRegistry<GoodCategory> IDENTIFIER_REGISTRY_CUSTOM_PLURAL(good_category, good_categories);
- IdentifierRegistry<Good> IDENTIFIER_REGISTRY(good);
+ IdentifierRegistry<GoodDefinition> IDENTIFIER_REGISTRY(good_definition);
public:
bool add_good_category(std::string_view identifier);
- bool add_good(
- std::string_view identifier, colour_t colour, GoodCategory const& category, Good::price_t base_price,
+ bool add_good_definition(
+ std::string_view identifier, colour_t colour, GoodCategory const& category, GoodDefinition::price_t base_price,
bool available_from_start, bool tradeable, bool money, bool overseas_penalty
);
- void reset_to_defaults();
bool load_goods_file(ast::NodeCPtr root);
bool generate_modifiers(ModifierManager& modifier_manager) const;
};
diff --git a/src/openvic-simulation/economy/GoodInstance.cpp b/src/openvic-simulation/economy/GoodInstance.cpp
new file mode 100644
index 0000000..937706d
--- /dev/null
+++ b/src/openvic-simulation/economy/GoodInstance.cpp
@@ -0,0 +1,20 @@
+#include "GoodInstance.hpp"
+
+using namespace OpenVic;
+
+GoodInstance::GoodInstance(GoodDefinition const& new_good_definition)
+ : HasIdentifierAndColour { new_good_definition }, good_definition { new_good_definition },
+ price { new_good_definition.get_base_price() }, available { new_good_definition.is_available_from_start() } {}
+
+bool GoodInstanceManager::setup_good_instances(GoodDefinitionManager const& good_definition_manager) {
+ good_instances.reset();
+ good_instances.reserve(good_definition_manager.get_good_definition_count());
+
+ bool ret = true;
+
+ for (GoodDefinition const& good : good_definition_manager.get_good_definitions()) {
+ ret &= good_instances.add_item({ good });
+ }
+
+ return ret;
+}
diff --git a/src/openvic-simulation/economy/GoodInstance.hpp b/src/openvic-simulation/economy/GoodInstance.hpp
new file mode 100644
index 0000000..3c27209
--- /dev/null
+++ b/src/openvic-simulation/economy/GoodInstance.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "openvic-simulation/economy/GoodDefinition.hpp"
+#include "openvic-simulation/types/HasIdentifier.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
+#include "openvic-simulation/utility/Getters.hpp"
+
+namespace OpenVic {
+ struct GoodInstanceManager;
+
+ struct GoodInstance : HasIdentifierAndColour {
+ friend struct GoodInstanceManager;
+
+ private:
+ GoodDefinition const& PROPERTY(good_definition);
+ GoodDefinition::price_t PROPERTY(price);
+ bool PROPERTY(available);
+ // TODO - supply, demand, actual bought
+
+ GoodInstance(GoodDefinition const& new_good_definition);
+
+ public:
+ GoodInstance(GoodInstance&&) = default;
+ };
+
+ struct GoodInstanceManager {
+ private:
+ IdentifierRegistry<GoodInstance> IDENTIFIER_REGISTRY(good_instance);
+
+ public:
+ bool setup_good_instances(GoodDefinitionManager const& good_definition_manager);
+ };
+}
diff --git a/src/openvic-simulation/economy/ProductionType.cpp b/src/openvic-simulation/economy/ProductionType.cpp
index 7029fd1..4f87ba5 100644
--- a/src/openvic-simulation/economy/ProductionType.cpp
+++ b/src/openvic-simulation/economy/ProductionType.cpp
@@ -4,9 +4,13 @@ using namespace OpenVic;
using namespace OpenVic::NodeTools;
Job::Job(
- PopType const* new_pop_type, effect_t new_effect_type, fixed_point_t new_effect_multiplier,
+ PopType const* new_pop_type,
+ effect_t new_effect_type,
+ fixed_point_t new_effect_multiplier,
fixed_point_t new_desired_workforce_share
-) : pop_type { new_pop_type }, effect_type { new_effect_type }, effect_multiplier { new_effect_multiplier },
+) : pop_type { new_pop_type },
+ effect_type { new_effect_type },
+ effect_multiplier { new_effect_multiplier },
desired_workforce_share { new_desired_workforce_share } {}
ProductionType::ProductionType(
@@ -15,18 +19,26 @@ ProductionType::ProductionType(
std::vector<Job>&& new_jobs,
template_type_t new_template_type,
Pop::pop_size_t new_base_workforce_size,
- Good::good_map_t&& new_input_goods,
- Good const* new_output_goods,
+ GoodDefinition::good_definition_map_t&& new_input_goods,
+ GoodDefinition const* new_output_goods,
fixed_point_t new_base_output_quantity,
std::vector<bonus_t>&& new_bonuses,
- Good::good_map_t&& new_maintenance_requirements,
+ GoodDefinition::good_definition_map_t&& new_maintenance_requirements,
bool new_is_coastal,
bool new_is_farm,
bool new_is_mine
-) : HasIdentifier { new_identifier }, owner { new_owner }, jobs { std::move(new_jobs) }, template_type { new_template_type },
- base_workforce_size { new_base_workforce_size }, input_goods { std::move(new_input_goods) },
- output_goods { new_output_goods }, base_output_quantity { new_base_output_quantity }, bonuses { std::move(new_bonuses) },
- maintenance_requirements { std::move(new_maintenance_requirements) }, coastal { new_is_coastal }, farm { new_is_farm },
+) : HasIdentifier { new_identifier },
+ owner { new_owner },
+ jobs { std::move(new_jobs) },
+ template_type { new_template_type },
+ base_workforce_size { new_base_workforce_size },
+ input_goods { std::move(new_input_goods) },
+ output_goods { new_output_goods },
+ base_output_quantity { new_base_output_quantity },
+ bonuses { std::move(new_bonuses) },
+ maintenance_requirements { std::move(new_maintenance_requirements) },
+ coastal { new_is_coastal },
+ farm { new_is_farm },
mine { new_is_mine } {}
bool ProductionType::parse_scripts(GameManager const& game_manager) {
@@ -40,9 +52,9 @@ bool ProductionType::parse_scripts(GameManager const& game_manager) {
ProductionTypeManager::ProductionTypeManager() : rgo_owner_sprite { 0 } {}
node_callback_t ProductionTypeManager::_expect_job(
- GoodManager const& good_manager, PopManager const& pop_manager, callback_t<Job&&> callback
+ GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager, callback_t<Job&&> callback
) {
- return [this, &good_manager, &pop_manager, callback](ast::NodeCPtr node) -> bool {
+ return [this, &good_definition_manager, &pop_manager, callback](ast::NodeCPtr node) -> bool {
using enum Job::effect_t;
std::string_view pop_type {};
@@ -66,11 +78,12 @@ node_callback_t ProductionTypeManager::_expect_job(
}
node_callback_t ProductionTypeManager::_expect_job_list(
- GoodManager const& good_manager, PopManager const& pop_manager, callback_t<std::vector<Job>&&> callback
+ GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager,
+ callback_t<std::vector<Job>&&> callback
) {
- return [this, &good_manager, &pop_manager, callback](ast::NodeCPtr node) -> bool {
+ return [this, &good_definition_manager, &pop_manager, callback](ast::NodeCPtr node) -> bool {
std::vector<Job> jobs;
- bool ret = expect_list(_expect_job(good_manager, pop_manager, vector_callback(jobs)))(node);
+ bool ret = expect_list(_expect_job(good_definition_manager, pop_manager, vector_callback(jobs)))(node);
ret &= callback(std::move(jobs));
return ret;
};
@@ -82,11 +95,11 @@ bool ProductionTypeManager::add_production_type(
std::vector<Job>&& jobs,
ProductionType::template_type_t template_type,
Pop::pop_size_t base_workforce_size,
- Good::good_map_t&& input_goods,
- Good const* output_goods,
+ GoodDefinition::good_definition_map_t&& input_goods,
+ GoodDefinition const* output_goods,
fixed_point_t base_output_quantity,
std::vector<ProductionType::bonus_t>&& bonuses,
- Good::good_map_t&& maintenance_requirements,
+ GoodDefinition::good_definition_map_t&& maintenance_requirements,
bool is_coastal,
bool is_farm,
bool is_mine
@@ -163,7 +176,7 @@ bool ProductionTypeManager::add_production_type(
}
bool ProductionTypeManager::load_production_types_file(
- GoodManager const& good_manager, PopManager const& pop_manager, ast::NodeCPtr root
+ GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager, ast::NodeCPtr root
) {
size_t expected_types = 0;
@@ -206,7 +219,7 @@ bool ProductionTypeManager::load_production_types_file(
/* Pass #3: actually load production types */
reserve_more_production_types(expected_types);
ret &= expect_dictionary(
- [this, &good_manager, &pop_manager, &template_target_map, &template_node_map](
+ [this, &good_definition_manager, &pop_manager, &template_target_map, &template_node_map](
std::string_view key, ast::NodeCPtr node) -> bool {
using enum ProductionType::template_type_t;
@@ -217,9 +230,9 @@ bool ProductionTypeManager::load_production_types_file(
std::optional<Job> owner;
std::vector<Job> jobs;
ProductionType::template_type_t template_type { FACTORY };
- Good const* output_goods = nullptr;
+ GoodDefinition const* output_goods = nullptr;
Pop::pop_size_t base_workforce_size = 0;
- Good::good_map_t input_goods, maintenance_requirements;
+ GoodDefinition::good_definition_map_t input_goods, maintenance_requirements;
fixed_point_t base_output_quantity = 0;
std::vector<ProductionType::bonus_t> bonuses;
bool is_coastal = false, is_farm = false, is_mine = false;
@@ -242,14 +255,19 @@ bool ProductionTypeManager::load_production_types_file(
bonuses.emplace_back(std::move(trigger), bonus_value);
return ret;
},
- "owner", ZERO_OR_ONE, _expect_job(good_manager, pop_manager, move_variable_callback(owner)),
- "employees", ZERO_OR_ONE, _expect_job_list(good_manager, pop_manager, move_variable_callback(jobs)),
- "type", ZERO_OR_ONE, expect_identifier(expect_mapped_string(template_type_map, assign_variable_callback(template_type))),
+ "owner", ZERO_OR_ONE, _expect_job(good_definition_manager, pop_manager, move_variable_callback(owner)),
+ "employees", ZERO_OR_ONE, _expect_job_list(good_definition_manager, pop_manager, move_variable_callback(jobs)),
+ "type", ZERO_OR_ONE,
+ expect_identifier(expect_mapped_string(template_type_map, assign_variable_callback(template_type))),
"workforce", ZERO_OR_ONE, expect_uint(assign_variable_callback(base_workforce_size)),
- "input_goods", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(input_goods)),
- "output_goods", ZERO_OR_ONE, good_manager.expect_good_identifier(assign_variable_callback_pointer(output_goods)),
+ "input_goods", ZERO_OR_ONE,
+ good_definition_manager.expect_good_definition_decimal_map(move_variable_callback(input_goods)),
+ "output_goods", ZERO_OR_ONE,
+ good_definition_manager.expect_good_definition_identifier(assign_variable_callback_pointer(output_goods)),
"value", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(base_output_quantity)),
- "efficiency", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(maintenance_requirements)),
+ "efficiency", ZERO_OR_ONE, good_definition_manager.expect_good_definition_decimal_map(
+ move_variable_callback(maintenance_requirements)
+ ),
"is_coastal", ZERO_OR_ONE, expect_bool(assign_variable_callback(is_coastal)),
"farm", ZERO_OR_ONE, expect_bool(assign_variable_callback(is_farm)),
"mine", ZERO_OR_ONE, expect_bool(assign_variable_callback(is_mine))
diff --git a/src/openvic-simulation/economy/ProductionType.hpp b/src/openvic-simulation/economy/ProductionType.hpp
index 3c0bf3f..7480206 100644
--- a/src/openvic-simulation/economy/ProductionType.hpp
+++ b/src/openvic-simulation/economy/ProductionType.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/pop/Pop.hpp"
#include "openvic-simulation/scripts/ConditionScript.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
@@ -44,12 +44,12 @@ namespace OpenVic {
const template_type_t PROPERTY(template_type);
const Pop::pop_size_t PROPERTY(base_workforce_size);
- Good::good_map_t PROPERTY(input_goods);
- Good const* PROPERTY(output_goods);
+ GoodDefinition::good_definition_map_t PROPERTY(input_goods);
+ GoodDefinition const* PROPERTY(output_goods);
const fixed_point_t PROPERTY(base_output_quantity);
std::vector<bonus_t> PROPERTY(bonuses);
- Good::good_map_t PROPERTY(maintenance_requirements);
+ GoodDefinition::good_definition_map_t PROPERTY(maintenance_requirements);
const bool PROPERTY_CUSTOM_PREFIX(coastal, is);
const bool PROPERTY_CUSTOM_PREFIX(farm, is);
@@ -61,11 +61,11 @@ namespace OpenVic {
std::vector<Job>&& new_jobs,
template_type_t new_template_type,
Pop::pop_size_t new_base_workforce_size,
- Good::good_map_t&& new_input_goods,
- Good const* new_output_goods,
+ GoodDefinition::good_definition_map_t&& new_input_goods,
+ GoodDefinition const* new_output_goods,
fixed_point_t new_base_output_quantity,
std::vector<bonus_t>&& new_bonuses,
- Good::good_map_t&& new_maintenance_requirements,
+ GoodDefinition::good_definition_map_t&& new_maintenance_requirements,
bool new_is_coastal,
bool new_is_farm,
bool new_is_mine
@@ -83,10 +83,12 @@ namespace OpenVic {
PopType::sprite_t PROPERTY(rgo_owner_sprite);
NodeTools::node_callback_t _expect_job(
- GoodManager const& good_manager, PopManager const& pop_manager, NodeTools::callback_t<Job&&> callback
+ GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager,
+ NodeTools::callback_t<Job&&> callback
);
NodeTools::node_callback_t _expect_job_list(
- GoodManager const& good_manager, PopManager const& pop_manager, NodeTools::callback_t<std::vector<Job>&&> callback
+ GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager,
+ NodeTools::callback_t<std::vector<Job>&&> callback
);
public:
@@ -98,17 +100,19 @@ namespace OpenVic {
std::vector<Job>&& employees,
ProductionType::template_type_t template_type,
Pop::pop_size_t workforce,
- Good::good_map_t&& input_goods,
- Good const* output_goods,
+ GoodDefinition::good_definition_map_t&& input_goods,
+ GoodDefinition const* output_goods,
fixed_point_t value,
std::vector<ProductionType::bonus_t>&& bonuses,
- Good::good_map_t&& maintenance_requirements,
+ GoodDefinition::good_definition_map_t&& maintenance_requirements,
bool coastal,
bool farm,
bool mine
);
- bool load_production_types_file(GoodManager const& good_manager, PopManager const& pop_manager, ast::NodeCPtr root);
+ bool load_production_types_file(
+ GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager, ast::NodeCPtr root
+ );
bool parse_scripts(GameManager const& game_manager);
};
diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp
index 87d0713..c4d92b8 100644
--- a/src/openvic-simulation/history/ProvinceHistory.cpp
+++ b/src/openvic-simulation/history/ProvinceHistory.cpp
@@ -20,7 +20,7 @@ bool ProvinceHistoryMap::_load_history_entry(
) {
BuildingTypeManager const& building_type_manager = game_manager.get_economy_manager().get_building_type_manager();
CountryManager const& country_manager = game_manager.get_country_manager();
- GoodManager const& good_manager = game_manager.get_economy_manager().get_good_manager();
+ GoodDefinitionManager const& good_definition_manager = game_manager.get_economy_manager().get_good_definition_manager();
IdeologyManager const& ideology_manager = game_manager.get_politics_manager().get_ideology_manager();
TerrainTypeManager const& terrain_type_manager = game_manager.get_map_definition().get_terrain_type_manager();
@@ -65,7 +65,8 @@ bool ProvinceHistoryMap::_load_history_entry(
"colony", ZERO_OR_ONE,
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_manager.expect_good_identifier(assign_variable_callback_pointer_opt(entry.rgo)),
+ "trade_goods", ZERO_OR_ONE,
+ good_definition_manager.expect_good_definition_identifier(assign_variable_callback_pointer_opt(entry.rgo)),
"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 c4cbd49..015b7be 100644
--- a/src/openvic-simulation/history/ProvinceHistory.hpp
+++ b/src/openvic-simulation/history/ProvinceHistory.hpp
@@ -16,7 +16,7 @@ namespace OpenVic {
struct ProvinceHistoryMap;
struct ProvinceDefinition;
struct Country;
- struct Good;
+ struct GoodDefinition;
struct TerrainType;
struct Ideology;
struct GameManager;
@@ -33,7 +33,7 @@ namespace OpenVic {
std::optional<bool> PROPERTY(slave);
std::vector<Country const*> PROPERTY(add_cores);
std::vector<Country const*> PROPERTY(remove_cores);
- std::optional<Good const*> PROPERTY(rgo);
+ std::optional<GoodDefinition const*> PROPERTY(rgo);
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);
diff --git a/src/openvic-simulation/map/Mapmode.cpp b/src/openvic-simulation/map/Mapmode.cpp
index 6f8e606..410ea2b 100644
--- a/src/openvic-simulation/map/Mapmode.cpp
+++ b/src/openvic-simulation/map/Mapmode.cpp
@@ -142,8 +142,8 @@ static constexpr auto shaded_mapmode(fixed_point_map_t<T const*> const&(Province
bool MapmodeManager::setup_mapmodes() {
bool ret = true;
- using mapmode_t = std::pair<std::string, Mapmode::colour_func_t>;
- const std::vector<mapmode_t> mapmodes {
+ using mapmode_definition_t = std::pair<std::string, Mapmode::colour_func_t>;
+ const std::vector<mapmode_definition_t> mapmode_definitions {
{
"mapmode_terrain",
[](MapInstance const&, ProvinceInstance const& province) -> Mapmode::base_stripe_t {
@@ -284,9 +284,13 @@ bool MapmodeManager::setup_mapmodes() {
}
};
- for (mapmode_t const& mapmode : mapmodes) {
+ mapmodes.reset();
+ reserve_mapmodes(mapmode_definitions.size());
+
+ for (mapmode_definition_t const& mapmode : mapmode_definitions) {
ret &= add_mapmode(mapmode.first, mapmode.second);
}
+
lock_mapmodes();
return ret;
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index ba52280..be77d6e 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -8,11 +8,27 @@
using namespace OpenVic;
ProvinceInstance::ProvinceInstance(ProvinceDefinition const& new_province_definition)
- : HasIdentifier { new_province_definition.get_identifier() }, province_definition { new_province_definition },
- terrain_type { nullptr }, life_rating { 0 }, colony_status { colony_status_t::STATE }, state { nullptr },
- owner { nullptr }, controller { nullptr }, cores {}, slave { false }, crime { nullptr }, rgo { nullptr },
- buildings { "buildings", false }, armies {}, navies {}, pops {}, total_population { 0 }, pop_type_distribution {},
- ideology_distribution {}, culture_distribution {}, religion_distribution {} {}
+ : HasIdentifierAndColour { new_province_definition },
+ province_definition { new_province_definition },
+ terrain_type { nullptr },
+ life_rating { 0 },
+ colony_status { colony_status_t::STATE },
+ state { nullptr },
+ owner { nullptr },
+ controller { nullptr },
+ cores {},
+ slave { false },
+ crime { nullptr },
+ rgo { nullptr },
+ buildings { "buildings", false },
+ armies {},
+ navies {},
+ pops {},
+ total_population { 0 },
+ pop_type_distribution {},
+ ideology_distribution {},
+ culture_distribution {},
+ religion_distribution {} {}
bool ProvinceInstance::expand_building(size_t building_index) {
BuildingInstance* building = buildings.get_item_by_index(building_index);
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index 3292575..beae0eb 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -13,7 +13,7 @@ namespace OpenVic {
struct State;
struct Country;
struct Crime;
- struct Good;
+ struct GoodDefinition;
struct ArmyInstance;
struct NavyInstance;
struct Ideology;
@@ -24,7 +24,7 @@ namespace OpenVic {
struct IdeologyManager;
struct IssueManager;
- struct ProvinceInstance : HasIdentifier {
+ struct ProvinceInstance : HasIdentifierAndColour {
friend struct MapInstance;
using life_rating_t = int8_t;
@@ -44,7 +44,7 @@ namespace OpenVic {
bool PROPERTY(slave);
Crime const* PROPERTY_RW(crime);
// TODO - change this into a factory-like structure
- Good const* PROPERTY(rgo);
+ GoodDefinition const* PROPERTY(rgo);
IdentifierRegistry<BuildingInstance> IDENTIFIER_REGISTRY(building);
ordered_set<ArmyInstance*> PROPERTY(armies);
ordered_set<NavyInstance*> PROPERTY(navies);
diff --git a/src/openvic-simulation/military/UnitType.cpp b/src/openvic-simulation/military/UnitType.cpp
index 1fafe35..45ce5d9 100644
--- a/src/openvic-simulation/military/UnitType.cpp
+++ b/src/openvic-simulation/military/UnitType.cpp
@@ -146,10 +146,10 @@ bool UnitTypeManager::add_ship_type(
}
bool UnitTypeManager::load_unit_type_file(
- GoodManager const& good_manager, TerrainTypeManager const& terrain_type_manager, ModifierManager const& modifier_manager,
- ast::NodeCPtr root
+ GoodDefinitionManager const& good_definition_manager, TerrainTypeManager const& terrain_type_manager,
+ ModifierManager const& modifier_manager, ast::NodeCPtr root
) {
- return expect_dictionary([this, &good_manager, &terrain_type_manager, &modifier_manager](
+ return expect_dictionary([this, &good_definition_manager, &terrain_type_manager, &modifier_manager](
std::string_view key, ast::NodeCPtr value
) -> bool {
@@ -194,9 +194,11 @@ bool UnitTypeManager::load_unit_type_file(
"move_sound", ZERO_OR_ONE, expect_identifier(assign_variable_callback(unit_args.move_sound)),
"select_sound", ZERO_OR_ONE, expect_identifier(assign_variable_callback(unit_args.select_sound)),
"build_time", ONE_EXACTLY, expect_days(assign_variable_callback(unit_args.build_time)),
- "build_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(move_variable_callback(unit_args.build_cost)),
+ "build_cost", ONE_EXACTLY,
+ good_definition_manager.expect_good_definition_decimal_map(move_variable_callback(unit_args.build_cost)),
"supply_consumption", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(unit_args.supply_consumption)),
- "supply_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(move_variable_callback(unit_args.supply_cost))
+ "supply_cost", ONE_EXACTLY,
+ good_definition_manager.expect_good_definition_decimal_map(move_variable_callback(unit_args.supply_cost))
);
const auto add_terrain_modifier = [&unit_args, &terrain_type_manager, &modifier_manager](
diff --git a/src/openvic-simulation/military/UnitType.hpp b/src/openvic-simulation/military/UnitType.hpp
index 201708e..9e7ecdc 100644
--- a/src/openvic-simulation/military/UnitType.hpp
+++ b/src/openvic-simulation/military/UnitType.hpp
@@ -5,7 +5,7 @@
#include "openvic-simulation/misc/Modifier.hpp"
#include "openvic-simulation/dataloader/NodeTools.hpp"
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/types/Date.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
@@ -33,7 +33,7 @@ namespace OpenVic {
fixed_point_t max_strength = 0, default_organisation = 0, maximum_speed = 0, weighted_value = 0,
supply_consumption = 0;
Timespan build_time;
- Good::good_map_t build_cost, supply_cost;
+ GoodDefinition::good_definition_map_t build_cost, supply_cost;
terrain_modifiers_t terrain_modifiers;
unit_type_args_t() = default;
@@ -58,9 +58,9 @@ namespace OpenVic {
std::string PROPERTY(select_sound);
const Timespan PROPERTY(build_time);
- Good::good_map_t PROPERTY(build_cost);
+ GoodDefinition::good_definition_map_t PROPERTY(build_cost);
const fixed_point_t PROPERTY(supply_consumption);
- Good::good_map_t PROPERTY(supply_cost);
+ GoodDefinition::good_definition_map_t PROPERTY(supply_cost);
terrain_modifiers_t PROPERTY(terrain_modifiers);
@@ -173,7 +173,7 @@ namespace OpenVic {
}
bool load_unit_type_file(
- GoodManager const& good_manager, TerrainTypeManager const& terrain_type_manager,
+ GoodDefinitionManager const& good_definition_manager, TerrainTypeManager const& terrain_type_manager,
ModifierManager const& modifier_manager, ast::NodeCPtr root
);
bool generate_modifiers(ModifierManager& modifier_manager) const;
diff --git a/src/openvic-simulation/politics/NationalFocus.cpp b/src/openvic-simulation/politics/NationalFocus.cpp
index 22b91b2..a62147f 100644
--- a/src/openvic-simulation/politics/NationalFocus.cpp
+++ b/src/openvic-simulation/politics/NationalFocus.cpp
@@ -72,8 +72,8 @@ inline bool NationalFocusManager::add_national_focus(
}
bool NationalFocusManager::load_national_foci_file(
- PopManager const& pop_manager, IdeologyManager const& ideology_manager, GoodManager const& good_manager,
- ModifierManager const& modifier_manager, ast::NodeCPtr root
+ PopManager const& pop_manager, IdeologyManager const& ideology_manager,
+ GoodDefinitionManager const& good_definition_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root
) {
size_t expected_national_foci = 0;
bool ret = expect_dictionary_reserve_length(
@@ -86,41 +86,46 @@ bool NationalFocusManager::load_national_foci_file(
reserve_more_national_foci(expected_national_foci);
- ret &= expect_national_focus_group_dictionary([this, &pop_manager, &ideology_manager, &good_manager, &modifier_manager](
- NationalFocusGroup const& group, ast::NodeCPtr group_node
- ) -> bool {
- return expect_dictionary([this, &group, &pop_manager, &ideology_manager, &good_manager, &modifier_manager](
- std::string_view identifier, ast::NodeCPtr node
+ ret &= expect_national_focus_group_dictionary(
+ [this, &pop_manager, &ideology_manager, &good_definition_manager, &modifier_manager](
+ NationalFocusGroup const& group, ast::NodeCPtr group_node
) -> bool {
- uint8_t icon = 0;
- bool has_flashpoint = false, own_provinces = true, outliner_show_as_percent = false;
- ModifierValue modifiers;
- Ideology const* loyalty_ideology = nullptr;
- fixed_point_t loyalty_value = 0;
- ConditionScript limit {
- scope_t::PROVINCE | scope_t::COUNTRY, scope_t::PROVINCE | scope_t::COUNTRY, scope_t::NO_SCOPE
- };
+ return expect_dictionary(
+ [this, &group, &pop_manager, &ideology_manager, &good_definition_manager, &modifier_manager](
+ std::string_view identifier, ast::NodeCPtr node
+ ) -> bool {
+ uint8_t icon = 0;
+ bool has_flashpoint = false, own_provinces = true, outliner_show_as_percent = false;
+ ModifierValue modifiers;
+ Ideology const* loyalty_ideology = nullptr;
+ fixed_point_t loyalty_value = 0;
+ ConditionScript limit {
+ scope_t::PROVINCE | scope_t::COUNTRY, scope_t::PROVINCE | scope_t::COUNTRY, scope_t::NO_SCOPE
+ };
- bool ret = modifier_manager.expect_modifier_value_and_keys(
- move_variable_callback(modifiers),
- "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)),
- "ideology", ZERO_OR_ONE,
- ideology_manager.expect_ideology_identifier(assign_variable_callback_pointer(loyalty_ideology)),
- "loyalty_value", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(loyalty_value)),
- "limit", ZERO_OR_ONE, limit.expect_script(),
- "has_flashpoint", ZERO_OR_ONE, expect_bool(assign_variable_callback(has_flashpoint)),
- "own_provinces", ZERO_OR_ONE, expect_bool(assign_variable_callback(own_provinces)),
- "outliner_show_as_percent", ZERO_OR_ONE, expect_bool(assign_variable_callback(outliner_show_as_percent))
- )(node);
+ bool ret = modifier_manager.expect_modifier_value_and_keys(
+ move_variable_callback(modifiers),
+ "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)),
+ "ideology", ZERO_OR_ONE,
+ ideology_manager.expect_ideology_identifier(assign_variable_callback_pointer(loyalty_ideology)),
+ "loyalty_value", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(loyalty_value)),
+ "limit", ZERO_OR_ONE, limit.expect_script(),
+ "has_flashpoint", ZERO_OR_ONE, expect_bool(assign_variable_callback(has_flashpoint)),
+ "own_provinces", ZERO_OR_ONE, expect_bool(assign_variable_callback(own_provinces)),
+ "outliner_show_as_percent", ZERO_OR_ONE,
+ expect_bool(assign_variable_callback(outliner_show_as_percent))
+ )(node);
- ret &= add_national_focus(
- identifier, group, icon, has_flashpoint, own_provinces, outliner_show_as_percent, std::move(modifiers),
- loyalty_ideology, loyalty_value, std::move(limit)
- );
+ ret &= add_national_focus(
+ identifier, group, icon, has_flashpoint, own_provinces, outliner_show_as_percent, std::move(modifiers),
+ loyalty_ideology, loyalty_value, std::move(limit)
+ );
- return ret;
- })(group_node);
- })(root);
+ return ret;
+ }
+ )(group_node);
+ }
+ )(root);
lock_national_foci();
return ret;
diff --git a/src/openvic-simulation/politics/NationalFocus.hpp b/src/openvic-simulation/politics/NationalFocus.hpp
index e1bf937..d8c5611 100644
--- a/src/openvic-simulation/politics/NationalFocus.hpp
+++ b/src/openvic-simulation/politics/NationalFocus.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/misc/Modifier.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/pop/Pop.hpp"
@@ -73,8 +73,8 @@ namespace OpenVic {
);
bool load_national_foci_file(
- PopManager const& pop_manager, IdeologyManager const& ideology_manager, GoodManager const& good_manager,
- ModifierManager const& modifier_manager, ast::NodeCPtr root
+ PopManager const& pop_manager, IdeologyManager const& ideology_manager,
+ GoodDefinitionManager const& good_definition_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root
);
bool parse_scripts(GameManager const& game_manager);
diff --git a/src/openvic-simulation/politics/PoliticsManager.hpp b/src/openvic-simulation/politics/PoliticsManager.hpp
index 4302072..82c89ed 100644
--- a/src/openvic-simulation/politics/PoliticsManager.hpp
+++ b/src/openvic-simulation/politics/PoliticsManager.hpp
@@ -24,11 +24,11 @@ namespace OpenVic {
return government_type_manager.load_government_types_file(ideology_manager, root);
}
inline bool load_national_foci_file(
- PopManager const& pop_manager, GoodManager const& good_manager, ModifierManager const& modifier_manager,
- ast::NodeCPtr root
+ PopManager const& pop_manager, GoodDefinitionManager const& good_definition_manager,
+ ModifierManager const& modifier_manager, ast::NodeCPtr root
) {
return national_focus_manager.load_national_foci_file(
- pop_manager, ideology_manager, good_manager, modifier_manager, root
+ pop_manager, ideology_manager, good_definition_manager, modifier_manager, root
);
}
inline bool load_rebels_file(ast::NodeCPtr root) {
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index 2490ef9..be484d9 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -124,9 +124,9 @@ PopType::PopType(
colour_t new_colour,
Strata const& new_strata,
sprite_t new_sprite,
- Good::good_map_t&& new_life_needs,
- Good::good_map_t&& new_everyday_needs,
- Good::good_map_t&& new_luxury_needs,
+ GoodDefinition::good_definition_map_t&& new_life_needs,
+ GoodDefinition::good_definition_map_t&& new_everyday_needs,
+ GoodDefinition::good_definition_map_t&& new_luxury_needs,
income_type_t new_life_needs_income_types,
income_type_t new_everyday_needs_income_types,
income_type_t new_luxury_needs_income_types,
@@ -233,9 +233,9 @@ bool PopManager::add_pop_type(
colour_t colour,
Strata const* strata,
PopType::sprite_t sprite,
- Good::good_map_t&& life_needs,
- Good::good_map_t&& everyday_needs,
- Good::good_map_t&& luxury_needs,
+ GoodDefinition::good_definition_map_t&& life_needs,
+ GoodDefinition::good_definition_map_t&& everyday_needs,
+ GoodDefinition::good_definition_map_t&& luxury_needs,
PopType::income_type_t life_needs_income_types,
PopType::income_type_t everyday_needs_income_types,
PopType::income_type_t luxury_needs_income_types,
@@ -396,12 +396,13 @@ static NodeCallback auto expect_needs_income(PopType::income_type_t& types) {
* POP-3, POP-4, POP-5, POP-6, POP-7, POP-8, POP-9, POP-10, POP-11, POP-12, POP-13, POP-14
*/
bool PopManager::load_pop_type_file(
- std::string_view filestem, GoodManager const& good_manager, IdeologyManager const& ideology_manager, ast::NodeCPtr root
+ std::string_view filestem, GoodDefinitionManager const& good_definition_manager, IdeologyManager const& ideology_manager,
+ ast::NodeCPtr root
) {
colour_t colour = colour_t::null();
Strata const* strata = nullptr;
PopType::sprite_t sprite = 0;
- Good::good_map_t life_needs, everyday_needs, luxury_needs;
+ GoodDefinition::good_definition_map_t life_needs, everyday_needs, luxury_needs;
PopType::income_type_t life_needs_income_types = NO_INCOME_TYPE, everyday_needs_income_types = NO_INCOME_TYPE,
luxury_needs_income_types = NO_INCOME_TYPE;
ast::NodeCPtr rebel_units = nullptr;
@@ -450,9 +451,12 @@ bool PopManager::load_pop_type_file(
"life_needs_income", ZERO_OR_ONE, expect_needs_income(life_needs_income_types),
"everyday_needs_income", ZERO_OR_ONE, expect_needs_income(everyday_needs_income_types),
"luxury_needs_income", ZERO_OR_ONE, expect_needs_income(luxury_needs_income_types),
- "luxury_needs", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(luxury_needs)),
- "everyday_needs", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(everyday_needs)),
- "life_needs", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(life_needs)),
+ "luxury_needs", ZERO_OR_ONE,
+ good_definition_manager.expect_good_definition_decimal_map(move_variable_callback(luxury_needs)),
+ "everyday_needs", ZERO_OR_ONE,
+ good_definition_manager.expect_good_definition_decimal_map(move_variable_callback(everyday_needs)),
+ "life_needs", ZERO_OR_ONE,
+ good_definition_manager.expect_good_definition_decimal_map(move_variable_callback(life_needs)),
"country_migration_target", ZERO_OR_ONE, country_migration_target.expect_conditional_weight(ConditionalWeight::FACTOR),
"migration_target", ZERO_OR_ONE, migration_target.expect_conditional_weight(ConditionalWeight::FACTOR),
"promote_to", ZERO_OR_ONE, assign_variable_callback(promote_to_node),
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index 7fc7456..f29a8fe 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -4,7 +4,7 @@
#include <ostream>
#include <tuple>
-#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
#include "openvic-simulation/pop/Culture.hpp"
#include "openvic-simulation/pop/Religion.hpp"
#include "openvic-simulation/scripts/ConditionalWeight.hpp"
@@ -126,9 +126,9 @@ namespace OpenVic {
private:
Strata const& PROPERTY(strata);
const sprite_t PROPERTY(sprite);
- Good::good_map_t PROPERTY(life_needs);
- Good::good_map_t PROPERTY(everyday_needs);
- Good::good_map_t PROPERTY(luxury_needs);
+ GoodDefinition::good_definition_map_t PROPERTY(life_needs);
+ GoodDefinition::good_definition_map_t PROPERTY(everyday_needs);
+ GoodDefinition::good_definition_map_t PROPERTY(luxury_needs);
income_type_t PROPERTY(life_needs_income_types);
income_type_t PROPERTY(everyday_needs_income_types);
income_type_t PROPERTY(luxury_needs_income_types);
@@ -164,9 +164,9 @@ namespace OpenVic {
colour_t new_colour,
Strata const& new_strata,
sprite_t new_sprite,
- Good::good_map_t&& new_life_needs,
- Good::good_map_t&& new_everyday_needs,
- Good::good_map_t&& new_luxury_needs,
+ GoodDefinition::good_definition_map_t&& new_life_needs,
+ GoodDefinition::good_definition_map_t&& new_everyday_needs,
+ GoodDefinition::good_definition_map_t&& new_luxury_needs,
income_type_t new_life_needs_income_types,
income_type_t new_everyday_needs_income_types,
income_type_t new_luxury_needs_income_types,
@@ -275,9 +275,9 @@ namespace OpenVic {
colour_t new_colour,
Strata const* strata,
PopType::sprite_t sprite,
- Good::good_map_t&& life_needs,
- Good::good_map_t&& everyday_needs,
- Good::good_map_t&& luxury_needs,
+ GoodDefinition::good_definition_map_t&& life_needs,
+ GoodDefinition::good_definition_map_t&& everyday_needs,
+ GoodDefinition::good_definition_map_t&& luxury_needs,
PopType::income_type_t life_needs_income_types,
PopType::income_type_t everyday_needs_income_types,
PopType::income_type_t luxury_needs_income_types,
@@ -312,8 +312,8 @@ namespace OpenVic {
void lock_all_pop_types();
bool load_pop_type_file(
- std::string_view filestem, GoodManager const& good_manager, IdeologyManager const& ideology_manager,
- ast::NodeCPtr root
+ std::string_view filestem, GoodDefinitionManager const& good_definition_manager,
+ IdeologyManager const& ideology_manager, ast::NodeCPtr root
);
bool load_delayed_parse_pop_type_data(UnitTypeManager const& unit_type_manager, IssueManager const& issue_manager);
diff --git a/src/openvic-simulation/scripts/Condition.cpp b/src/openvic-simulation/scripts/Condition.cpp
index 238d0f8..f754420 100644
--- a/src/openvic-simulation/scripts/Condition.cpp
+++ b/src/openvic-simulation/scripts/Condition.cpp
@@ -434,7 +434,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) {
);
import_identifiers(
- game_manager.get_economy_manager().get_good_manager().get_good_identifiers(),
+ game_manager.get_economy_manager().get_good_definition_manager().get_good_definition_identifiers(),
INTEGER,
COUNTRY,
NO_SCOPE,
@@ -499,7 +499,7 @@ callback_t<std::string_view> ConditionManager::expect_parse_identifier(
EXPECT_CALL(CULTURE, culture, game_manager.get_pop_manager().get_culture_manager(), "THIS", "FROM");
EXPECT_CALL(CULTURE_GROUP, culture_group, game_manager.get_pop_manager().get_culture_manager());
EXPECT_CALL(RELIGION, religion, game_manager.get_pop_manager().get_religion_manager(), "THIS", "FROM");
- EXPECT_CALL(TRADE_GOOD, good, game_manager.get_economy_manager().get_good_manager());
+ EXPECT_CALL(TRADE_GOOD, good_definition, game_manager.get_economy_manager().get_good_definition_manager());
EXPECT_CALL(BUILDING, building_type, game_manager.get_economy_manager().get_building_type_manager(), "FACTORY");
EXPECT_CALL(CASUS_BELLI, wargoal_type, game_manager.get_military_manager().get_wargoal_type_manager());
EXPECT_CALL(GOVERNMENT_TYPE, government_type, game_manager.get_politics_manager().get_government_type_manager());
diff --git a/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
index e811144..357157e 100644
--- a/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
+++ b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
@@ -552,8 +552,8 @@ namespace OpenVic {
void check_base_price(std::string identifier, std::string target_value, std::string req_name) {
// Get string of base_price from goods manager
- fixed_point_t base_price_fp = get_game_manager()->get_economy_manager().get_good_manager()
- .get_good_by_identifier(identifier)->get_base_price();
+ fixed_point_t base_price_fp = get_game_manager()->get_economy_manager().get_good_definition_manager()
+ .get_good_definition_by_identifier(identifier)->get_base_price();
std::stringstream ss;
// Use a single digit floating point of the value
ss << std::fixed << std::setprecision(1) << base_price_fp.to_double();
diff --git a/src/openvic-simulation/types/HasIdentifier.hpp b/src/openvic-simulation/types/HasIdentifier.hpp
index 9457e75..3f2d8a8 100644
--- a/src/openvic-simulation/types/HasIdentifier.hpp
+++ b/src/openvic-simulation/types/HasIdentifier.hpp
@@ -33,9 +33,9 @@ namespace OpenVic {
HasIdentifier(std::string_view new_identifier): identifier { new_identifier } {
assert(!identifier.empty());
}
+ HasIdentifier(HasIdentifier const&) = default;
public:
- HasIdentifier(HasIdentifier const&) = delete;
HasIdentifier(HasIdentifier&&) = default;
HasIdentifier& operator=(HasIdentifier const&) = delete;
HasIdentifier& operator=(HasIdentifier&&) = delete;
@@ -59,9 +59,9 @@ namespace OpenVic {
_HasColour(ColourT new_colour, bool cannot_be_null): colour { new_colour } {
assert(!cannot_be_null || !colour.is_null());
}
+ _HasColour(_HasColour const&) = default;
public:
- _HasColour(_HasColour const&) = delete;
_HasColour(_HasColour&&) = default;
_HasColour& operator=(_HasColour const&) = delete;
_HasColour& operator=(_HasColour&&) = delete;
@@ -75,9 +75,9 @@ namespace OpenVic {
protected:
_HasIdentifierAndColour(std::string_view new_identifier, ColourT new_colour, bool cannot_be_null)
: HasIdentifier { new_identifier }, _HasColour<ColourT> { new_colour, cannot_be_null } {}
+ _HasIdentifierAndColour(_HasIdentifierAndColour const&) = default;
public:
- _HasIdentifierAndColour(_HasIdentifierAndColour const&) = delete;
_HasIdentifierAndColour(_HasIdentifierAndColour&&) = default;
_HasIdentifierAndColour& operator=(_HasIdentifierAndColour const&) = delete;
_HasIdentifierAndColour& operator=(_HasIdentifierAndColour&&) = delete;