aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/politics
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-12-19 03:41:57 +0100
committer Spartan322 <Megacake1234@gmail.com>2023-12-24 22:57:56 +0100
commit3770de7a03879a8ff6b8cf22b402217c19fa2b53 (patch)
tree0d77d82ab8cea8955e2b86d883d1c2fd10813717 /src/openvic-simulation/politics
parent14e47d58b85f657ec1fed8abf88219f09bd3efbb (diff)
Change colour_t to be a strongly typed structure
Make RGB default of `colour_t` Distinguish RGB and ARGB colors by type and colour_traits Add `_colour` and `_argb` colour user-defined literals Add `OpenVic::utility::unreachable`
Diffstat (limited to 'src/openvic-simulation/politics')
-rw-r--r--src/openvic-simulation/politics/Ideology.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp
index fd5005d..577ab79 100644
--- a/src/openvic-simulation/politics/Ideology.cpp
+++ b/src/openvic-simulation/politics/Ideology.cpp
@@ -1,5 +1,7 @@
#include "Ideology.hpp"
+#include "openvic-simulation/types/Colour.hpp"
+
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -8,7 +10,7 @@ IdeologyGroup::IdeologyGroup(std::string_view new_identifier) : HasIdentifier {
Ideology::Ideology(
std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool new_uncivilised,
bool new_can_reduce_militancy, Date new_spawn_date
-) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, group { new_group }, uncivilised { new_uncivilised },
+) : HasIdentifierAndColour { new_identifier, new_colour, false }, group { new_group }, uncivilised { new_uncivilised },
can_reduce_militancy { new_can_reduce_militancy }, spawn_date { new_spawn_date } {}
bool IdeologyManager::add_ideology_group(std::string_view identifier) {
@@ -29,11 +31,6 @@ bool IdeologyManager::add_ideology(
return false;
}
- if (colour > MAX_COLOUR_RGB) {
- Logger::error("Invalid ideology colour for ", identifier, ": ", colour_to_hex_string(colour));
- return false;
- }
-
if (group == nullptr) {
Logger::error("Null ideology group for ", identifier);
return false;
@@ -61,7 +58,7 @@ bool IdeologyManager::load_ideology_file(ast::NodeCPtr root) {
IdeologyGroup const* ideology_group = get_ideology_group_by_identifier(ideology_group_key);
return expect_dictionary([this, ideology_group](std::string_view key, ast::NodeCPtr value) -> bool {
- colour_t colour = NULL_COLOUR;
+ colour_t colour = colour_t::null();
bool uncivilised = true, can_reduce_militancy = false;
Date spawn_date;