diff options
author | zaaarf <zaaarf@proton.me> | 2023-09-22 16:23:00 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-09-22 16:23:00 +0200 |
commit | 8b15eb58d934b8fea4ed1ed44130f9a8957ea761 (patch) | |
tree | 23c5471490d79754c6456e239c4136c419e42111 /src/openvic-simulation | |
parent | e91e2670abfd4976883c7a5d654d1f5469b4ac7a (diff) |
chore: removed hardcoded possible values on unit type
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r-- | src/openvic-simulation/units/Unit.cpp | 12 | ||||
-rw-r--r-- | src/openvic-simulation/units/Unit.hpp | 12 |
2 files changed, 8 insertions, 16 deletions
diff --git a/src/openvic-simulation/units/Unit.cpp b/src/openvic-simulation/units/Unit.cpp index 55ff08d..63053c1 100644 --- a/src/openvic-simulation/units/Unit.cpp +++ b/src/openvic-simulation/units/Unit.cpp @@ -1,5 +1,4 @@ #include "Unit.hpp" -#include <string_view> #define UNIT_ARGS icon, sprite, active, type, floating_flag, priority, max_strength, \ default_organisation, maximum_speed, weighted_value, build_time, build_cost, supply_consumption, \ @@ -177,13 +176,18 @@ bool UnitManager::_check_shared_parameters(const std::string_view identifier, UN return false; } - //TODO check that icon and sprite exist + if (sprite.empty()) { + Logger::error("Invalid sprite identifier - empty!"); + return false; + } - if (!allowed_unit_types.contains(type)) { - Logger::error("Invalid unit type \"", type, "\" specified!"); + if (type.empty()) { + Logger::error("Invalid unit type - empty!"); return false; } + //TODO check that icon and sprite exist + return true; } diff --git a/src/openvic-simulation/units/Unit.hpp b/src/openvic-simulation/units/Unit.hpp index 9653526..ccda35e 100644 --- a/src/openvic-simulation/units/Unit.hpp +++ b/src/openvic-simulation/units/Unit.hpp @@ -1,10 +1,8 @@ #pragma once #include <cstdint> -#include <set> #include <string> #include <string_view> -#include <unordered_set> #include "openvic-simulation/economy/Good.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" @@ -150,16 +148,6 @@ namespace OpenVic { bool _check_shared_parameters(const std::string_view identifier, UNIT_PARAMS); public: - const std::unordered_set<std::string_view> allowed_unit_types { //TODO is this useful? - "infantry", //guard, infantry, irregular - "cavalry", //cavalry, cuirassier, dragoon, hussar, plane - "support", //artillery - "special", //engineer, tank - "transport", //clipper transport, steam transport - "light_ship", //commerce raider, cruiser, frigate - "big_ship" //battleship, dreadnought, ironclad, manowar, monitor - }; - UnitManager(GoodManager& good_manager); bool add_land_unit(const std::string_view identifier, UNIT_PARAMS, LAND_PARAMS); |