diff options
author | Hop311 <Hop3114@gmail.com> | 2023-12-08 00:23:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-08 00:23:09 +0100 |
commit | abb0804b015d8444542af7a6c5db728c0fde4cfb (patch) | |
tree | 6789bacb931ccfd7c7dc9de9e22a17b78b725d09 /src/openvic-simulation/map | |
parent | 085fe94212c6f0ddbdfca1b2ba58223e7f6dcc8a (diff) | |
parent | 4320b37f7258c7e1f2585d67509045b5c9d6de06 (diff) |
Merge pull request #86 from OpenVicProject/meta-state-fix
Meta regions being used to make states fix
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r-- | src/openvic-simulation/map/Province.cpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/map/Province.hpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/map/State.cpp | 11 | ||||
-rw-r--r-- | src/openvic-simulation/map/State.hpp | 4 |
4 files changed, 10 insertions, 9 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp index 1f9ca99..363be6c 100644 --- a/src/openvic-simulation/map/Province.cpp +++ b/src/openvic-simulation/map/Province.cpp @@ -9,7 +9,7 @@ Province::Province( std::string_view new_identifier, colour_t new_colour, index_t new_index ) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, index { new_index }, region { nullptr }, on_map { false }, has_region { false }, water { false }, default_terrain_type { nullptr }, - terrain_type { nullptr }, life_rating { 0 }, colony_status { colony_status_t::STATE }, owner { nullptr }, + positions {}, terrain_type { nullptr }, life_rating { 0 }, colony_status { colony_status_t::STATE }, owner { nullptr }, controller { nullptr }, slave { false }, crime { nullptr }, rgo { nullptr }, buildings { "buildings", false }, total_population { 0 } { assert(index != NULL_INDEX); diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp index b45dd9c..e423938 100644 --- a/src/openvic-simulation/map/Province.hpp +++ b/src/openvic-simulation/map/Province.hpp @@ -68,7 +68,7 @@ namespace OpenVic { TerrainType const* PROPERTY(default_terrain_type); std::vector<adjacency_t> PROPERTY(adjacencies); - province_positions_t positions; + province_positions_t PROPERTY(positions); TerrainType const* PROPERTY(terrain_type); life_rating_t PROPERTY(life_rating); diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp index 8da1e85..896008e 100644 --- a/src/openvic-simulation/map/State.cpp +++ b/src/openvic-simulation/map/State.cpp @@ -8,16 +8,15 @@ State::State( Country const* owner, Province const* capital, Region::provinces_t&& provinces, Province::colony_status_t colony_status ) : owner { owner }, capital { capital }, provinces { std::move(provinces) }, colony_status { colony_status } {} -StateSet::StateSet(Region const* new_region) { - if (region->get_meta()) { +StateSet::StateSet(Region const& new_region) : region { new_region } { + if (region.get_meta()) { Logger::error("Cannot use meta region as state template!"); } - region = new_region; std::vector<Region::provinces_t> temp_provinces; bool in_state = false; - for (Province* province : region->get_provinces()) { + for (Province* province : region.get_provinces()) { // add to existing state if shared owner & status... for (Region::provinces_t& provinces : temp_provinces) { if (provinces[0] == province) { @@ -77,7 +76,9 @@ void StateManager::generate_states(Map const& map) { regions.clear(); regions.reserve(map.get_region_count()); for(Region const& region : map.get_regions()) { - regions.push_back(StateSet(®ion)); + if (!region.get_meta()) { + regions.push_back(StateSet(region)); + } } Logger::info("Generated states."); } diff --git a/src/openvic-simulation/map/State.hpp b/src/openvic-simulation/map/State.hpp index e403580..bb23b2d 100644 --- a/src/openvic-simulation/map/State.hpp +++ b/src/openvic-simulation/map/State.hpp @@ -29,11 +29,11 @@ namespace OpenVic { using states_t = std::deque<State>; private: - Region const* PROPERTY(region); + Region const& PROPERTY(region); states_t states; public: - StateSet(Region const* new_region); + StateSet(Region const& new_region); bool add_state(State&& state); bool remove_state(State const* state); |