aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-12-25 01:22:01 +0100
committer hop311 <hop3114@gmail.com>2023-12-25 01:22:01 +0100
commit48204950cd8d48e6df26ed6892f57b3d9da823de (patch)
tree99822c48f16eb1495f7ea9fe669bcb43e7a6001c /src/openvic-simulation/economy
parentbf4e7368600bb425b6612231fbb84de34ec99a27 (diff)
Province building scaffolding
Diffstat (limited to 'src/openvic-simulation/economy')
-rw-r--r--src/openvic-simulation/economy/BuildingInstance.cpp5
-rw-r--r--src/openvic-simulation/economy/BuildingType.cpp35
-rw-r--r--src/openvic-simulation/economy/BuildingType.hpp5
-rw-r--r--src/openvic-simulation/economy/ProductionType.cpp5
4 files changed, 40 insertions, 10 deletions
diff --git a/src/openvic-simulation/economy/BuildingInstance.cpp b/src/openvic-simulation/economy/BuildingInstance.cpp
index 597b89e..047b759 100644
--- a/src/openvic-simulation/economy/BuildingInstance.cpp
+++ b/src/openvic-simulation/economy/BuildingInstance.cpp
@@ -4,7 +4,7 @@ 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 } {}
+ expansion_state { ExpansionState::CannotExpand }, start_date {}, end_date {}, expansion_progress { 0.0f } {}
bool BuildingInstance::_can_expand() const {
return level < building_type.get_max_level();
@@ -29,7 +29,8 @@ void BuildingInstance::update_state(Date today) {
end_date = start_date + building_type.get_build_time();
break;
case ExpansionState::Expanding:
- expansion_progress = static_cast<double>(today - start_date) / static_cast<double>(end_date - start_date);
+ expansion_progress =
+ static_cast<float>((today - start_date).to_int()) / static_cast<float>((end_date - start_date).to_int());
break;
default: expansion_state = _can_expand() ? ExpansionState::CanExpand : ExpansionState::CannotExpand;
}
diff --git a/src/openvic-simulation/economy/BuildingType.cpp b/src/openvic-simulation/economy/BuildingType.cpp
index 3d44c8c..c11933f 100644
--- a/src/openvic-simulation/economy/BuildingType.cpp
+++ b/src/openvic-simulation/economy/BuildingType.cpp
@@ -104,18 +104,41 @@ bool BuildingTypeManager::load_buildings_file(
min_modifier_prefix.append(building_type.get_identifier()), false, ModifierEffect::format_t::INT
);
+ if (building_type.is_in_province()) {
+ province_building_types.emplace_back(&building_type);
+ }
+
if (building_type.is_port()) {
- if (port_building_type == nullptr) {
- port_building_type = &building_type;
+ if (building_type.is_in_province()) {
+ if (port_building_type == nullptr) {
+ port_building_type = &building_type;
+ } else {
+ Logger::error(
+ "Building type ", building_type, " is marked as a port, but we are already using ", port_building_type,
+ " as the port building type!"
+ );
+ ret = false;
+ }
} else {
- Logger::error(
- "Building type ", building_type, " is marked as a port, but we are already using ", port_building_type,
- " as the port building type!"
- );
+ Logger::error("Building type ", building_type, " is marked as a port, but is not a province building!");
ret = false;
}
}
}
+ if (port_building_type == nullptr) {
+ Logger::error("No port building type found!");
+ ret = false;
+ }
+ if (province_building_types.empty()) {
+ Logger::error("No province building types found!");
+ ret = false;
+ } else {
+ Logger::info(
+ "Found ", province_building_types.size(), " province building types out of ", get_building_type_count(),
+ " total building types"
+ );
+ }
+
return ret;
}
diff --git a/src/openvic-simulation/economy/BuildingType.hpp b/src/openvic-simulation/economy/BuildingType.hpp
index 27cedfd..b1eb6f8 100644
--- a/src/openvic-simulation/economy/BuildingType.hpp
+++ b/src/openvic-simulation/economy/BuildingType.hpp
@@ -47,11 +47,11 @@ namespace OpenVic {
bool PROPERTY(strategic_factory);
bool PROPERTY(advanced_factory);
- level_t PROPERTY(fort_level); // probably the step-per-level
+ level_t PROPERTY(fort_level); // fort bonus step-per-level
uint64_t PROPERTY(naval_capacity);
std::vector<fixed_point_t> PROPERTY(colonial_points);
- bool PROPERTY(in_province); // province
+ bool PROPERTY_CUSTOM_PREFIX(in_province, is); // province
bool PROPERTY(one_per_state);
fixed_point_t PROPERTY(colonial_range);
@@ -74,6 +74,7 @@ namespace OpenVic {
private:
IdentifierRegistry<BuildingType> IDENTIFIER_REGISTRY(building_type);
+ std::vector<BuildingType const*> PROPERTY(province_building_types);
BuildingType const* PROPERTY(port_building_type);
public:
diff --git a/src/openvic-simulation/economy/ProductionType.cpp b/src/openvic-simulation/economy/ProductionType.cpp
index a19b7bf..05529f5 100644
--- a/src/openvic-simulation/economy/ProductionType.cpp
+++ b/src/openvic-simulation/economy/ProductionType.cpp
@@ -212,5 +212,10 @@ bool ProductionTypeManager::load_production_types_file(
production_types.lock();
+ if (rgo_owner_sprite <= 0) {
+ Logger::error("No RGO owner pop type sprite found!");
+ ret = false;
+ }
+
return ret;
}