Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/openvic-simulation/defines/CountryDefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<life_rating_t>(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)),
Expand Down
4 changes: 2 additions & 2 deletions src/openvic-simulation/defines/CountryDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/openvic-simulation/defines/PopsDefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<life_rating_t>(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)),
Expand Down
4 changes: 2 additions & 2 deletions src/openvic-simulation/defines/PopsDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/openvic-simulation/history/ProvinceHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<life_rating_t>(assign_variable_callback(entry.life_rating)),
"life_rating", ZERO_OR_ONE, expect_strong_typedef<life_rating_t>(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)
),
Expand Down
2 changes: 1 addition & 1 deletion src/openvic-simulation/history/ProvinceHistory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
26 changes: 26 additions & 0 deletions src/openvic-simulation/map/LifeRating.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <cstdint>

#include <fmt/base.h>
#include <fmt/format.h>

#include <type_safe/strong_typedef.hpp>

namespace OpenVic {
struct life_rating_t : type_safe::strong_typedef<life_rating_t, std::int8_t>,
type_safe::strong_typedef_op::equality_comparison<life_rating_t>,
type_safe::strong_typedef_op::relational_comparison<life_rating_t>,
type_safe::strong_typedef_op::integer_arithmetic<life_rating_t>,
type_safe::strong_typedef_op::mixed_addition<life_rating_t, std::uint8_t>,
type_safe::strong_typedef_op::mixed_subtraction<life_rating_t, std::uint8_t> {
using strong_typedef::strong_typedef;
};
}

template<>
struct fmt::formatter<OpenVic::life_rating_t> : fmt::formatter<std::int8_t> {
fmt::format_context::iterator format(OpenVic::life_rating_t const& value, fmt::format_context& ctx) const {
return fmt::formatter<std::int8_t>::format(type_safe::get(value), ctx);
}
};
4 changes: 2 additions & 2 deletions src/openvic-simulation/map/ProvinceInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 0 additions & 7 deletions src/openvic-simulation/types/ProvinceLifeRating.hpp

This file was deleted.