diff --git a/src/openvic-simulation/defines/CountryDefines.cpp b/src/openvic-simulation/defines/CountryDefines.cpp index 9f1216daa..fe28cf070 100644 --- a/src/openvic-simulation/defines/CountryDefines.cpp +++ b/src/openvic-simulation/defines/CountryDefines.cpp @@ -40,7 +40,7 @@ node_callback_t CountryDefines::expect_defines() { "COLONIAL_RANK", ONE_EXACTLY, expect_uint(assign_variable_callback(secondary_power_rank)), "COLONY_TO_STATE_PRESTIGE_GAIN", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(colony_to_state_prestige_gain)), - "COLONIAL_LIFERATING", ONE_EXACTLY, expect_uint(assign_variable_callback(colonial_liferating)), + "COLONIAL_LIFERATING", ONE_EXACTLY, expect_strong_typedef(assign_variable_callback(colonial_liferating)), "BASE_GREATPOWER_DAILY_INFLUENCE", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(base_greatpower_daily_influence)), "AI_SUPPORT_REFORM", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(ai_support_reform)), diff --git a/src/openvic-simulation/defines/CountryDefines.hpp b/src/openvic-simulation/defines/CountryDefines.hpp index 5bbedd408..7aac92a21 100644 --- a/src/openvic-simulation/defines/CountryDefines.hpp +++ b/src/openvic-simulation/defines/CountryDefines.hpp @@ -3,7 +3,7 @@ #include "openvic-simulation/dataloader/NodeTools.hpp" #include "openvic-simulation/types/Date.hpp" #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" -#include "openvic-simulation/types/ProvinceLifeRating.hpp" +#include "openvic-simulation/map/LifeRating.hpp" #include "openvic-simulation/utility/Getters.hpp" namespace OpenVic { @@ -40,7 +40,7 @@ namespace OpenVic { Timespan PROPERTY(campaign_duration); size_t PROPERTY(secondary_power_rank, 0); fixed_point_t PROPERTY(colony_to_state_prestige_gain); - life_rating_t PROPERTY(colonial_liferating, 0); + life_rating_t PROPERTY(colonial_liferating, life_rating_t { 0 }); fixed_point_t PROPERTY(base_greatpower_daily_influence); fixed_point_t PROPERTY(ai_support_reform); fixed_point_t PROPERTY(base_monthly_diplopoints); diff --git a/src/openvic-simulation/defines/PopsDefines.cpp b/src/openvic-simulation/defines/PopsDefines.cpp index 5717d26ec..f28258985 100644 --- a/src/openvic-simulation/defines/PopsDefines.cpp +++ b/src/openvic-simulation/defines/PopsDefines.cpp @@ -23,7 +23,7 @@ node_callback_t PopsDefines::expect_defines() { "LUXURY_THRESHOLD", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(luxury_threshold)), "BASE_GOODS_DEMAND", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(base_goods_demand)), "BASE_POPGROWTH", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(base_popgrowth)), - "MIN_LIFE_RATING_FOR_GROWTH", ONE_EXACTLY, expect_uint(assign_variable_callback(min_life_rating_for_growth)), + "MIN_LIFE_RATING_FOR_GROWTH", ONE_EXACTLY, expect_strong_typedef(assign_variable_callback(min_life_rating_for_growth)), "LIFE_RATING_GROWTH_BONUS", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(life_rating_growth_bonus)), "LIFE_NEED_STARVATION_LIMIT", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(life_need_starvation_limit)), "MIL_LACK_EVERYDAY_NEED", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(mil_lack_everyday_need)), diff --git a/src/openvic-simulation/defines/PopsDefines.hpp b/src/openvic-simulation/defines/PopsDefines.hpp index fa31f04b9..631ae7892 100644 --- a/src/openvic-simulation/defines/PopsDefines.hpp +++ b/src/openvic-simulation/defines/PopsDefines.hpp @@ -3,7 +3,7 @@ #include "openvic-simulation/dataloader/NodeTools.hpp" #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" #include "openvic-simulation/population/PopSum.hpp" -#include "openvic-simulation/types/ProvinceLifeRating.hpp" +#include "openvic-simulation/map/LifeRating.hpp" #include "openvic-simulation/utility/Getters.hpp" namespace OpenVic { @@ -24,7 +24,7 @@ namespace OpenVic { fixed_point_t PROPERTY(luxury_threshold); fixed_point_t PROPERTY(base_goods_demand); fixed_point_t PROPERTY(base_popgrowth); - life_rating_t PROPERTY(min_life_rating_for_growth, 0); + life_rating_t PROPERTY(min_life_rating_for_growth, life_rating_t { 0 }); fixed_point_t PROPERTY(life_rating_growth_bonus); fixed_point_t PROPERTY(life_need_starvation_limit); fixed_point_t PROPERTY(mil_lack_everyday_need); diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp index f788cf329..f251e33ed 100644 --- a/src/openvic-simulation/history/ProvinceHistory.cpp +++ b/src/openvic-simulation/history/ProvinceHistory.cpp @@ -135,7 +135,7 @@ bool ProvinceHistoryMap::_load_history_entry( allow_empty_true, //could be explicitly setting trade_goods to null do_warn //could be typo in good identifier ), - "life_rating", ZERO_OR_ONE, expect_uint(assign_variable_callback(entry.life_rating)), + "life_rating", ZERO_OR_ONE, expect_strong_typedef(assign_variable_callback(entry.life_rating)), "terrain", ZERO_OR_ONE, terrain_type_manager.expect_terrain_type_identifier( assign_variable_callback_pointer_opt(entry.terrain_type) ), diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp index 1f434235a..a302a6337 100644 --- a/src/openvic-simulation/history/ProvinceHistory.hpp +++ b/src/openvic-simulation/history/ProvinceHistory.hpp @@ -10,7 +10,7 @@ #include "openvic-simulation/types/Date.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" #include "openvic-simulation/types/fixed_point/FixedPointMap.hpp" -#include "openvic-simulation/types/ProvinceLifeRating.hpp" +#include "openvic-simulation/map/LifeRating.hpp" #include "openvic-simulation/utility/Containers.hpp" #include "openvic-simulation/utility/Getters.hpp" diff --git a/src/openvic-simulation/map/LifeRating.hpp b/src/openvic-simulation/map/LifeRating.hpp new file mode 100644 index 000000000..7c6c5fbe1 --- /dev/null +++ b/src/openvic-simulation/map/LifeRating.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include +#include + +#include + +namespace OpenVic { + struct life_rating_t : type_safe::strong_typedef, + type_safe::strong_typedef_op::equality_comparison, + type_safe::strong_typedef_op::relational_comparison, + type_safe::strong_typedef_op::integer_arithmetic, + type_safe::strong_typedef_op::mixed_addition, + type_safe::strong_typedef_op::mixed_subtraction { + using strong_typedef::strong_typedef; + }; +} + +template<> +struct fmt::formatter : fmt::formatter { + fmt::format_context::iterator format(OpenVic::life_rating_t const& value, fmt::format_context& ctx) const { + return fmt::formatter::format(type_safe::get(value), ctx); + } +}; diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp index 45f93dd90..27a4e1262 100644 --- a/src/openvic-simulation/map/ProvinceInstance.hpp +++ b/src/openvic-simulation/map/ProvinceInstance.hpp @@ -13,7 +13,7 @@ #include "openvic-simulation/types/HasIdentifier.hpp" #include "openvic-simulation/types/HasIndex.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" -#include "openvic-simulation/types/ProvinceLifeRating.hpp" +#include "openvic-simulation/map/LifeRating.hpp" #include "openvic-simulation/types/TypedIndices.hpp" #include "openvic-simulation/types/UnitBranchType.hpp" #include "openvic-simulation/utility/Containers.hpp" @@ -72,7 +72,7 @@ namespace OpenVic { GameRulesManager const& game_rules_manager; TerrainType const* PROPERTY(terrain_type); - life_rating_t PROPERTY(life_rating, 0); + life_rating_t PROPERTY(life_rating, life_rating_t { 0 }); colony_status_t PROPERTY(colony_status, colony_status_t::STATE); State* PROPERTY_PTR(state, nullptr); diff --git a/src/openvic-simulation/types/ProvinceLifeRating.hpp b/src/openvic-simulation/types/ProvinceLifeRating.hpp deleted file mode 100644 index 50f028766..000000000 --- a/src/openvic-simulation/types/ProvinceLifeRating.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -namespace OpenVic { - using life_rating_t = int8_t; -} \ No newline at end of file