diff options
author | hop311 <hop3114@gmail.com> | 2024-06-07 00:20:58 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-06-07 12:28:16 +0200 |
commit | 1198a780916e65cae048dd3478f614c1d18db846 (patch) | |
tree | f681dd2e76d489ba6e7beea44ae6ebd59e9d51f3 /src/openvic-simulation/map/State.cpp | |
parent | c94a06477fc3930e8f8f2e5f971fc4b5b838ea0d (diff) |
Separated MapDefinition and MapInstancemap-instance
Diffstat (limited to 'src/openvic-simulation/map/State.cpp')
-rw-r--r-- | src/openvic-simulation/map/State.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/openvic-simulation/map/State.cpp b/src/openvic-simulation/map/State.cpp index 1c49ed7..46ff11d 100644 --- a/src/openvic-simulation/map/State.cpp +++ b/src/openvic-simulation/map/State.cpp @@ -1,7 +1,8 @@ #include "State.hpp" #include "openvic-simulation/country/Country.hpp" -#include "openvic-simulation/map/Map.hpp" +#include "openvic-simulation/map/MapDefinition.hpp" +#include "openvic-simulation/map/MapInstance.hpp" #include "openvic-simulation/map/ProvinceInstance.hpp" #include "openvic-simulation/map/Region.hpp" @@ -39,7 +40,7 @@ void StateSet::update_gamestate() { } } -bool StateManager::add_state_set(Map& map, Region const& region) { +bool StateManager::add_state_set(MapInstance& map_instance, Region const& region) { if (region.get_meta()) { Logger::error("Cannot use meta region \"", region.get_identifier(), "\" as state template!"); return false; @@ -54,7 +55,7 @@ bool StateManager::add_state_set(Map& map, Region const& region) { for (ProvinceDefinition const* province : region.get_provinces()) { - ProvinceInstance* province_instance = map.get_province_instance_from_const(province); + ProvinceInstance* province_instance = map_instance.get_province_instance_from_const(province); // add to existing state if shared owner & status... for (std::vector<ProvinceInstance*>& provinces : temp_provinces) { @@ -98,16 +99,18 @@ bool StateManager::add_state_set(Map& map, Region const& region) { return true; } -bool StateManager::generate_states(Map& map) { +bool StateManager::generate_states(MapInstance& map_instance) { + MapDefinition const& map_definition = map_instance.get_map_definition(); + state_sets.clear(); - state_sets.reserve(map.get_region_count()); + state_sets.reserve(map_definition.get_region_count()); bool ret = true; size_t state_count = 0; - for (Region const& region : map.get_regions()) { + for (Region const& region : map_definition.get_regions()) { if (!region.get_meta()) { - if (add_state_set(map, region)) { + if (add_state_set(map_instance, region)) { state_count += state_sets.back().get_state_count(); } else { ret = false; |