aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-07-04 10:38:54 +0200
committer GitHub <noreply@github.com>2024-07-04 10:38:54 +0200
commit8c8b9349e26b4f606e18810a201ff378eaac19b2 (patch)
treec8d10e8c2b38208401f30e9b3acf7fc4a071583f /src/openvic-simulation/map
parentbfd539513af435564daf70f94f6cce146dd5c948 (diff)
parent326db6b4779bf3662752243d929ff3d605870049 (diff)
Merge pull request #167 from OpenVicProject/country-definition
Renamed Country to CountryDefinition
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/MapInstance.cpp2
-rw-r--r--src/openvic-simulation/map/MapInstance.hpp4
-rw-r--r--src/openvic-simulation/map/Mapmode.cpp2
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp18
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp17
-rw-r--r--src/openvic-simulation/map/State.cpp5
-rw-r--r--src/openvic-simulation/map/State.hpp6
7 files changed, 27 insertions, 27 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp
index 093d341..1547ade 100644
--- a/src/openvic-simulation/map/MapInstance.cpp
+++ b/src/openvic-simulation/map/MapInstance.cpp
@@ -86,7 +86,7 @@ bool MapInstance::setup(BuildingTypeManager const& building_type_manager) {
bool MapInstance::apply_history_to_provinces(
ProvinceHistoryManager const& history_manager, Date date, IdeologyManager const& ideology_manager,
- IssueManager const& issue_manager, Country const& country
+ IssueManager const& issue_manager, CountryDefinition const& country
) {
bool ret = true;
diff --git a/src/openvic-simulation/map/MapInstance.hpp b/src/openvic-simulation/map/MapInstance.hpp
index 353a3a4..2c0ff74 100644
--- a/src/openvic-simulation/map/MapInstance.hpp
+++ b/src/openvic-simulation/map/MapInstance.hpp
@@ -12,7 +12,7 @@ namespace OpenVic {
struct ProvinceHistoryManager;
struct IdeologyManager;
struct IssueManager;
- struct Country;
+ struct CountryDefinition;
/* REQUIREMENTS:
* MAP-4
@@ -47,7 +47,7 @@ namespace OpenVic {
bool setup(BuildingTypeManager const& building_type_manager);
bool apply_history_to_provinces(
ProvinceHistoryManager const& history_manager, Date date, IdeologyManager const& ideology_manager,
- IssueManager const& issue_manager, Country const& country
+ IssueManager const& issue_manager, CountryDefinition const& country
);
void update_gamestate(Date today);
diff --git a/src/openvic-simulation/map/Mapmode.cpp b/src/openvic-simulation/map/Mapmode.cpp
index 410ea2b..f03b0e8 100644
--- a/src/openvic-simulation/map/Mapmode.cpp
+++ b/src/openvic-simulation/map/Mapmode.cpp
@@ -2,7 +2,7 @@
#include <cassert>
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/map/MapDefinition.hpp"
#include "openvic-simulation/map/MapInstance.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index 2a0863d..61b1527 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -1,6 +1,6 @@
#include "ProvinceInstance.hpp"
-#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/history/ProvinceHistory.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
#include "openvic-simulation/military/UnitInstance.hpp"
@@ -39,8 +39,8 @@ bool ProvinceInstance::expand_building(size_t building_index) {
return building->expand();
}
-void ProvinceInstance::_add_pop(Pop pop) {
- pop.set_location(this);
+void ProvinceInstance::_add_pop(Pop&& pop) {
+ pop.set_location(*this);
pops.push_back(std::move(pop));
}
@@ -54,11 +54,11 @@ bool ProvinceInstance::add_pop(Pop&& pop) {
}
}
-bool ProvinceInstance::add_pop_vec(std::vector<Pop> const& pop_vec) {
+bool ProvinceInstance::add_pop_vec(std::vector<PopBase> const& pop_vec) {
if (!province_definition.is_water()) {
reserve_more(pops, pop_vec.size());
- for (Pop const& pop : pop_vec) {
- _add_pop(pop);
+ for (PopBase const& pop : pop_vec) {
+ _add_pop(Pop { pop });
}
return true;
} else {
@@ -176,7 +176,7 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const* ent
if (entry->get_owner()) owner = *entry->get_owner();
if (entry->get_controller()) controller = *entry->get_controller();
if (entry->get_slave()) slave = *entry->get_slave();
- for (Country const* core : entry->get_remove_cores()) {
+ for (CountryDefinition const* core : entry->get_remove_cores()) {
const typename decltype(cores)::iterator existing_core = std::find(cores.begin(), cores.end(), core);
if (existing_core != cores.end()) {
cores.erase(existing_core);
@@ -186,7 +186,7 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const* ent
);
}
}
- for (Country const* core : entry->get_add_cores()) {
+ for (CountryDefinition const* core : entry->get_add_cores()) {
const typename decltype(cores)::iterator existing_core = std::find(cores.begin(), cores.end(), core);
if (existing_core == cores.end()) {
cores.push_back(core);
@@ -215,7 +215,7 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const* ent
}
void ProvinceInstance::setup_pop_test_values(
- IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country
+ IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country
) {
for (Pop& pop : pops) {
pop.setup_pop_test_values(ideology_manager, issue_manager, country);
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index 67ce423..ca7f149 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -11,7 +11,7 @@ namespace OpenVic {
struct ProvinceDefinition;
struct TerrainType;
struct State;
- struct Country;
+ struct CountryDefinition;
struct Crime;
struct GoodDefinition;
struct ArmyInstance;
@@ -31,16 +31,17 @@ namespace OpenVic {
enum struct colony_status_t : uint8_t { STATE, PROTECTORATE, COLONY };
+ private:
ProvinceDefinition const& PROPERTY(province_definition);
- /* Mutable attributes (reset before loading history) */
TerrainType const* PROPERTY(terrain_type);
life_rating_t PROPERTY(life_rating);
colony_status_t PROPERTY(colony_status);
State const* PROPERTY_RW(state);
- Country const* PROPERTY(owner);
- Country const* PROPERTY(controller);
- std::vector<Country const*> PROPERTY(cores);
+ CountryDefinition const* PROPERTY(owner);
+ CountryDefinition const* PROPERTY(controller);
+ // Cores being CountryDefinitions means then they won't be affected by tag switched (as desired)
+ std::vector<CountryDefinition const*> PROPERTY(cores);
bool PROPERTY(slave);
Crime const* PROPERTY_RW(crime);
// TODO - change this into a factory-like structure
@@ -58,7 +59,7 @@ namespace OpenVic {
ProvinceInstance(ProvinceDefinition const& new_province_definition);
- void _add_pop(Pop pop);
+ void _add_pop(Pop&& pop);
void _update_pops();
public:
@@ -71,7 +72,7 @@ namespace OpenVic {
bool expand_building(size_t building_index);
bool add_pop(Pop&& pop);
- bool add_pop_vec(std::vector<Pop> const& pop_vec);
+ bool add_pop_vec(std::vector<PopBase> const& pop_vec);
size_t get_pop_count() const;
void update_gamestate(Date today);
@@ -86,7 +87,7 @@ namespace OpenVic {
bool apply_history_to_province(ProvinceHistoryEntry const* entry);
void setup_pop_test_values(
- IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country
+ IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country
);
};
}
diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp
index 46ff11d..42d84cc 100644
--- a/src/openvic-simulation/map/State.cpp
+++ b/src/openvic-simulation/map/State.cpp
@@ -1,6 +1,5 @@
#include "State.hpp"
-#include "openvic-simulation/country/Country.hpp"
#include "openvic-simulation/map/MapDefinition.hpp"
#include "openvic-simulation/map/MapInstance.hpp"
#include "openvic-simulation/map/ProvinceInstance.hpp"
@@ -9,8 +8,8 @@
using namespace OpenVic;
State::State(
- StateSet const& new_state_set, Country const* owner, ProvinceInstance* capital, std::vector<ProvinceInstance*>&& provinces,
- ProvinceInstance::colony_status_t colony_status
+ StateSet const& new_state_set, CountryDefinition const* owner, ProvinceInstance* capital,
+ std::vector<ProvinceInstance*>&& provinces, ProvinceInstance::colony_status_t colony_status
) : state_set { new_state_set }, owner { owner }, capital { capital }, provinces { std::move(provinces) },
colony_status { colony_status } {}
diff --git a/src/openvic-simulation/map/State.hpp b/src/openvic-simulation/map/State.hpp
index ff8acfa..6111668 100644
--- a/src/openvic-simulation/map/State.hpp
+++ b/src/openvic-simulation/map/State.hpp
@@ -9,7 +9,7 @@
namespace OpenVic {
struct StateManager;
struct StateSet;
- struct Country;
+ struct CountryDefinition;
struct ProvinceInstance;
struct State {
@@ -17,7 +17,7 @@ namespace OpenVic {
private:
StateSet const& PROPERTY(state_set);
- Country const* PROPERTY(owner);
+ CountryDefinition const* PROPERTY(owner);
ProvinceInstance* PROPERTY(capital);
std::vector<ProvinceInstance*> PROPERTY(provinces);
ProvinceInstance::colony_status_t PROPERTY(colony_status);
@@ -25,7 +25,7 @@ namespace OpenVic {
Pop::pop_size_t PROPERTY(total_population);
State(
- StateSet const& new_state_set, Country const* owner, ProvinceInstance* capital,
+ StateSet const& new_state_set, CountryDefinition const* owner, ProvinceInstance* capital,
std::vector<ProvinceInstance*>&& provinces, ProvinceInstance::colony_status_t colony_status
);