aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/GoodInstance.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-06-13 00:24:00 +0200
committer hop311 <hop3114@gmail.com>2024-06-13 00:24:00 +0200
commit4b39e77304094708d5c503b6a221386408cc4409 (patch)
tree7ba5a06714c267185dd3a59aabc6556a105c122f /src/openvic-simulation/economy/GoodInstance.cpp
parentc0ba822ee46551a40ad6b43e8f56b80e27ae35b5 (diff)
Separated GameManager into Definition and Instance Managersinstance-definition-managers
Diffstat (limited to 'src/openvic-simulation/economy/GoodInstance.cpp')
-rw-r--r--src/openvic-simulation/economy/GoodInstance.cpp10
1 files changed, 8 insertions, 2 deletions
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;
}