diff options
Diffstat (limited to 'src/openvic-simulation/map/State.cpp')
-rw-r--r-- | src/openvic-simulation/map/State.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp index 020b6f1..31ea05f 100644 --- a/src/openvic-simulation/map/State.cpp +++ b/src/openvic-simulation/map/State.cpp @@ -5,6 +5,7 @@ #include "openvic-simulation/map/MapInstance.hpp" #include "openvic-simulation/map/ProvinceInstance.hpp" #include "openvic-simulation/map/Region.hpp" +#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" #include "openvic-simulation/utility/StringUtils.hpp" using namespace OpenVic; @@ -65,10 +66,19 @@ void State::update_gamestate() { const int32_t potential_workforce_in_state = 0; // sum of worker pops, regardless of employment const int32_t potential_employment_in_state = 0; // sum of (factory level * production method base_workforce_size) - industrial_power = total_factory_levels_in_state * std::clamp( - (fixed_point_t { potential_workforce_in_state } / 100).floor() * 400 / potential_employment_in_state, - fixed_point_t::_0_20(), fixed_point_t::_4() - ); + fixed_point_t workforce_scalar; + constexpr fixed_point_t min_workforce_scalar = fixed_point_t::_0_20(); + constexpr fixed_point_t max_workforce_scalar = fixed_point_t::_4(); + if (potential_employment_in_state <= 0) { + workforce_scalar = min_workforce_scalar; + } else { + workforce_scalar = std::clamp( + (fixed_point_t { potential_workforce_in_state } / 100).floor() * 400 / potential_employment_in_state, + min_workforce_scalar, max_workforce_scalar + ); + } + + industrial_power = total_factory_levels_in_state * workforce_scalar; } /* Whether two provinces in the same region should be grouped into the same state or not. |