aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/economy')
-rw-r--r--src/openvic-simulation/economy/EconomyManager.hpp6
-rw-r--r--src/openvic-simulation/economy/GoodInstance.cpp10
-rw-r--r--src/openvic-simulation/economy/GoodInstance.hpp2
-rw-r--r--src/openvic-simulation/economy/ProductionType.cpp8
-rw-r--r--src/openvic-simulation/economy/ProductionType.hpp4
5 files changed, 15 insertions, 15 deletions
diff --git a/src/openvic-simulation/economy/EconomyManager.hpp b/src/openvic-simulation/economy/EconomyManager.hpp
index caac9c2..668774d 100644
--- a/src/openvic-simulation/economy/EconomyManager.hpp
+++ b/src/openvic-simulation/economy/EconomyManager.hpp
@@ -2,7 +2,6 @@
#include "openvic-simulation/economy/BuildingType.hpp"
#include "openvic-simulation/economy/GoodDefinition.hpp"
-#include "openvic-simulation/economy/GoodInstance.hpp"
#include "openvic-simulation/economy/ProductionType.hpp"
namespace OpenVic {
@@ -10,7 +9,6 @@ namespace OpenVic {
private:
BuildingTypeManager PROPERTY_REF(building_type_manager);
GoodDefinitionManager PROPERTY_REF(good_definition_manager);
- GoodInstanceManager PROPERTY_REF(good_instance_manager);
ProductionTypeManager PROPERTY_REF(production_type_manager);
public:
@@ -23,9 +21,5 @@ namespace OpenVic {
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/GoodInstance.cpp b/src/openvic-simulation/economy/GoodInstance.cpp
index 937706d..6fe3a2f 100644
--- a/src/openvic-simulation/economy/GoodInstance.cpp
+++ b/src/openvic-simulation/economy/GoodInstance.cpp
@@ -6,8 +6,12 @@ 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();
+bool GoodInstanceManager::setup(GoodDefinitionManager const& good_definition_manager) {
+ if (good_instances_are_locked()) {
+ Logger::error("Cannot set up good instances - they are already locked!");
+ return false;
+ }
+
good_instances.reserve(good_definition_manager.get_good_definition_count());
bool ret = true;
@@ -16,5 +20,7 @@ bool GoodInstanceManager::setup_good_instances(GoodDefinitionManager const& good
ret &= good_instances.add_item({ good });
}
+ lock_good_instances();
+
return ret;
}
diff --git a/src/openvic-simulation/economy/GoodInstance.hpp b/src/openvic-simulation/economy/GoodInstance.hpp
index 3c27209..555ef87 100644
--- a/src/openvic-simulation/economy/GoodInstance.hpp
+++ b/src/openvic-simulation/economy/GoodInstance.hpp
@@ -28,6 +28,6 @@ namespace OpenVic {
IdentifierRegistry<GoodInstance> IDENTIFIER_REGISTRY(good_instance);
public:
- bool setup_good_instances(GoodDefinitionManager const& good_definition_manager);
+ bool setup(GoodDefinitionManager const& good_definition_manager);
};
}
diff --git a/src/openvic-simulation/economy/ProductionType.cpp b/src/openvic-simulation/economy/ProductionType.cpp
index 4f87ba5..9b5a42b 100644
--- a/src/openvic-simulation/economy/ProductionType.cpp
+++ b/src/openvic-simulation/economy/ProductionType.cpp
@@ -41,10 +41,10 @@ ProductionType::ProductionType(
farm { new_is_farm },
mine { new_is_mine } {}
-bool ProductionType::parse_scripts(GameManager const& game_manager) {
+bool ProductionType::parse_scripts(DefinitionManager const& definition_manager) {
bool ret = true;
for (auto& [bonus_script, bonus_value] : bonuses) {
- ret &= bonus_script.parse_script(false, game_manager);
+ ret &= bonus_script.parse_script(false, definition_manager);
}
return ret;
}
@@ -309,10 +309,10 @@ bool ProductionTypeManager::load_production_types_file(
return ret;
}
-bool ProductionTypeManager::parse_scripts(GameManager const& game_manager) {
+bool ProductionTypeManager::parse_scripts(DefinitionManager const& definition_manager) {
bool ret = true;
for (ProductionType& production_type : production_types.get_items()) {
- ret &= production_type.parse_scripts(game_manager);
+ ret &= production_type.parse_scripts(definition_manager);
}
return ret;
}
diff --git a/src/openvic-simulation/economy/ProductionType.hpp b/src/openvic-simulation/economy/ProductionType.hpp
index 7480206..ed3b84f 100644
--- a/src/openvic-simulation/economy/ProductionType.hpp
+++ b/src/openvic-simulation/economy/ProductionType.hpp
@@ -71,7 +71,7 @@ namespace OpenVic {
bool new_is_mine
);
- bool parse_scripts(GameManager const& game_manager);
+ bool parse_scripts(DefinitionManager const& definition_manager);
public:
ProductionType(ProductionType&&) = default;
@@ -114,6 +114,6 @@ namespace OpenVic {
GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager, ast::NodeCPtr root
);
- bool parse_scripts(GameManager const& game_manager);
+ bool parse_scripts(DefinitionManager const& definition_manager);
};
}