aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/pop')
-rw-r--r--src/openvic-simulation/pop/Culture.cpp15
-rw-r--r--src/openvic-simulation/pop/Culture.hpp6
-rw-r--r--src/openvic-simulation/pop/Pop.hpp2
-rw-r--r--src/openvic-simulation/pop/Religion.cpp14
-rw-r--r--src/openvic-simulation/pop/Religion.hpp2
5 files changed, 14 insertions, 25 deletions
diff --git a/src/openvic-simulation/pop/Culture.cpp b/src/openvic-simulation/pop/Culture.cpp
index 47501e0..376e2a3 100644
--- a/src/openvic-simulation/pop/Culture.cpp
+++ b/src/openvic-simulation/pop/Culture.cpp
@@ -77,7 +77,7 @@ bool CultureManager::add_culture_group(
}
bool CultureManager::add_culture(
- std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string>&& first_names,
+ std::string_view identifier, colour_t colour, CultureGroup const& group, std::vector<std::string>&& first_names,
std::vector<std::string>&& last_names
) {
if (!culture_groups.is_locked()) {
@@ -88,15 +88,11 @@ bool CultureManager::add_culture(
Logger::error("Invalid culture identifier - empty!");
return false;
}
- if (group == nullptr) {
- Logger::error("Null culture group for ", identifier);
- return false;
- }
if (colour > MAX_COLOUR_RGB) {
Logger::error("Invalid culture colour for ", identifier, ": ", colour_to_hex_string(colour));
return false;
}
- return cultures.add_item({ identifier, colour, *group, std::move(first_names), std::move(last_names) });
+ return cultures.add_item({ identifier, colour, group, std::move(first_names), std::move(last_names) });
}
bool CultureManager::load_graphical_culture_type_file(ast::NodeCPtr root) {
@@ -131,7 +127,7 @@ bool CultureManager::_load_culture_group(
}
bool CultureManager::_load_culture(
- CultureGroup const* culture_group, std::string_view culture_key, ast::NodeCPtr culture_node
+ CultureGroup const& culture_group, std::string_view culture_key, ast::NodeCPtr culture_node
) {
colour_t colour = NULL_COLOUR;
@@ -191,9 +187,8 @@ bool CultureManager::load_culture_file(ast::NodeCPtr root) {
lock_culture_groups();
cultures.reserve(cultures.size() + total_expected_cultures);
- ret &= expect_dictionary([this](std::string_view culture_group_key, ast::NodeCPtr culture_group_value) -> bool {
- CultureGroup const* culture_group = get_culture_group_by_identifier(culture_group_key);
- return expect_dictionary([this, culture_group](std::string_view key, ast::NodeCPtr value) -> bool {
+ ret &= expect_culture_group_dictionary([this](CultureGroup const& culture_group, ast::NodeCPtr culture_group_value) -> bool {
+ return expect_dictionary([this, &culture_group](std::string_view key, ast::NodeCPtr value) -> bool {
static const string_set_t reserved_keys = { "leader", "unit", "union", "is_overseas" };
if (reserved_keys.contains(key)) {
return true;
diff --git a/src/openvic-simulation/pop/Culture.hpp b/src/openvic-simulation/pop/Culture.hpp
index 402af0c..2abe77d 100644
--- a/src/openvic-simulation/pop/Culture.hpp
+++ b/src/openvic-simulation/pop/Culture.hpp
@@ -71,7 +71,7 @@ namespace OpenVic {
size_t& total_expected_cultures, GraphicalCultureType const* default_unit_graphical_culture_type,
std::string_view culture_group_key, ast::NodeCPtr culture_group_node
);
- bool _load_culture(CultureGroup const* culture_group, std::string_view culture_key, ast::NodeCPtr node);
+ bool _load_culture(CultureGroup const& culture_group, std::string_view culture_key, ast::NodeCPtr node);
public:
CultureManager();
@@ -80,13 +80,13 @@ namespace OpenVic {
IDENTIFIER_REGISTRY_ACCESSORS(graphical_culture_type)
bool add_culture_group(
- std::string_view identifier, std::string_view leader, GraphicalCultureType const* new_graphical_culture_type,
+ std::string_view identifier, std::string_view leader, GraphicalCultureType const* graphical_culture_type,
bool is_overseas
);
IDENTIFIER_REGISTRY_ACCESSORS(culture_group)
bool add_culture(
- std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string>&& first_names,
+ std::string_view identifier, colour_t colour, CultureGroup const& group, std::vector<std::string>&& first_names,
std::vector<std::string>&& last_names
);
IDENTIFIER_REGISTRY_ACCESSORS(culture)
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index 4abb2a9..f7f20fe 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -49,7 +49,7 @@ namespace OpenVic {
friend struct PopManager;
using sprite_t = uint8_t;
- using rebel_units_t = decimal_map_t<Unit const*>;
+ using rebel_units_t = fixed_point_map_t<Unit const*>;
private:
const enum class strata_t { POOR, MIDDLE, RICH } strata;
diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp
index 99915c3..f52ed3e 100644
--- a/src/openvic-simulation/pop/Religion.cpp
+++ b/src/openvic-simulation/pop/Religion.cpp
@@ -37,7 +37,7 @@ bool ReligionManager::add_religion_group(std::string_view identifier) {
}
bool ReligionManager::add_religion(
- std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan
+ std::string_view identifier, colour_t colour, ReligionGroup const& group, Religion::icon_t icon, bool pagan
) {
if (!religion_groups.is_locked()) {
Logger::error("Cannot register religions until religion groups are locked!");
@@ -47,10 +47,6 @@ bool ReligionManager::add_religion(
Logger::error("Invalid religion identifier - empty!");
return false;
}
- if (group == nullptr) {
- Logger::error("Null religion group for ", identifier);
- return false;
- }
if (colour > MAX_COLOUR_RGB) {
Logger::error("Invalid religion colour for ", identifier, ": ", colour_to_hex_string(colour));
return false;
@@ -59,7 +55,7 @@ bool ReligionManager::add_religion(
Logger::error("Invalid religion icon for ", identifier, ": ", icon);
return false;
}
- return religions.add_item({ identifier, colour, *group, icon, pagan });
+ return religions.add_item({ identifier, colour, group, icon, pagan });
}
/* REQUIREMENTS:
@@ -77,10 +73,8 @@ bool ReligionManager::load_religion_file(ast::NodeCPtr root) {
)(root);
lock_religion_groups();
religions.reserve(religions.size() + total_expected_religions);
- ret &= expect_dictionary([this](std::string_view religion_group_key, ast::NodeCPtr religion_group_value) -> bool {
- ReligionGroup const* religion_group = get_religion_group_by_identifier(religion_group_key);
-
- return expect_dictionary([this, religion_group](std::string_view key, ast::NodeCPtr value) -> bool {
+ ret &= expect_religion_group_dictionary([this](ReligionGroup const& religion_group, ast::NodeCPtr religion_group_value) -> bool {
+ return expect_dictionary([this, &religion_group](std::string_view key, ast::NodeCPtr value) -> bool {
colour_t colour = NULL_COLOUR;
Religion::icon_t icon = 0;
bool pagan = false;
diff --git a/src/openvic-simulation/pop/Religion.hpp b/src/openvic-simulation/pop/Religion.hpp
index a47754d..4cc8403 100644
--- a/src/openvic-simulation/pop/Religion.hpp
+++ b/src/openvic-simulation/pop/Religion.hpp
@@ -52,7 +52,7 @@ namespace OpenVic {
IDENTIFIER_REGISTRY_ACCESSORS(religion_group)
bool add_religion(
- std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan
+ std::string_view identifier, colour_t colour, ReligionGroup const& group, Religion::icon_t icon, bool pagan
);
IDENTIFIER_REGISTRY_ACCESSORS(religion)