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/Pop.cpp38
-rw-r--r--src/openvic-simulation/pop/Pop.hpp53
2 files changed, 49 insertions, 42 deletions
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index 4f8bdcb..8f4c445 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -1,6 +1,7 @@
#include "Pop.hpp"
#include "openvic-simulation/country/CountryDefinition.hpp"
+#include "openvic-simulation/map/ProvinceInstance.hpp"
#include "openvic-simulation/military/UnitType.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/politics/Issue.hpp"
@@ -12,18 +13,14 @@ using namespace OpenVic::NodeTools;
using enum PopType::income_type_t;
-Pop::Pop(
- PopType const& new_type,
- Culture const& new_culture,
- Religion const& new_religion,
- pop_size_t new_size,
- fixed_point_t new_militancy,
- fixed_point_t new_consciousness,
- RebelType const* new_rebel_type
-) : type { new_type },
- culture { new_culture },
- religion { new_religion },
- size { new_size },
+PopBase::PopBase(
+ PopType const& new_type, Culture const& new_culture, Religion const& new_religion, pop_size_t new_size,
+ fixed_point_t new_militancy, fixed_point_t new_consciousness, RebelType const* new_rebel_type
+) : type { new_type }, culture { new_culture }, religion { new_religion }, size { new_size }, militancy { new_militancy },
+ consciousness { new_consciousness }, rebel_type { new_rebel_type } {}
+
+Pop::Pop(PopBase const& pop_base)
+ : PopBase { pop_base },
location { nullptr },
total_change { 0 },
num_grown { 0 },
@@ -32,9 +29,6 @@ Pop::Pop(
num_migrated_internal { 0 },
num_migrated_external { 0 },
num_migrated_colonial { 0 },
- militancy { new_militancy },
- consciousness { new_consciousness },
- rebel_type { new_rebel_type },
ideologies {},
issues {},
votes {},
@@ -117,6 +111,14 @@ void Pop::setup_pop_test_values(
luxury_needs_fulfilled = test_range();
}
+void Pop::set_location(ProvinceInstance const& new_location) {
+ if (location != &new_location) {
+ location = &new_location;
+
+ // TODO - update location dependent attributes
+ }
+}
+
Strata::Strata(std::string_view new_identifier) : HasIdentifier { new_identifier } {}
PopType::PopType(
@@ -596,8 +598,8 @@ bool PopManager::load_pop_type_chances_file(ast::NodeCPtr root) {
)(root);
}
-bool PopManager::load_pop_into_vector(
- RebelManager const& rebel_manager, std::vector<Pop>& vec, PopType const& type, ast::NodeCPtr pop_node,
+bool PopManager::load_pop_bases_into_vector(
+ RebelManager const& rebel_manager, std::vector<PopBase>& vec, PopType const& type, ast::NodeCPtr pop_node,
bool *non_integer_size
) const {
Culture const* culture = nullptr;
@@ -620,7 +622,7 @@ bool PopManager::load_pop_into_vector(
}
if (culture != nullptr && religion != nullptr && size >= 1) {
- vec.emplace_back(Pop { type, *culture, *religion, size.to_int64_t(), militancy, consciousness, rebel_type });
+ vec.emplace_back(PopBase { type, *culture, *religion, size.to_int64_t(), militancy, consciousness, rebel_type });
} else {
Logger::warning(
"Some pop arguments are invalid: culture = ", culture, ", religion = ", religion, ", size = ", size
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index b069f02..8ac6d4c 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -26,22 +26,36 @@ namespace OpenVic {
struct ProvinceInstance;
struct CountryParty;
- /* REQUIREMENTS:
- * POP-18, POP-19, POP-20, POP-21, POP-34, POP-35, POP-36, POP-37
- */
- struct Pop {
+ struct PopBase {
friend struct PopManager;
using pop_size_t = int64_t;
+ protected:
+ PopType const& PROPERTY_ACCESS(type, protected);
+ Culture const& PROPERTY_ACCESS(culture, protected);
+ Religion const& PROPERTY_ACCESS(religion, protected);
+ pop_size_t PROPERTY_ACCESS(size, protected);
+ fixed_point_t PROPERTY_ACCESS(militancy, protected);
+ fixed_point_t PROPERTY_ACCESS(consciousness, protected);
+ RebelType const* PROPERTY_ACCESS(rebel_type, protected);
+
+ PopBase(
+ PopType const& new_type, Culture const& new_culture, Religion const& new_religion, pop_size_t new_size,
+ fixed_point_t new_militancy, fixed_point_t new_consciousness, RebelType const* new_rebel_type
+ );
+ };
+
+ /* REQUIREMENTS:
+ * POP-18, POP-19, POP-20, POP-21, POP-34, POP-35, POP-36, POP-37
+ */
+ struct Pop : PopBase {
+ friend struct ProvinceInstance;
+
static constexpr pop_size_t MAX_SIZE = std::numeric_limits<pop_size_t>::max();
private:
- PopType const& PROPERTY(type);
- Culture const& PROPERTY(culture);
- Religion const& PROPERTY(religion);
- pop_size_t PROPERTY(size);
- ProvinceInstance const* PROPERTY_RW(location);
+ ProvinceInstance const* PROPERTY(location);
/* Last day's size change by source. */
pop_size_t PROPERTY(total_change);
@@ -52,10 +66,7 @@ namespace OpenVic {
pop_size_t PROPERTY(num_migrated_external);
pop_size_t PROPERTY(num_migrated_colonial);
- fixed_point_t PROPERTY(militancy);
- fixed_point_t PROPERTY(consciousness);
fixed_point_t PROPERTY(literacy);
- RebelType const* PROPERTY(rebel_type);
fixed_point_map_t<Ideology const*> PROPERTY(ideologies);
fixed_point_map_t<Issue const*> PROPERTY(issues);
@@ -70,18 +81,10 @@ namespace OpenVic {
fixed_point_t PROPERTY(everyday_needs_fulfilled);
fixed_point_t PROPERTY(luxury_needs_fulfilled);
- Pop(
- PopType const& new_type,
- Culture const& new_culture,
- Religion const& new_religion,
- pop_size_t new_size,
- fixed_point_t new_militancy,
- fixed_point_t new_consciousness,
- RebelType const* new_rebel_type
- );
+ Pop(PopBase const& pop_base);
public:
- Pop(Pop const&) = default;
+ Pop(Pop const&) = delete;
Pop(Pop&&) = default;
Pop& operator=(Pop const&) = delete;
Pop& operator=(Pop&&) = delete;
@@ -89,6 +92,8 @@ namespace OpenVic {
void setup_pop_test_values(
IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country
);
+
+ void set_location(ProvinceInstance const& new_location);
};
struct Strata : HasIdentifier {
@@ -319,8 +324,8 @@ namespace OpenVic {
bool load_pop_type_chances_file(ast::NodeCPtr root);
- bool load_pop_into_vector(
- RebelManager const& rebel_manager, std::vector<Pop>& vec, PopType const& type, ast::NodeCPtr pop_node,
+ bool load_pop_bases_into_vector(
+ RebelManager const& rebel_manager, std::vector<PopBase>& vec, PopType const& type, ast::NodeCPtr pop_node,
bool *non_integer_size
) const;