aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/military
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-10-28 11:39:08 +0200
committer hop311 <hop3114@gmail.com>2023-10-29 20:42:47 +0100
commit164264b047921dbe1567d2af183e1cffb200a8cb (patch)
tree21c3c81f65ac3259db4808ebe9fd32a94ca993af /src/openvic-simulation/military
parentd8ec90f07342876e9331819bd3cc372050f78248 (diff)
Astyle formatting (with manual cleanup)
Diffstat (limited to 'src/openvic-simulation/military')
-rw-r--r--src/openvic-simulation/military/Deployment.cpp175
-rw-r--r--src/openvic-simulation/military/Deployment.hpp6
-rw-r--r--src/openvic-simulation/military/LeaderTrait.cpp3
-rw-r--r--src/openvic-simulation/military/Unit.cpp139
-rw-r--r--src/openvic-simulation/military/Unit.hpp16
5 files changed, 181 insertions, 158 deletions
diff --git a/src/openvic-simulation/military/Deployment.cpp b/src/openvic-simulation/military/Deployment.cpp
index d2637b1..441142d 100644
--- a/src/openvic-simulation/military/Deployment.cpp
+++ b/src/openvic-simulation/military/Deployment.cpp
@@ -5,8 +5,11 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-Deployment::Deployment(std::string_view new_path, std::vector<Army>&& new_armies, std::vector<Navy>&& new_navies, std::vector<Leader>&& new_leaders)
- : HasIdentifier { new_path }, armies { std::move(new_armies) }, navies { std::move(new_navies) }, leaders { std::move(new_leaders) } {}
+Deployment::Deployment(
+ std::string_view new_path, std::vector<Army>&& new_armies,
+ std::vector<Navy>&& new_navies, std::vector<Leader>&& new_leaders
+) : HasIdentifier { new_path }, armies { std::move(new_armies) },
+ navies { std::move(new_navies) }, leaders { std::move(new_leaders) } {}
const std::vector<Army>& Deployment::get_armies() const {
return armies;
@@ -22,7 +25,8 @@ const std::vector<Leader>& Deployment::get_leaders() const {
DeploymentManager::DeploymentManager() : deployments { "deployments" } {}
-bool DeploymentManager::add_deployment(std::string_view path, std::vector<Army>&& armies, std::vector<Navy>&& navies, std::vector<Leader>&& leaders) {
+bool DeploymentManager::add_deployment(std::string_view path, std::vector<Army>&& armies,
+ std::vector<Navy>&& navies, std::vector<Leader>&& leaders) {
if (path.empty()) {
Logger::error("Attemped to load order of battle with no path! Something is very wrong!");
return false;
@@ -42,84 +46,97 @@ bool DeploymentManager::load_oob_file(GameManager& game_manager, std::string_vie
bool ret = expect_dictionary_keys_and_default(
key_value_success_callback, // TODO: load SOI information
"leader", ZERO_OR_MORE, [&leaders, &game_manager](ast::NodeCPtr node) -> bool {
- std::string_view name;
- Unit::type_t type;
- Date date;
- LeaderTrait const* personality;
- LeaderTrait const* background;
- fixed_point_t prestige = 0;
-
- bool ret = expect_dictionary_keys(
- "name", ONE_EXACTLY, expect_string(assign_variable_callback(name), false),
- "date", ONE_EXACTLY, expect_identifier_or_string(expect_date_str(assign_variable_callback(date))),
- "type", ONE_EXACTLY, expect_identifier([&type](std::string_view leader_type) -> bool {
- if (leader_type == "land") {
- type = Unit::type_t::LAND;
- } else {
- type = Unit::type_t::NAVAL;
- }
- return true;
- }),
- "personality", ONE_EXACTLY, game_manager.get_military_manager().get_leader_trait_manager().expect_leader_trait_identifier(assign_variable_callback_pointer(personality)),
- "background", ONE_EXACTLY, game_manager.get_military_manager().get_leader_trait_manager().expect_leader_trait_identifier(assign_variable_callback_pointer(background)),
- "prestige", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(prestige)),
- "picture", ZERO_OR_ONE, success_callback
- )(node);
-
- if (!personality->is_personality_trait()) {
- Logger::error("Leader ", name, " has personality ", personality->get_identifier(), " which is not a personality trait!");
- return false;
- }
- if (!background->is_background_trait()) {
- Logger::error("Leader ", name, " has background ", background->get_identifier(), " which is not a background trait!");
- return false;
- }
-
- leaders.push_back(Leader{ std::string(name), type, date, personality, background, prestige });
- return ret; },
+ std::string_view name;
+ Unit::type_t type;
+ Date date;
+ LeaderTrait const* personality = nullptr;
+ LeaderTrait const* background = nullptr;
+ fixed_point_t prestige = 0;
+
+ bool ret = expect_dictionary_keys(
+ "name", ONE_EXACTLY, expect_string(assign_variable_callback(name), false),
+ "date", ONE_EXACTLY, expect_identifier_or_string(expect_date_str(assign_variable_callback(date))),
+ "type", ONE_EXACTLY, expect_identifier([&type](std::string_view leader_type) -> bool {
+ if (leader_type == "land") {
+ type = Unit::type_t::LAND;
+ } else {
+ type = Unit::type_t::NAVAL;
+ }
+ return true;
+ }),
+ "personality", ONE_EXACTLY, game_manager.get_military_manager().get_leader_trait_manager()
+ .expect_leader_trait_identifier(assign_variable_callback_pointer(personality)),
+ "background", ONE_EXACTLY, game_manager.get_military_manager().get_leader_trait_manager()
+ .expect_leader_trait_identifier(assign_variable_callback_pointer(background)),
+ "prestige", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(prestige)),
+ "picture", ZERO_OR_ONE, success_callback
+ )(node);
+
+ if (!personality->is_personality_trait()) {
+ Logger::error("Leader ", name, " has personality ", personality->get_identifier(),
+ " which is not a personality trait!");
+ return false;
+ }
+ if (!background->is_background_trait()) {
+ Logger::error("Leader ", name, " has background ", background->get_identifier(),
+ " which is not a background trait!");
+ return false;
+ }
+
+ leaders.push_back(Leader{ std::string(name), type, date, personality, background, prestige });
+ return ret;
+ },
"army", ZERO_OR_MORE, [&armies, &game_manager](ast::NodeCPtr node) -> bool {
- std::string_view name;
- Province const* location;
- std::vector<Regiment> regiments;
-
- bool ret = expect_dictionary_keys(
- "leader", ZERO_OR_MORE, success_callback, /* another paradox gem, tested in game and they don't lead the army or even show up */
- "name", ONE_EXACTLY, expect_string(assign_variable_callback(name), false),
- "location", ONE_EXACTLY, game_manager.get_map().expect_province_identifier(assign_variable_callback_pointer(location)),
- "regiment", ONE_OR_MORE, [&game_manager, &regiments](ast::NodeCPtr node) -> bool {
- Regiment regiment;
- bool ret = expect_dictionary_keys(
- "name", ONE_EXACTLY, expect_string(assign_variable_callback_string(regiment.name), false),
- "type", ONE_EXACTLY, game_manager.get_military_manager().get_unit_manager().expect_unit_identifier(assign_variable_callback_pointer(regiment.type)),
- "home", ONE_EXACTLY, game_manager.get_map().expect_province_identifier(assign_variable_callback_pointer(regiment.home))
- )(node);
- regiments.push_back(regiment);
- return ret;
- }
- )(node);
- armies.push_back(Army{ std::string(name), location, std::move(regiments) });
- return ret; },
+ std::string_view name;
+ Province const* location = nullptr;
+ std::vector<Regiment> regiments;
+
+ bool ret = expect_dictionary_keys(
+ /* another paradox gem, tested in game and they don't lead the army or even show up */
+ "leader", ZERO_OR_MORE, success_callback,
+ "name", ONE_EXACTLY, expect_string(assign_variable_callback(name), false),
+ "location", ONE_EXACTLY,
+ game_manager.get_map().expect_province_identifier(assign_variable_callback_pointer(location)),
+ "regiment", ONE_OR_MORE, [&game_manager, &regiments](ast::NodeCPtr node) -> bool {
+ Regiment regiment;
+ bool ret = expect_dictionary_keys(
+ "name", ONE_EXACTLY, expect_string(assign_variable_callback_string(regiment.name), false),
+ "type", ONE_EXACTLY, game_manager.get_military_manager().get_unit_manager()
+ .expect_unit_identifier(assign_variable_callback_pointer(regiment.type)),
+ "home", ONE_EXACTLY, game_manager.get_map()
+ .expect_province_identifier(assign_variable_callback_pointer(regiment.home))
+ )(node);
+ regiments.push_back(regiment);
+ return ret;
+ }
+ )(node);
+ armies.push_back(Army{ std::string(name), location, std::move(regiments) });
+ return ret;
+ },
"navy", ZERO_OR_MORE, [&navies, &game_manager](ast::NodeCPtr node) -> bool {
- std::string_view name;
- Province const* location;
- std::vector<Ship> ships;
-
- bool ret = expect_dictionary_keys(
- "name", ONE_EXACTLY, expect_string(assign_variable_callback(name), false),
- "location", ONE_EXACTLY, game_manager.get_map().expect_province_identifier(assign_variable_callback_pointer(location)),
- "ship", ONE_OR_MORE, [&game_manager, &ships](ast::NodeCPtr node) -> bool {
- Ship ship;
- bool ret = expect_dictionary_keys(
- "name", ONE_EXACTLY, expect_string(assign_variable_callback_string(ship.name), false),
- "type", ONE_EXACTLY, game_manager.get_military_manager().get_unit_manager().expect_unit_identifier(assign_variable_callback_pointer(ship.type))
- )(node);
- ships.push_back(ship);
- return ret;
- },
- "leader", ZERO_OR_MORE, success_callback
- )(node);
- navies.push_back(Navy{ std::string(name), location, std::move(ships) });
- return ret; }
+ std::string_view name;
+ Province const* location = nullptr;
+ std::vector<Ship> ships;
+
+ bool ret = expect_dictionary_keys(
+ "name", ONE_EXACTLY, expect_string(assign_variable_callback(name), false),
+ "location", ONE_EXACTLY,
+ game_manager.get_map().expect_province_identifier(assign_variable_callback_pointer(location)),
+ "ship", ONE_OR_MORE, [&game_manager, &ships](ast::NodeCPtr node) -> bool {
+ Ship ship;
+ bool ret = expect_dictionary_keys(
+ "name", ONE_EXACTLY, expect_string(assign_variable_callback_string(ship.name), false),
+ "type", ONE_EXACTLY, game_manager.get_military_manager().get_unit_manager()
+ .expect_unit_identifier(assign_variable_callback_pointer(ship.type))
+ )(node);
+ ships.push_back(ship);
+ return ret;
+ },
+ "leader", ZERO_OR_MORE, success_callback
+ )(node);
+ navies.push_back(Navy{ std::string(name), location, std::move(ships) });
+ return ret;
+ }
)(root);
/* need to do this for platform compatibility of identifiers */
std::string identifier = std::string { path };
diff --git a/src/openvic-simulation/military/Deployment.hpp b/src/openvic-simulation/military/Deployment.hpp
index 8ec0e49..9eb0a72 100644
--- a/src/openvic-simulation/military/Deployment.hpp
+++ b/src/openvic-simulation/military/Deployment.hpp
@@ -56,7 +56,8 @@ namespace OpenVic {
const std::vector<Navy> navies;
const std::vector<Leader> leaders;
- Deployment(std::string_view new_path, std::vector<Army>&& new_armies, std::vector<Navy>&& new_navies, std::vector<Leader>&& new_leaders);
+ Deployment(std::string_view new_path, std::vector<Army>&& new_armies,
+ std::vector<Navy>&& new_navies, std::vector<Leader>&& new_leaders);
public:
const std::vector<Army>& get_armies() const;
@@ -71,7 +72,8 @@ namespace OpenVic {
public:
DeploymentManager();
- bool add_deployment(std::string_view path, std::vector<Army>&& armies, std::vector<Navy>&& navies, std::vector<Leader>&& leaders);
+ bool add_deployment(std::string_view path, std::vector<Army>&& armies,
+ std::vector<Navy>&& navies, std::vector<Leader>&& leaders);
IDENTIFIER_REGISTRY_ACCESSORS(deployment);
bool load_oob_file(GameManager& game_manager, std::string_view path, ast::NodeCPtr root);
diff --git a/src/openvic-simulation/military/LeaderTrait.cpp b/src/openvic-simulation/military/LeaderTrait.cpp
index ed21c1f..81c6ccc 100644
--- a/src/openvic-simulation/military/LeaderTrait.cpp
+++ b/src/openvic-simulation/military/LeaderTrait.cpp
@@ -24,7 +24,8 @@ ModifierValue const& LeaderTrait::get_modifiers() const {
LeaderTraitManager::LeaderTraitManager() : leader_traits { "leader trait" } {}
-bool LeaderTraitManager::add_leader_trait(std::string_view identifier, LeaderTrait::trait_type_t type, ModifierValue&& modifiers) {
+bool LeaderTraitManager::add_leader_trait(std::string_view identifier,
+ LeaderTrait::trait_type_t type, ModifierValue&& modifiers) {
if (identifier.empty()) {
Logger::error("Invalid leader trait identifier - empty!");
return false;
diff --git a/src/openvic-simulation/military/Unit.cpp b/src/openvic-simulation/military/Unit.cpp
index 294c77f..f079ee9 100644
--- a/src/openvic-simulation/military/Unit.cpp
+++ b/src/openvic-simulation/military/Unit.cpp
@@ -15,8 +15,9 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-Unit::Unit(std::string_view identifier, type_t type, UNIT_PARAMS)
- : HasIdentifier { identifier }, icon { icon }, type { type }, sprite { sprite }, active { active },
+Unit::Unit(
+ std::string_view identifier, type_t type, UNIT_PARAMS
+) : HasIdentifier { identifier }, icon { icon }, type { type }, sprite { sprite }, active { active },
unit_type { unit_type }, floating_flag { floating_flag }, priority { priority }, max_strength { max_strength },
default_organisation { default_organisation }, maximum_speed { maximum_speed }, weighted_value { weighted_value },
move_sound { move_sound }, select_sound { select_sound }, build_time { build_time }, build_cost { std::move(build_cost) },
@@ -90,8 +91,9 @@ Good::good_map_t const& Unit::get_supply_cost() const {
return supply_cost;
}
-LandUnit::LandUnit(std::string_view identifier, UNIT_PARAMS, LAND_PARAMS)
- : Unit { identifier, type_t::LAND, UNIT_ARGS }, primary_culture { primary_culture },
+LandUnit::LandUnit(
+ std::string_view identifier, UNIT_PARAMS, LAND_PARAMS
+) : Unit { identifier, type_t::LAND, UNIT_ARGS }, primary_culture { primary_culture },
sprite_override { sprite_override }, sprite_mount { sprite_mount }, sprite_mount_attach_node { sprite_mount_attach_node },
reconnaissance { reconnaissance }, attack { attack }, defence { defence }, discipline { discipline }, support { support },
maneuver { maneuver }, siege { siege } {}
@@ -140,10 +142,11 @@ fixed_point_t LandUnit::get_siege() const {
return siege;
}
-NavalUnit::NavalUnit(std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS)
- : Unit { identifier, type_t::NAVAL, UNIT_ARGS }, naval_icon { naval_icon }, sail { sail },
+NavalUnit::NavalUnit(
+ std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS
+) : Unit { identifier, type_t::NAVAL, UNIT_ARGS }, naval_icon { naval_icon }, sail { sail },
transport { transport }, capital { capital }, colonial_points { colonial_points },
- build_overseas { build_overseas }, min_port_level { min_port_level },limit_per_port { limit_per_port },
+ build_overseas { build_overseas }, min_port_level { min_port_level }, limit_per_port { limit_per_port },
supply_consumption_score { supply_consumption_score }, hull { hull }, gun_power { gun_power },
fire_range { fire_range }, evasion { evasion }, torpedo_attack { torpedo_attack } {};
@@ -248,14 +251,16 @@ bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr
bool active = true, floating_flag = false;
uint32_t priority = 0;
Timespan build_time;
- fixed_point_t maximum_speed = 0, max_strength = 0, default_organisation = 0, weighted_value = 0, supply_consumption = 0;
+ fixed_point_t maximum_speed = 0, max_strength = 0, default_organisation = 0;
+ fixed_point_t weighted_value = 0, supply_consumption = 0;
Good::good_map_t build_cost, supply_cost;
using enum Unit::type_t;
static const string_map_t<Unit::type_t> type_map = {
{ "land", LAND }, { "naval", NAVAL }
};
- bool ret = expect_key("type", expect_identifier(expect_mapped_string(type_map, assign_variable_callback(type))))(value);
+ bool ret =
+ expect_key("type", expect_identifier(expect_mapped_string(type_map, assign_variable_callback(type))))(value);
if (!ret) {
Logger::error("Failed to read type for unit: ", key);
@@ -285,65 +290,63 @@ bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr
);
switch (type) {
- case LAND:
- {
- bool primary_culture = false;
- std::string_view sprite_override, sprite_mount, sprite_mount_attach_node;
- fixed_point_t reconnaissance = 0, attack = 0, defence = 0, discipline = 0, support = 0, maneuver = 0, siege = 0;
-
- ret &= add_key_map_entries(key_map,
- "primary_culture", ZERO_OR_ONE, expect_bool(assign_variable_callback(primary_culture)),
- "sprite_override", ZERO_OR_ONE, expect_identifier(assign_variable_callback(sprite_override)),
- "sprite_mount", ZERO_OR_ONE, expect_identifier(assign_variable_callback(sprite_mount)),
- "sprite_mount_attach_node", ZERO_OR_ONE, expect_identifier(assign_variable_callback(sprite_mount_attach_node)),
- "reconnaissance", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(reconnaissance)),
- "attack", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(attack)),
- "defence", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(defence)),
- "discipline", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(discipline)),
- "support", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(support)),
- "maneuver", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(maneuver)),
- "siege", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(siege))
- );
-
- ret &= expect_dictionary_key_map(key_map)(value);
-
- ret &= add_land_unit(key, UNIT_ARGS, LAND_ARGS);
-
- return ret;
- }
- break;
- case NAVAL:
- {
- Unit::icon_t naval_icon = 0;
- bool sail = false, transport = false, capital = false, build_overseas = false;
- uint32_t min_port_level = 0;
- int32_t limit_per_port = 0;
- fixed_point_t fire_range = 0, evasion = 0, supply_consumption_score = 0, hull = 0, gun_power = 0, colonial_points = 0, torpedo_attack = 0;
-
- ret &= add_key_map_entries(key_map,
- "naval_icon", ONE_EXACTLY, expect_uint(assign_variable_callback(naval_icon)),
- "sail", ZERO_OR_ONE, expect_bool(assign_variable_callback(sail)),
- "transport", ZERO_OR_ONE, expect_bool(assign_variable_callback(transport)),
- "capital", ZERO_OR_ONE, expect_bool(assign_variable_callback(capital)),
- "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_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_fixed_point(assign_variable_callback(torpedo_attack))
- );
-
- ret &= expect_dictionary_key_map(key_map)(value);
-
- ret &= add_naval_unit(key, UNIT_ARGS, NAVY_ARGS);
-
- return ret;
- }
- break;
+ case LAND: {
+ bool primary_culture = false;
+ std::string_view sprite_override, sprite_mount, sprite_mount_attach_node;
+ fixed_point_t reconnaissance = 0, attack = 0, defence = 0, discipline = 0, support = 0, maneuver = 0, siege = 0;
+
+ ret &= add_key_map_entries(key_map,
+ "primary_culture", ZERO_OR_ONE, expect_bool(assign_variable_callback(primary_culture)),
+ "sprite_override", ZERO_OR_ONE, expect_identifier(assign_variable_callback(sprite_override)),
+ "sprite_mount", ZERO_OR_ONE, expect_identifier(assign_variable_callback(sprite_mount)),
+ "sprite_mount_attach_node", ZERO_OR_ONE, expect_identifier(assign_variable_callback(sprite_mount_attach_node)),
+ "reconnaissance", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(reconnaissance)),
+ "attack", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(attack)),
+ "defence", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(defence)),
+ "discipline", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(discipline)),
+ "support", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(support)),
+ "maneuver", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(maneuver)),
+ "siege", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(siege))
+ );
+
+ ret &= expect_dictionary_key_map(key_map)(value);
+
+ ret &= add_land_unit(key, UNIT_ARGS, LAND_ARGS);
+
+ return ret;
+ }
+ case NAVAL: {
+ Unit::icon_t naval_icon = 0;
+ bool sail = false, transport = false, capital = false, build_overseas = false;
+ uint32_t min_port_level = 0;
+ int32_t limit_per_port = 0;
+ fixed_point_t fire_range = 0, evasion = 0, supply_consumption_score = 0, hull = 0;
+ fixed_point_t gun_power = 0, colonial_points = 0, torpedo_attack = 0;
+
+ ret &= add_key_map_entries(key_map,
+ "naval_icon", ONE_EXACTLY, expect_uint(assign_variable_callback(naval_icon)),
+ "sail", ZERO_OR_ONE, expect_bool(assign_variable_callback(sail)),
+ "transport", ZERO_OR_ONE, expect_bool(assign_variable_callback(transport)),
+ "capital", ZERO_OR_ONE, expect_bool(assign_variable_callback(capital)),
+ "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_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_fixed_point(assign_variable_callback(torpedo_attack))
+ );
+
+ ret &= expect_dictionary_key_map(key_map)(value);
+
+ ret &= add_naval_unit(key, UNIT_ARGS, NAVY_ARGS);
+
+ return ret;
+ }
default:
Logger::error("Unknown unit type for ", key, ": ", static_cast<int>(type));
return false;
diff --git a/src/openvic-simulation/military/Unit.hpp b/src/openvic-simulation/military/Unit.hpp
index ea28511..d1dcc8f 100644
--- a/src/openvic-simulation/military/Unit.hpp
+++ b/src/openvic-simulation/military/Unit.hpp
@@ -11,20 +11,20 @@
#define UNIT_PARAMS \
Unit::icon_t icon, std::string_view sprite, bool active, std::string_view unit_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, std::string_view move_sound, \
- std::string_view select_sound, Timespan build_time, Good::good_map_t &&build_cost, \
- fixed_point_t supply_consumption, Good::good_map_t &&supply_cost
+ 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, std::string_view move_sound, \
+ std::string_view select_sound, Timespan build_time, Good::good_map_t &&build_cost, \
+ fixed_point_t supply_consumption, Good::good_map_t &&supply_cost
#define LAND_PARAMS \
bool primary_culture, std::string_view sprite_override, std::string_view sprite_mount, \
- std::string_view sprite_mount_attach_node, 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
+ std::string_view sprite_mount_attach_node, 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, 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
+ 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 {