aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/BuildingInstance.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-12-25 13:21:38 +0100
committer GitHub <noreply@github.com>2023-12-25 13:21:38 +0100
commitbff91f78f9c5339079c10adfbf8232e5159c1a2d (patch)
treea40b49f6dc155fc5c3c47b623926764642242677 /src/openvic-simulation/economy/BuildingInstance.cpp
parentdcef842d5e070854913f9e61e4a1f485870ae703 (diff)
parent48204950cd8d48e6df26ed6892f57b3d9da823de (diff)
Merge pull request #103 from OpenVicProject/province-buildings
Province building scaffolding
Diffstat (limited to 'src/openvic-simulation/economy/BuildingInstance.cpp')
-rw-r--r--src/openvic-simulation/economy/BuildingInstance.cpp5
1 files changed, 3 insertions, 2 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;
}