aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/State.cpp
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2024-10-21 14:09:40 +0200
committer wvpm <24685035+wvpm@users.noreply.github.com>2024-10-26 16:49:08 +0200
commit3daebe5db14949f55be2c50220323138260dbaea (patch)
tree46039d0eb5d630cf000e94aed584aebaaa8f3f9b /src/openvic-simulation/map/State.cpp
parentc88cf59997529cbca008f9a2b629822de9deaa2a (diff)
contextual modifier parsingcontextual_modifier_parsing
Diffstat (limited to 'src/openvic-simulation/map/State.cpp')
-rw-r--r--src/openvic-simulation/map/State.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp
index 020b6f1..619f97b 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,16 @@ 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 unclamped_score_per_factory = fixed_point_t::_0();
+
+ if (potential_employment_in_state > 0) {
+ unclamped_score_per_factory = (fixed_point_t { potential_workforce_in_state } / fixed_point_t::_100()).floor() * 400 / potential_employment_in_state;
+ } else {
+ industrial_power = total_factory_levels_in_state * std::clamp(
+ unclamped_score_per_factory,
+ fixed_point_t::_0_20(), fixed_point_t::_4()
+ );
+ }
}
/* Whether two provinces in the same region should be grouped into the same state or not.