aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-09-28 11:29:57 +0200
committer zaaarf <zaaarf@proton.me>2023-09-28 11:29:57 +0200
commit33a2a1e5fcac60ddd0f2840449488e48069493ec (patch)
tree059cf0a5e900b4a4e3c32d8c14b464678251777f /src
parent8256fe4c9468e23f5397d92796a741893b9469bc (diff)
fix: use timespan for unit build time
Diffstat (limited to 'src')
-rw-r--r--src/openvic-simulation/units/Unit.cpp10
-rw-r--r--src/openvic-simulation/units/Unit.hpp7
2 files changed, 10 insertions, 7 deletions
diff --git a/src/openvic-simulation/units/Unit.cpp b/src/openvic-simulation/units/Unit.cpp
index f57e0a7..b965f93 100644
--- a/src/openvic-simulation/units/Unit.cpp
+++ b/src/openvic-simulation/units/Unit.cpp
@@ -52,7 +52,7 @@ fixed_point_t Unit::get_maximum_speed() const {
return maximum_speed;
}
-uint32_t Unit::get_build_time() const {
+Timespan Unit::get_build_time() const {
return build_time;
}
@@ -210,14 +210,14 @@ bool UnitManager::add_naval_unit(const std::string_view identifier, UNIT_PARAMS,
return units.add_item(NavalUnit { identifier, UNIT_ARGS, NAVY_ARGS });
}
-//TODO forgot fcking capital flag for naval units
+
bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr root) {
return NodeTools::expect_dictionary([this, &good_manager](std::string_view key, ast::NodeCPtr value) -> bool {
Unit::icon_t icon;
std::string_view category, type;
Unit::sprite_t sprite;
bool active = true, floating_flag;
- uint32_t priority, build_time;
+ uint32_t priority, build_time_days;
fixed_point_t maximum_speed, max_strength, default_organisation, weighted_value, supply_consumption;
std::map<const Good*, fixed_point_t> build_cost, supply_cost;
@@ -234,12 +234,14 @@ bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr
"default_organisation", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(default_organisation)),
"maximum_speed", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(maximum_speed)),
"weighted_value", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(weighted_value)),
- "build_time", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("unit build time", build_time)),
+ "build_time", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("unit build time", build_time_days)),
"build_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(assign_variable_callback(build_cost)),
"supply_consumption", ONE_EXACTLY, expect_fixed_point(move_variable_callback(supply_consumption)),
"supply_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(move_variable_callback(supply_cost))
)(value);
+ Timespan build_time = { build_time_days };
+
if (category == "land") {
fixed_point_t reconnaissance, attack, defence, discipline, support, maneuver, siege;
diff --git a/src/openvic-simulation/units/Unit.hpp b/src/openvic-simulation/units/Unit.hpp
index 507adbd..dc7c00f 100644
--- a/src/openvic-simulation/units/Unit.hpp
+++ b/src/openvic-simulation/units/Unit.hpp
@@ -7,10 +7,11 @@
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
#include "openvic-simulation/dataloader/NodeTools.hpp"
#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/types/Date.hpp"
#define UNIT_PARAMS Unit::icon_t icon, Unit::sprite_t sprite, bool active, std::string_view type, \
bool floating_flag, uint32_t priority, fixed_point_t max_strength, fixed_point_t default_organisation, \
- fixed_point_t maximum_speed, fixed_point_t weighted_value, uint32_t build_time, \
+ fixed_point_t maximum_speed, fixed_point_t weighted_value, Timespan build_time, \
std::map<const Good*, fixed_point_t> build_cost, fixed_point_t supply_consumption, \
std::map<const Good*, fixed_point_t> supply_cost
#define LAND_PARAMS fixed_point_t reconnaissance, fixed_point_t attack, fixed_point_t defence, fixed_point_t discipline, \
@@ -40,7 +41,7 @@ namespace OpenVic {
const fixed_point_t maximum_speed;
const fixed_point_t weighted_value;
- const uint32_t build_time;
+ const Timespan build_time;
const std::map<const Good*, fixed_point_t> build_cost;
const fixed_point_t supply_consumption;
const std::map<const Good*, fixed_point_t> supply_cost;
@@ -64,7 +65,7 @@ namespace OpenVic {
fixed_point_t get_maximum_speed() const;
fixed_point_t get_weighted_value() const;
- uint32_t get_build_time() const;
+ Timespan get_build_time() const;
std::map<const Good*, fixed_point_t> const& get_build_cost() const;
fixed_point_t get_supply_consumption() const;
std::map<const Good*, fixed_point_t> const& get_supply_cost() const;