aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/Good.cpp
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/economy/Good.cpp
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/economy/Good.cpp')
-rw-r--r--src/openvic-simulation/economy/Good.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/Good.cpp
index 44b896b..78150bb 100644
--- a/src/openvic-simulation/economy/Good.cpp
+++ b/src/openvic-simulation/economy/Good.cpp
@@ -10,7 +10,7 @@ GoodCategory::GoodCategory(std::string_view new_identifier) : HasIdentifier { ne
Good::Good(
std::string_view new_identifier, colour_t new_colour, index_t new_index, GoodCategory const& new_category,
price_t new_base_price, bool new_available_from_start, bool new_tradeable, bool new_money, bool new_overseas_penalty
-) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, index { new_index }, category { new_category },
+) : HasIdentifierAndColour { new_identifier, new_colour, false }, index { new_index }, category { new_category },
base_price { new_base_price }, available_from_start { new_available_from_start }, tradeable { new_tradeable },
money { new_money }, overseas_penalty { new_overseas_penalty } {
assert(base_price > NULL_PRICE);
@@ -37,10 +37,6 @@ bool GoodManager::add_good(
Logger::error("Invalid good identifier - empty!");
return false;
}
- if (colour > MAX_COLOUR_RGB) {
- Logger::error("Invalid good colour for ", identifier, ": ", colour_to_hex_string(colour));
- return false;
- }
if (base_price <= Good::NULL_PRICE) {
Logger::error("Invalid base price for ", identifier, ": ", base_price);
return false;
@@ -71,7 +67,7 @@ bool GoodManager::load_goods_file(ast::NodeCPtr root) {
goods.reserve(goods.size() + total_expected_goods);
ret &= expect_good_category_dictionary([this](GoodCategory const& good_category, ast::NodeCPtr good_category_value) -> bool {
return expect_dictionary([this, &good_category](std::string_view key, ast::NodeCPtr value) -> bool {
- colour_t colour = NULL_COLOUR;
+ colour_t colour = colour_t::null();
Good::price_t base_price;
bool available_from_start = true, tradeable = true;
bool money = false, overseas_penalty = false;