aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/units/Unit.cpp42
-rw-r--r--src/openvic-simulation/units/Unit.hpp40
2 files changed, 41 insertions, 41 deletions
diff --git a/src/openvic-simulation/units/Unit.cpp b/src/openvic-simulation/units/Unit.cpp
index 0ec4aa1..ebf4985 100644
--- a/src/openvic-simulation/units/Unit.cpp
+++ b/src/openvic-simulation/units/Unit.cpp
@@ -40,11 +40,11 @@ uint32_t Unit::get_priority() const {
return priority;
}
-uint32_t Unit::get_max_strength() const {
+fixed_point_t Unit::get_max_strength() const {
return max_strength;
}
-uint32_t Unit::get_default_organisation() const {
+fixed_point_t Unit::get_default_organisation() const {
return default_organisation;
}
@@ -60,7 +60,7 @@ fixed_point_t Unit::get_weighted_value() const {
return weighted_value;
}
-std::map<const Good*, fixed_point_t> Unit::get_build_cost() const {
+std::map<const Good*, fixed_point_t> const& Unit::get_build_cost() const {
return build_cost;
}
@@ -68,7 +68,7 @@ fixed_point_t Unit::get_supply_consumption() const {
return supply_consumption;
}
-std::map<const Good*, fixed_point_t> Unit::get_supply_cost() const {
+std::map<const Good*, fixed_point_t> const& Unit::get_supply_cost() const {
return supply_cost;
}
@@ -130,7 +130,7 @@ NavalUnit::sound_t NavalUnit::get_select_sound() const {
return select_sound;
}
-uint32_t NavalUnit::get_colonial_points() const {
+fixed_point_t NavalUnit::get_colonial_points() const {
return colonial_points;
}
@@ -146,15 +146,15 @@ int32_t NavalUnit::get_limit_per_port() const {
return limit_per_port;
}
-uint32_t NavalUnit::get_supply_consumption_score() const {
+fixed_point_t NavalUnit::get_supply_consumption_score() const {
return supply_consumption_score;
}
-uint32_t NavalUnit::get_hull() const {
+fixed_point_t NavalUnit::get_hull() const {
return hull;
}
-uint32_t NavalUnit::get_gun_power() const {
+fixed_point_t NavalUnit::get_gun_power() const {
return gun_power;
}
@@ -166,11 +166,11 @@ fixed_point_t NavalUnit::get_evasion() const {
return evasion;
}
-uint32_t NavalUnit::get_torpedo_attack() const {
+fixed_point_t NavalUnit::get_torpedo_attack() const {
return torpedo_attack;
}
-UnitManager::UnitManager(GoodManager& good_manager) : good_manager { good_manager }, units { "units " } {};
+UnitManager::UnitManager(GoodManager& good_manager) : good_manager { good_manager }, units { "units" } {};
bool UnitManager::_check_shared_parameters(const std::string_view identifier, UNIT_PARAMS) {
if (identifier.empty()) {
@@ -217,8 +217,8 @@ bool UnitManager::load_unit_file(ast::NodeCPtr root) {
std::string_view category, type;
Unit::sprite_t sprite;
bool active = true, floating_flag;
- uint32_t priority, max_strength, default_organisation, build_time;
- fixed_point_t maximum_speed, weighted_value, supply_consumption;
+ uint32_t priority, build_time;
+ fixed_point_t maximum_speed, max_strength, default_organisation, weighted_value, supply_consumption;
std::map<const Good*, fixed_point_t> build_cost, supply_cost;
//shared
@@ -230,8 +230,8 @@ bool UnitManager::load_unit_file(ast::NodeCPtr root) {
"unit_type", ONE_EXACTLY, expect_identifier(assign_variable_callback(type)),
"floating_flag", ONE_EXACTLY, expect_bool(assign_variable_callback(floating_flag)),
"priority", ONE_EXACTLY, expect_uint(assign_variable_callback(priority)),
- "max_strength", ONE_EXACTLY, expect_uint(assign_variable_callback(max_strength)),
- "default_organisation", ONE_EXACTLY, expect_uint(assign_variable_callback(default_organisation)),
+ "max_strength", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(max_strength)),
+ "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(build_time)),
@@ -260,9 +260,9 @@ bool UnitManager::load_unit_file(ast::NodeCPtr root) {
Unit::icon_t naval_icon;
bool sail = false, transport = false, capital = false, build_overseas = false;
Unit::sound_t move_sound, select_sound; //TODO defaults for both
- uint32_t min_port_level, supply_consumption_score, hull, gun_power, colonial_points = 0, torpedo_attack = 0;
+ uint32_t min_port_level;
int32_t limit_per_port;
- fixed_point_t fire_range, evasion;
+ fixed_point_t fire_range, evasion, supply_consumption_score, hull, gun_power, colonial_points = 0, torpedo_attack = 0;
ret &= expect_dictionary_keys(ALLOW_OTHER_KEYS,
"naval_icon", ONE_EXACTLY, expect_uint(assign_variable_callback(naval_icon)),
@@ -271,16 +271,16 @@ bool UnitManager::load_unit_file(ast::NodeCPtr root) {
"capital", ZERO_OR_ONE, expect_bool(assign_variable_callback(capital)),
"move_sound", ZERO_OR_ONE, expect_identifier(assign_variable_callback(move_sound)),
"select_sound", ZERO_OR_ONE, expect_identifier(assign_variable_callback(select_sound)),
- "colonial_points", ZERO_OR_ONE, expect_uint(assign_variable_callback(colonial_points)),
+ "colonial_points", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(colonial_points)),
"can_build_overseas", ZERO_OR_ONE, expect_bool(assign_variable_callback(build_overseas)),
"min_port_level", ONE_EXACTLY, expect_uint(assign_variable_callback(min_port_level)),
"limit_per_port", ONE_EXACTLY, expect_int(assign_variable_callback(limit_per_port)),
- "supply_consumption_score", ONE_EXACTLY, expect_uint(assign_variable_callback(supply_consumption_score)),
- "hull", ONE_EXACTLY, expect_uint(assign_variable_callback(hull)),
- "gun_power", ONE_EXACTLY, expect_uint(assign_variable_callback(gun_power)),
+ "supply_consumption_score", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(supply_consumption_score)),
+ "hull", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(hull)),
+ "gun_power", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(gun_power)),
"fire_range", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(fire_range)),
"evasion", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(evasion)),
- "torpedo_attack", ZERO_OR_ONE, expect_uint(assign_variable_callback(torpedo_attack))
+ "torpedo_attack", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(torpedo_attack))
)(value);
ret &= add_naval_unit(key, UNIT_ARGS, NAVY_ARGS);
diff --git a/src/openvic-simulation/units/Unit.hpp b/src/openvic-simulation/units/Unit.hpp
index e95650e..c9d3434 100644
--- a/src/openvic-simulation/units/Unit.hpp
+++ b/src/openvic-simulation/units/Unit.hpp
@@ -9,16 +9,16 @@
#include "openvic-simulation/economy/Good.hpp"
#define UNIT_PARAMS Unit::icon_t icon, Unit::sprite_t sprite, bool active, std::string_view type, \
- bool floating_flag, uint32_t priority, uint32_t max_strength, uint32_t default_organisation, \
+ 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, \
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, \
fixed_point_t support, fixed_point_t maneuver, fixed_point_t siege
#define NAVY_PARAMS Unit::icon_t naval_icon, bool sail, bool transport, bool capital, Unit::sound_t move_sound, \
- Unit::sound_t select_sound, uint32_t colonial_points, bool build_overseas, uint32_t min_port_level, \
- int32_t limit_per_port, uint32_t supply_consumption_score, uint32_t hull, uint32_t gun_power, \
- fixed_point_t fire_range, fixed_point_t evasion, uint32_t torpedo_attack
+ Unit::sound_t select_sound, fixed_point_t colonial_points, bool build_overseas, uint32_t min_port_level, \
+ int32_t limit_per_port, fixed_point_t supply_consumption_score, fixed_point_t hull, fixed_point_t gun_power, \
+ fixed_point_t fire_range, fixed_point_t evasion, fixed_point_t torpedo_attack
namespace OpenVic {
struct Unit : HasIdentifier {
@@ -35,8 +35,8 @@ namespace OpenVic {
const bool floating_flag;
const uint32_t priority;
- const uint32_t max_strength;
- const uint32_t default_organisation;
+ const fixed_point_t max_strength;
+ const fixed_point_t default_organisation;
const fixed_point_t maximum_speed;
const fixed_point_t weighted_value;
@@ -59,15 +59,15 @@ namespace OpenVic {
bool has_floating_flag() const;
uint32_t get_priority() const;
- uint32_t get_max_strength() const;
- uint32_t get_default_organisation() const;
+ fixed_point_t get_max_strength() const;
+ fixed_point_t get_default_organisation() const;
fixed_point_t get_maximum_speed() const;
fixed_point_t get_weighted_value() const;
uint32_t get_build_time() const;
- std::map<const Good*, fixed_point_t> get_build_cost() 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> get_supply_cost() const;
+ std::map<const Good*, fixed_point_t> const& get_supply_cost() const;
};
struct LandUnit : Unit {
@@ -106,17 +106,17 @@ namespace OpenVic {
const bool capital;
const sound_t move_sound;
const sound_t select_sound;
- const uint32_t colonial_points;
+ const fixed_point_t colonial_points;
const bool build_overseas;
const uint32_t min_port_level;
const int32_t limit_per_port;
- const uint32_t supply_consumption_score;
+ const fixed_point_t supply_consumption_score;
- const uint32_t hull;
- const uint32_t gun_power;
+ const fixed_point_t hull;
+ const fixed_point_t gun_power;
const fixed_point_t fire_range;
const fixed_point_t evasion;
- const uint32_t torpedo_attack;
+ const fixed_point_t torpedo_attack;
NavalUnit(std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS);
@@ -129,17 +129,17 @@ namespace OpenVic {
bool is_capital() const;
sound_t get_move_sound() const;
sound_t get_select_sound() const;
- uint32_t get_colonial_points() const;
+ fixed_point_t get_colonial_points() const;
bool can_build_overseas() const;
uint32_t get_min_port_level() const;
int32_t get_limit_per_port() const;
- uint32_t get_supply_consumption_score() const;
+ fixed_point_t get_supply_consumption_score() const;
- uint32_t get_hull() const;
- uint32_t get_gun_power() const;
+ fixed_point_t get_hull() const;
+ fixed_point_t get_gun_power() const;
fixed_point_t get_fire_range() const;
fixed_point_t get_evasion() const;
- uint32_t get_torpedo_attack() const;
+ fixed_point_t get_torpedo_attack() const;
};
struct UnitManager {