aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/openvic-simulation/military/Unit.cpp19
-rw-r--r--src/openvic-simulation/military/Unit.hpp6
2 files changed, 19 insertions, 6 deletions
diff --git a/src/openvic-simulation/military/Unit.cpp b/src/openvic-simulation/military/Unit.cpp
index 0862741..db04335 100644
--- a/src/openvic-simulation/military/Unit.cpp
+++ b/src/openvic-simulation/military/Unit.cpp
@@ -6,7 +6,7 @@
std::move(supply_cost)
#define LAND_ARGS \
- primary_culture, sprite_override, sprite_mount, sprite_mount_attach_node, reconnaissance, attack, defence, discipline, \
+ allowed_cultures, sprite_override, sprite_mount, sprite_mount_attach_node, reconnaissance, attack, defence, discipline, \
support, maneuver, siege
#define NAVY_ARGS \
@@ -26,7 +26,7 @@ Unit::Unit(
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 },
+) : Unit { identifier, type_t::LAND, UNIT_ARGS }, allowed_cultures { allowed_cultures }, 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 } {}
@@ -127,12 +127,14 @@ bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr
switch (type) {
case Unit::type_t::LAND: {
- bool primary_culture = false;
+ bool is_restricted_to_primary_culture = false;
+ bool is_restricted_to_accepted_cultures = 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)),
+ "primary_culture", ZERO_OR_ONE, expect_bool(assign_variable_callback(is_restricted_to_primary_culture)),
+ "accepted_culture", ZERO_OR_ONE, expect_bool(assign_variable_callback(is_restricted_to_accepted_cultures)),
"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)),
@@ -145,6 +147,15 @@ bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr
"siege", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(siege))
);
+ LandUnit::allowed_cultures_t allowed_cultures;
+ if (is_restricted_to_accepted_cultures) {
+ allowed_cultures = LandUnit::allowed_cultures_t::ACCEPTED_CULTURES;
+ } else if (is_restricted_to_primary_culture) {
+ allowed_cultures = LandUnit::allowed_cultures_t::PRIMARY_CULTURE;
+ } else {
+ allowed_cultures = LandUnit::allowed_cultures_t::ALL_CULTURES;
+ }
+
ret &= expect_dictionary_key_map(key_map)(value);
ret &= add_land_unit(key, UNIT_ARGS, LAND_ARGS);
diff --git a/src/openvic-simulation/military/Unit.hpp b/src/openvic-simulation/military/Unit.hpp
index a44f4e5..c791aca 100644
--- a/src/openvic-simulation/military/Unit.hpp
+++ b/src/openvic-simulation/military/Unit.hpp
@@ -17,7 +17,7 @@
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, \
+ LandUnit::allowed_cultures_t allowed_cultures, 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
@@ -64,8 +64,10 @@ namespace OpenVic {
struct LandUnit : Unit {
friend struct UnitManager;
+ enum struct allowed_cultures_t { ALL_CULTURES, ACCEPTED_CULTURES, PRIMARY_CULTURE };
+
private:
- const bool PROPERTY_CUSTOM_PREFIX(primary_culture, is);
+ const allowed_cultures_t PROPERTY(allowed_cultures);
const std::string PROPERTY(sprite_override);
const std::string PROPERTY(sprite_mount);
const std::string PROPERTY(sprite_mount_attach_node);