aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/economy
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-08-24 01:32:23 +0200
committer Hop311 <hop3114@gmail.com>2023-08-24 01:32:23 +0200
commitefa88c722fcb6c8fea7a86e1b3b8a83f1f59eb31 (patch)
tree0d64199bf4f19fabaaff083b35aa8625823d6c1e /src/openvic/economy
parent6f4a6c77c6f2613e65a403c3a2964d5041a538c7 (diff)
Big Dataloader Commit (openvic-simulation)
Diffstat (limited to 'src/openvic/economy')
-rw-r--r--src/openvic/economy/Good.cpp8
-rw-r--r--src/openvic/economy/Good.hpp8
2 files changed, 10 insertions, 6 deletions
diff --git a/src/openvic/economy/Good.cpp b/src/openvic/economy/Good.cpp
index 9e8a7dd..f14c170 100644
--- a/src/openvic/economy/Good.cpp
+++ b/src/openvic/economy/Good.cpp
@@ -20,11 +20,11 @@ std::string const& Good::get_category() const {
return category;
}
-price_t Good::get_base_price() const {
+Good::price_t Good::get_base_price() const {
return base_price;
}
-price_t Good::get_price() const {
+Good::price_t Good::get_price() const {
return price;
}
@@ -44,7 +44,7 @@ void Good::reset_to_defaults() {
GoodManager::GoodManager() : goods { "goods" } {}
return_t GoodManager::add_good(const std::string_view identifier, colour_t colour, const std::string_view category,
- price_t base_price, bool default_available, bool tradeable, bool currency, bool overseas_maintenance) {
+ Good::price_t base_price, bool default_available, bool tradeable, bool currency, bool overseas_maintenance) {
if (identifier.empty()) {
Logger::error("Invalid good identifier - empty!");
return FAILURE;
@@ -57,7 +57,7 @@ return_t GoodManager::add_good(const std::string_view identifier, colour_t colou
Logger::error("Invalid good category for ", identifier, ": empty!");
return FAILURE;
}
- if (base_price <= NULL_PRICE) {
+ if (base_price <= Good::NULL_PRICE) {
Logger::error("Invalid base price for ", identifier, ": ", base_price);
return FAILURE;
}
diff --git a/src/openvic/economy/Good.hpp b/src/openvic/economy/Good.hpp
index cfe185d..5c8e68c 100644
--- a/src/openvic/economy/Good.hpp
+++ b/src/openvic/economy/Good.hpp
@@ -1,6 +1,7 @@
#pragma once
-#include "../Types.hpp"
+#include "openvic/types/IdentifierRegistry.hpp"
+#include "openvic/types/fixed_point/FP.hpp"
namespace OpenVic {
struct GoodManager;
@@ -20,6 +21,9 @@ namespace OpenVic {
struct Good : HasIdentifierAndColour {
friend struct GoodManager;
+ using price_t = FP;
+ static constexpr price_t NULL_PRICE = FP::_0();
+
private:
const std::string category;
const price_t base_price;
@@ -48,7 +52,7 @@ namespace OpenVic {
public:
GoodManager();
- return_t add_good(const std::string_view identifier, colour_t colour, const std::string_view category, price_t base_price,
+ return_t add_good(const std::string_view identifier, colour_t colour, const std::string_view category, Good::price_t base_price,
bool default_available, bool tradeable, bool currency, bool overseas_maintenance);
void lock_goods();
void reset_to_defaults();