aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-12-01 20:03:03 +0100
committer zaaarf <zaaarf@proton.me>2023-12-01 20:03:03 +0100
commit2d76e0766f0d65ffd8c9eb19eaec705445f91af0 (patch)
treea3ba37c2d652b95085ac8cf72a25941da26498ad
parenta54898b7770e0d66b729216173960686c67e58bb (diff)
feat: replaced REF_GETTERS with PROPERTY_REF, added PROPERTY_CUSTOM_PREFIX
-rw-r--r--src/openvic-simulation/GameManager.hpp34
-rw-r--r--src/openvic-simulation/country/Country.hpp2
-rw-r--r--src/openvic-simulation/economy/EconomyManager.hpp10
-rw-r--r--src/openvic-simulation/economy/Good.hpp4
-rw-r--r--src/openvic-simulation/economy/ProductionType.hpp6
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.hpp8
-rw-r--r--src/openvic-simulation/history/HistoryManager.hpp14
-rw-r--r--src/openvic-simulation/map/Map.hpp3
-rw-r--r--src/openvic-simulation/military/MilitaryManager.hpp14
-rw-r--r--src/openvic-simulation/military/Unit.hpp14
-rw-r--r--src/openvic-simulation/misc/Modifier.hpp2
-rw-r--r--src/openvic-simulation/politics/Government.hpp4
-rw-r--r--src/openvic-simulation/politics/Ideology.hpp2
-rw-r--r--src/openvic-simulation/politics/Issue.hpp4
-rw-r--r--src/openvic-simulation/politics/PoliticsManager.hpp16
-rw-r--r--src/openvic-simulation/pop/Pop.hpp7
-rw-r--r--src/openvic-simulation/types/IdentifierRegistry.hpp4
-rw-r--r--src/openvic-simulation/utility/Getters.hpp17
18 files changed, 65 insertions, 100 deletions
diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp
index cd86716..5b66c8b 100644
--- a/src/openvic-simulation/GameManager.hpp
+++ b/src/openvic-simulation/GameManager.hpp
@@ -16,17 +16,17 @@ namespace OpenVic {
using state_updated_func_t = std::function<void()>;
private:
- Map map;
- DefineManager define_manager;
- EconomyManager economy_manager;
- MilitaryManager military_manager;
- ModifierManager modifier_manager;
- PoliticsManager politics_manager;
- HistoryManager history_manager;
- PopManager pop_manager;
- CountryManager country_manager;
- UIManager ui_manager;
- GameAdvancementHook clock;
+ Map PROPERTY_REF(map);
+ DefineManager PROPERTY_REF(define_manager);
+ EconomyManager PROPERTY_REF(economy_manager);
+ MilitaryManager PROPERTY_REF(military_manager);
+ ModifierManager PROPERTY_REF(modifier_manager);
+ PoliticsManager PROPERTY_REF(politics_manager);
+ HistoryManager PROPERTY_REF(history_manager);
+ PopManager PROPERTY_REF(pop_manager);
+ CountryManager PROPERTY_REF(country_manager);
+ UIManager PROPERTY_REF(ui_manager);
+ GameAdvancementHook PROPERTY_REF(clock);
time_t session_start; /* SS-54, as well as allowing time-tracking */
Bookmark const* PROPERTY(bookmark);
@@ -41,18 +41,6 @@ namespace OpenVic {
public:
GameManager(state_updated_func_t state_updated_callback);
- REF_GETTERS(map)
- REF_GETTERS(define_manager)
- REF_GETTERS(economy_manager)
- REF_GETTERS(military_manager)
- REF_GETTERS(modifier_manager)
- REF_GETTERS(politics_manager)
- REF_GETTERS(history_manager)
- REF_GETTERS(pop_manager)
- REF_GETTERS(country_manager)
- REF_GETTERS(ui_manager)
- REF_GETTERS(clock)
-
bool reset();
bool load_bookmark(Bookmark const* new_bookmark);
diff --git a/src/openvic-simulation/country/Country.hpp b/src/openvic-simulation/country/Country.hpp
index 5b5c528..fb58dff 100644
--- a/src/openvic-simulation/country/Country.hpp
+++ b/src/openvic-simulation/country/Country.hpp
@@ -60,7 +60,7 @@ namespace OpenVic {
*/
IdentifierRegistry<CountryParty> parties;
const unit_names_map_t PROPERTY(unit_names);
- const bool PROPERTY_CUSTOM_NAME(dynamic_tag, is_dynamic_tag);
+ const bool PROPERTY_CUSTOM_PREFIX(dynamic_tag, is);
const government_colour_map_t PROPERTY(alternative_colours);
Country(
diff --git a/src/openvic-simulation/economy/EconomyManager.hpp b/src/openvic-simulation/economy/EconomyManager.hpp
index d53aa7e..fcde094 100644
--- a/src/openvic-simulation/economy/EconomyManager.hpp
+++ b/src/openvic-simulation/economy/EconomyManager.hpp
@@ -7,15 +7,11 @@
namespace OpenVic {
struct EconomyManager {
private:
- BuildingManager building_manager;
- GoodManager good_manager;
- ProductionTypeManager production_type_manager;
+ BuildingManager PROPERTY_REF(building_manager);
+ GoodManager PROPERTY_REF(good_manager);
+ ProductionTypeManager PROPERTY_REF(production_type_manager);
public:
- REF_GETTERS(building_manager)
- REF_GETTERS(good_manager)
- REF_GETTERS(production_type_manager)
-
inline bool load_production_types_file(PopManager const& pop_manager, ast::NodeCPtr root) {
return production_type_manager.load_production_types_file(good_manager, pop_manager, root);
}
diff --git a/src/openvic-simulation/economy/Good.hpp b/src/openvic-simulation/economy/Good.hpp
index ac85cbd..faf4b66 100644
--- a/src/openvic-simulation/economy/Good.hpp
+++ b/src/openvic-simulation/economy/Good.hpp
@@ -38,8 +38,8 @@ namespace OpenVic {
private:
GoodCategory const& PROPERTY(category);
const price_t PROPERTY(base_price);
- const bool PROPERTY_CUSTOM_NAME(available_from_start, is_available_from_start);
- const bool PROPERTY_CUSTOM_NAME(tradeable, is_tradeable);
+ const bool PROPERTY_CUSTOM_PREFIX(available_from_start, is);
+ const bool PROPERTY_CUSTOM_PREFIX(tradeable, is);
const bool PROPERTY(money);
const bool PROPERTY(overseas_penalty);
diff --git a/src/openvic-simulation/economy/ProductionType.hpp b/src/openvic-simulation/economy/ProductionType.hpp
index b03f16b..dd0b2fd 100644
--- a/src/openvic-simulation/economy/ProductionType.hpp
+++ b/src/openvic-simulation/economy/ProductionType.hpp
@@ -53,10 +53,10 @@ namespace OpenVic {
const std::vector<Bonus> PROPERTY(bonuses);
const Good::good_map_t PROPERTY(efficiency);
- const bool PROPERTY_CUSTOM_NAME(coastal, is_coastal); // is_coastal
+ const bool PROPERTY_CUSTOM_PREFIX(coastal, is); // is_coastal
- const bool PROPERTY_CUSTOM_NAME(farm, is_farm);
- const bool PROPERTY_CUSTOM_NAME(mine, is_mine);
+ const bool PROPERTY_CUSTOM_PREFIX(farm, is);
+ const bool PROPERTY_CUSTOM_PREFIX(mine, is);
ProductionType(PRODUCTION_TYPE_ARGS);
diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp
index 3ed253f..4d620b5 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.hpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.hpp
@@ -19,7 +19,7 @@ namespace OpenVic {
friend struct DiplomaticHistoryManager;
private:
- Date PROPERTY_CUSTOM_NAME(added, get_date_added);
+ Date PROPERTY_CUSTOM_PREFIX(added, get_date);
Country const* PROPERTY(actor);
Country const* PROPERTY(receiver);
WargoalType const* PROPERTY(wargoal);
@@ -34,8 +34,8 @@ namespace OpenVic {
private:
Country const* PROPERTY(country);
- Date PROPERTY_CUSTOM_NAME(joined, get_date_joined);
- std::optional<Date> PROPERTY_CUSTOM_NAME(exited, get_date_exited);
+ Date PROPERTY_CUSTOM_PREFIX(joined, get_date);
+ std::optional<Date> PROPERTY_CUSTOM_PREFIX(exited, get_date);
war_participant_t(Country const* new_country, Date new_joined, std::optional<Date> new_exited);
};
@@ -73,7 +73,7 @@ namespace OpenVic {
private:
Country const* PROPERTY(overlord);
Country const* PROPERTY(subject);
- const type_t PROPERTY_CUSTOM_NAME(type, get_subject_type);
+ const type_t PROPERTY_CUSTOM_PREFIX(type, get_subject);
const Date start;
const Date end;
diff --git a/src/openvic-simulation/history/HistoryManager.hpp b/src/openvic-simulation/history/HistoryManager.hpp
index a7fc668..35aebbf 100644
--- a/src/openvic-simulation/history/HistoryManager.hpp
+++ b/src/openvic-simulation/history/HistoryManager.hpp
@@ -9,15 +9,9 @@
namespace OpenVic {
struct HistoryManager {
private:
- BookmarkManager bookmark_manager;
- CountryHistoryManager country_manager;
- ProvinceHistoryManager province_manager;
- DiplomaticHistoryManager diplomacy_manager;
-
- public:
- REF_GETTERS(bookmark_manager)
- REF_GETTERS(country_manager)
- REF_GETTERS(province_manager)
- REF_GETTERS(diplomacy_manager)
+ BookmarkManager PROPERTY_REF(bookmark_manager);
+ CountryHistoryManager PROPERTY_REF(country_manager);
+ ProvinceHistoryManager PROPERTY_REF(province_manager);
+ DiplomaticHistoryManager PROPERTY_REF(diplomacy_manager);
};
}
diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp
index 4f87237..0999145 100644
--- a/src/openvic-simulation/map/Map.hpp
+++ b/src/openvic-simulation/map/Map.hpp
@@ -56,7 +56,7 @@ namespace OpenVic {
IdentifierRegistry<Region> regions;
IdentifierRegistry<Mapmode> mapmodes;
ProvinceSet water_provinces;
- TerrainTypeManager terrain_type_manager;
+ TerrainTypeManager PROPERTY_REF(terrain_type_manager);
size_t width = 0, height = 0;
std::vector<shape_pixel_t> province_shape_image;
@@ -92,7 +92,6 @@ namespace OpenVic {
size_t get_width() const;
size_t get_height() const;
std::vector<shape_pixel_t> const& get_province_shape_image() const;
- REF_GETTERS(terrain_type_manager)
bool add_region(std::string_view identifier, std::vector<std::string_view> const& province_identifiers);
IDENTIFIER_REGISTRY_ACCESSORS(region)
diff --git a/src/openvic-simulation/military/MilitaryManager.hpp b/src/openvic-simulation/military/MilitaryManager.hpp
index ba13b70..aeb5a7b 100644
--- a/src/openvic-simulation/military/MilitaryManager.hpp
+++ b/src/openvic-simulation/military/MilitaryManager.hpp
@@ -8,15 +8,9 @@
namespace OpenVic {
struct MilitaryManager {
private:
- UnitManager unit_manager;
- LeaderTraitManager leader_trait_manager;
- DeploymentManager deployment_manager;
- WargoalTypeManager wargoal_manager;
-
- public:
- REF_GETTERS(unit_manager)
- REF_GETTERS(leader_trait_manager)
- REF_GETTERS(deployment_manager)
- REF_GETTERS(wargoal_manager)
+ UnitManager PROPERTY_REF(unit_manager);
+ LeaderTraitManager PROPERTY_REF(leader_trait_manager);
+ DeploymentManager PROPERTY_REF(deployment_manager);
+ WargoalTypeManager PROPERTY_REF(wargoal_manager);
};
}
diff --git a/src/openvic-simulation/military/Unit.hpp b/src/openvic-simulation/military/Unit.hpp
index 632067e..65d0936 100644
--- a/src/openvic-simulation/military/Unit.hpp
+++ b/src/openvic-simulation/military/Unit.hpp
@@ -35,9 +35,9 @@ namespace OpenVic {
const type_t PROPERTY(type);
const icon_t PROPERTY(icon);
const std::string PROPERTY(sprite);
- const bool PROPERTY_CUSTOM_NAME(active, is_active);
+ const bool PROPERTY_CUSTOM_PREFIX(active, is);
const std::string PROPERTY(unit_type);
- const bool PROPERTY_CUSTOM_NAME(floating_flag, has_floating_flag);
+ const bool PROPERTY_CUSTOM_PREFIX(floating_flag, has);
const uint32_t PROPERTY(priority);
const fixed_point_t PROPERTY(max_strength);
@@ -64,7 +64,7 @@ namespace OpenVic {
friend struct UnitManager;
private:
- const bool PROPERTY_CUSTOM_NAME(primary_culture, is_primary_culture);
+ const bool PROPERTY_CUSTOM_PREFIX(primary_culture, is);
const std::string PROPERTY(sprite_override);
const std::string PROPERTY(sprite_mount);
const std::string PROPERTY(sprite_mount_attach_node);
@@ -87,11 +87,11 @@ namespace OpenVic {
private:
const icon_t PROPERTY(naval_icon);
- const bool PROPERTY_CUSTOM_NAME(sail, can_sail);
- const bool PROPERTY_CUSTOM_NAME(transport, is_transport);
- const bool PROPERTY_CUSTOM_NAME(capital, is_capital);
+ const bool PROPERTY_CUSTOM_PREFIX(sail, can);
+ const bool PROPERTY_CUSTOM_PREFIX(transport, is);
+ const bool PROPERTY_CUSTOM_PREFIX(capital, is);
const fixed_point_t PROPERTY(colonial_points);
- const bool PROPERTY_CUSTOM_NAME(build_overseas, can_build_overseas);
+ const bool PROPERTY_CUSTOM_PREFIX(build_overseas, can);
const uint32_t PROPERTY(min_port_level);
const int32_t PROPERTY(limit_per_port);
const fixed_point_t PROPERTY(supply_consumption_score);
diff --git a/src/openvic-simulation/misc/Modifier.hpp b/src/openvic-simulation/misc/Modifier.hpp
index 34acd9d..c1c532a 100644
--- a/src/openvic-simulation/misc/Modifier.hpp
+++ b/src/openvic-simulation/misc/Modifier.hpp
@@ -19,7 +19,7 @@ namespace OpenVic {
/* If true, positive values will be green and negative values will be red.
* If false, the colours will be switced.
*/
- const bool PROPERTY_CUSTOM_NAME(positive_good, is_positive_good);
+ const bool PROPERTY_CUSTOM_PREFIX(positive_good, is);
const format_t PROPERTY(format);
// TODO - format/precision, e.g. 80% vs 0.8 vs 0.800, 2 vs 2.0 vs 200%
diff --git a/src/openvic-simulation/politics/Government.hpp b/src/openvic-simulation/politics/Government.hpp
index fde7d32..0bc777a 100644
--- a/src/openvic-simulation/politics/Government.hpp
+++ b/src/openvic-simulation/politics/Government.hpp
@@ -10,8 +10,8 @@ namespace OpenVic {
private:
const std::vector<Ideology const*> PROPERTY(ideologies);
- const bool PROPERTY_CUSTOM_NAME(elections, holds_elections);
- const bool PROPERTY_CUSTOM_NAME(appoint_ruling_party, can_appoint_ruling_party);
+ const bool PROPERTY_CUSTOM_PREFIX(elections, holds);
+ const bool PROPERTY_CUSTOM_PREFIX(appoint_ruling_party, can);
const Timespan PROPERTY(term_duration);
const std::string PROPERTY_CUSTOM_NAME(flag_type_identifier, get_flag_type);
diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp
index 47ae45b..dd3f07a 100644
--- a/src/openvic-simulation/politics/Ideology.hpp
+++ b/src/openvic-simulation/politics/Ideology.hpp
@@ -20,7 +20,7 @@ namespace OpenVic {
private:
IdeologyGroup const& PROPERTY(group);
- const bool PROPERTY_CUSTOM_NAME(uncivilised, is_uncivilised);
+ const bool PROPERTY_CUSTOM_PREFIX(uncivilised, is);
const bool PROPERTY(can_reduce_militancy);
const Date PROPERTY(spawn_date);
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp
index 0dceae9..e9d154f 100644
--- a/src/openvic-simulation/politics/Issue.hpp
+++ b/src/openvic-simulation/politics/Issue.hpp
@@ -56,8 +56,8 @@ namespace OpenVic {
private:
ReformType const& PROPERTY(type);
- const bool PROPERTY_CUSTOM_NAME(ordered, is_ordered); // next_step_only
- const bool PROPERTY_CUSTOM_NAME(administrative, is_administrative);
+ const bool PROPERTY_CUSTOM_PREFIX(ordered, is); // next_step_only
+ const bool PROPERTY_CUSTOM_PREFIX(administrative, is);
ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative);
diff --git a/src/openvic-simulation/politics/PoliticsManager.hpp b/src/openvic-simulation/politics/PoliticsManager.hpp
index b30d1c0..532e64f 100644
--- a/src/openvic-simulation/politics/PoliticsManager.hpp
+++ b/src/openvic-simulation/politics/PoliticsManager.hpp
@@ -9,19 +9,13 @@
namespace OpenVic {
struct PoliticsManager {
private:
- GovernmentTypeManager government_type_manager;
- IdeologyManager ideology_manager;
- IssueManager issue_manager;
- NationalValueManager national_value_manager;
- NationalFocusManager national_focus_manager;
+ GovernmentTypeManager PROPERTY_REF(government_type_manager);
+ IdeologyManager PROPERTY_REF(ideology_manager);
+ IssueManager PROPERTY_REF(issue_manager);
+ NationalValueManager PROPERTY_REF(national_value_manager);
+ NationalFocusManager PROPERTY_REF(national_focus_manager);
public:
- REF_GETTERS(government_type_manager)
- REF_GETTERS(ideology_manager)
- REF_GETTERS(issue_manager)
- REF_GETTERS(national_value_manager)
- REF_GETTERS(national_focus_manager)
-
inline bool load_government_types_file(ast::NodeCPtr root) {
return government_type_manager.load_government_types_file(ideology_manager, root);
}
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index ff4ff5f..798e78e 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -80,15 +80,12 @@ namespace OpenVic {
private:
IdentifierRegistry<PopType> pop_types;
- CultureManager culture_manager;
- ReligionManager religion_manager;
+ CultureManager PROPERTY_REF(culture_manager);
+ ReligionManager PROPERTY_REF(religion_manager);
public:
PopManager();
- REF_GETTERS(culture_manager)
- REF_GETTERS(religion_manager)
-
bool add_pop_type(
std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite,
Good::good_map_t&& life_needs, Good::good_map_t&& everyday_needs, Good::good_map_t&& luxury_needs,
diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp
index 6c0dd3b..072ab07 100644
--- a/src/openvic-simulation/types/IdentifierRegistry.hpp
+++ b/src/openvic-simulation/types/IdentifierRegistry.hpp
@@ -105,7 +105,7 @@ namespace OpenVic {
const std::string name;
const bool log_lock;
- std::vector<_Storage> items;
+ std::vector<_Storage> PROPERTY_REF(items);
bool locked = false;
string_map_t<size_t> identifier_index_map;
@@ -248,8 +248,6 @@ namespace OpenVic {
return index < size();
}
- REF_GETTERS(items)
-
std::vector<std::string_view> get_item_identifiers() const {
std::vector<std::string_view> identifiers(items.size());
for (typename decltype(identifier_index_map)::value_type const& entry : identifier_index_map) {
diff --git a/src/openvic-simulation/utility/Getters.hpp b/src/openvic-simulation/utility/Getters.hpp
index 99c895c..1be9287 100644
--- a/src/openvic-simulation/utility/Getters.hpp
+++ b/src/openvic-simulation/utility/Getters.hpp
@@ -36,13 +36,17 @@
constexpr std::string_view get_base_type() const override { \
return ::ovdl::detail::type_name<std::decay_t<decltype(*this)>>(); }
-#define REF_GETTERS(var) \
- constexpr decltype(var)& get_##var() { \
- return var; \
+#define PROPERTY_REF(NAME) PROPERTY_REF_FULL(NAME, private)
+#define PROPERTY_REF_FULL(NAME, ACCESS) \
+ NAME; \
+public: \
+ constexpr decltype(NAME)& get_##NAME() { \
+ return NAME; \
} \
- constexpr decltype(var) const& get_##var() const { \
- return var; \
- }
+ constexpr decltype(NAME) const& get_##NAME() const { \
+ return NAME; \
+ } \
+ACCESS:
namespace OpenVic {
struct ReturnByValueProperty {};
@@ -88,6 +92,7 @@ namespace OpenVic {
* Province& PROPERTY(province); // Province& province; Province const& get_province() const;
*/
#define PROPERTY(NAME) PROPERTY_ACCESS(NAME, private)
+#define PROPERTY_CUSTOM_PREFIX(NAME, PREFIX) PROPERTY_CUSTOM_NAME(NAME, PREFIX##_##NAME)
#define PROPERTY_CUSTOM_NAME(NAME, GETTER_NAME) PROPERTY_FULL(NAME, GETTER_NAME, private)
#define PROPERTY_ACCESS(NAME, ACCESS) PROPERTY_FULL(NAME, get_##NAME, ACCESS)
#define PROPERTY_FULL(NAME, GETTER_NAME, ACCESS) \