aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-12-24 23:00:36 +0100
committer GitHub <noreply@github.com>2023-12-24 23:00:36 +0100
commitbf4e7368600bb425b6612231fbb84de34ec99a27 (patch)
treed3b29714d3286b9edbe380f877bbce541344a635 /src/openvic-simulation/pop
parentf036506b88af02508242f279ca29b743ef713976 (diff)
parent3770de7a03879a8ff6b8cf22b402217c19fa2b53 (diff)
Merge pull request #100 from OpenVicProject/change/colour_t_to_struct
Diffstat (limited to 'src/openvic-simulation/pop')
-rw-r--r--src/openvic-simulation/pop/Culture.cpp9
-rw-r--r--src/openvic-simulation/pop/Pop.cpp9
-rw-r--r--src/openvic-simulation/pop/Religion.cpp11
3 files changed, 10 insertions, 19 deletions
diff --git a/src/openvic-simulation/pop/Culture.cpp b/src/openvic-simulation/pop/Culture.cpp
index ee8ffd6..9b9d6c2 100644
--- a/src/openvic-simulation/pop/Culture.cpp
+++ b/src/openvic-simulation/pop/Culture.cpp
@@ -1,6 +1,7 @@
#include "Culture.hpp"
#include "openvic-simulation/dataloader/NodeTools.hpp"
+#include "openvic-simulation/types/Colour.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -16,7 +17,7 @@ CultureGroup::CultureGroup(
Culture::Culture(
std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group,
std::vector<std::string>&& new_first_names, std::vector<std::string>&& new_last_names
-) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, group { new_group },
+) : HasIdentifierAndColour { new_identifier, new_colour, false }, group { new_group },
first_names { std::move(new_first_names) }, last_names { std::move(new_last_names) } {}
bool CultureManager::add_graphical_culture_type(std::string_view identifier) {
@@ -61,10 +62,6 @@ bool CultureManager::add_culture(
Logger::error("Invalid culture identifier - empty!");
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) });
}
@@ -101,7 +98,7 @@ bool CultureManager::_load_culture(
CultureGroup const& culture_group, std::string_view culture_key, ast::NodeCPtr culture_node
) {
- colour_t colour = NULL_COLOUR;
+ colour_t colour = colour_t::null();
std::vector<std::string> first_names, last_names;
bool ret = expect_dictionary_keys(
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index 39deeaa..2b031c2 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -5,6 +5,7 @@
#include "openvic-simulation/dataloader/NodeTools.hpp"
#include "openvic-simulation/map/Province.hpp"
#include "openvic-simulation/politics/Rebel.hpp"
+#include "openvic-simulation/types/Colour.hpp"
#include "openvic-simulation/utility/Logger.hpp"
using namespace OpenVic;
@@ -32,7 +33,7 @@ PopType::PopType(
bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_allowed_to_vote, bool new_is_slave,
bool new_can_be_recruited, bool new_can_reduce_consciousness, bool new_administrative_efficiency, bool new_can_build,
bool new_factory, bool new_can_work_factory, bool new_unemployment
-) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, strata { new_strata }, sprite { new_sprite },
+) : HasIdentifierAndColour { new_identifier, new_colour, false }, strata { new_strata }, sprite { new_sprite },
life_needs { std::move(new_life_needs) }, everyday_needs { std::move(new_everyday_needs) },
luxury_needs { std::move(new_luxury_needs) }, rebel_units { std::move(new_rebel_units) }, max_size { new_max_size },
merge_max_size { new_merge_max_size }, state_capital_only { new_state_capital_only },
@@ -68,10 +69,6 @@ bool PopManager::add_pop_type(
Logger::error("Invalid pop type identifier - empty!");
return false;
}
- if (colour > MAX_COLOUR_RGB) {
- Logger::error("Invalid pop type colour for ", identifier, ": ", colour_to_hex_string(colour));
- return false;
- }
if (strata == nullptr) {
Logger::error("Invalid pop type strata for ", identifier, " - null!");
return false;
@@ -116,7 +113,7 @@ void PopManager::reserve_pop_types(size_t count) {
bool PopManager::load_pop_type_file(
std::string_view filestem, UnitManager const& unit_manager, GoodManager const& good_manager, ast::NodeCPtr root
) {
- colour_t colour = NULL_COLOUR;
+ colour_t colour = colour_t::null();
Strata const* strata = nullptr;
PopType::sprite_t sprite = 0;
Good::good_map_t life_needs, everyday_needs, luxury_needs;
diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp
index a5e9faf..0527da7 100644
--- a/src/openvic-simulation/pop/Religion.cpp
+++ b/src/openvic-simulation/pop/Religion.cpp
@@ -2,6 +2,8 @@
#include <cassert>
+#include "openvic-simulation/types/Colour.hpp"
+
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -9,8 +11,7 @@ ReligionGroup::ReligionGroup(std::string_view new_identifier) : HasIdentifier {
Religion::Religion(
std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, bool new_pagan
-) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, group { new_group }, icon { new_icon },
- pagan { new_pagan } {
+) : HasIdentifierAndColour { new_identifier, new_colour, false }, group { new_group }, icon { new_icon }, pagan { new_pagan } {
assert(icon > 0);
}
@@ -33,10 +34,6 @@ bool ReligionManager::add_religion(
Logger::error("Invalid religion identifier - empty!");
return false;
}
- if (colour > MAX_COLOUR_RGB) {
- Logger::error("Invalid religion colour for ", identifier, ": ", colour_to_hex_string(colour));
- return false;
- }
if (icon <= 0) {
Logger::error("Invalid religion icon for ", identifier, ": ", icon);
return false;
@@ -61,7 +58,7 @@ bool ReligionManager::load_religion_file(ast::NodeCPtr root) {
religions.reserve(religions.size() + total_expected_religions);
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;
+ colour_t colour = colour_t::null();
Religion::icon_t icon = 0;
bool pagan = false;