aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/Map.cpp8
-rw-r--r--src/openvic-simulation/map/Province.cpp26
-rw-r--r--src/openvic-simulation/map/Province.hpp9
3 files changed, 20 insertions, 23 deletions
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp
index b1aea2c..7e2213e 100644
--- a/src/openvic-simulation/map/Map.cpp
+++ b/src/openvic-simulation/map/Map.cpp
@@ -42,6 +42,12 @@ bool Map::add_province(std::string_view identifier, colour_t colour) {
Logger::error("Invalid province identifier - empty!");
return false;
}
+ if (!valid_basic_identifier(identifier)) {
+ Logger::error(
+ "Invalid province identifier: ", identifier, " (can only contain alphanumeric characters and underscores)"
+ );
+ return false;
+ }
if (colour == NULL_COLOUR || colour > MAX_COLOUR_RGB) {
Logger::error("Invalid province colour for ", identifier, ": ", colour_to_hex_string(colour));
return false;
@@ -483,7 +489,7 @@ bool Map::load_map_images(fs::path const& province_path, fs::path const& terrain
uint8_t const* terrain_data = terrain_bmp.get_pixel_data().data();
std::vector<bool> province_checklist(provinces.size());
- std::vector<distribution_t> terrain_type_pixels_list(provinces.size());
+ std::vector<decimal_map_t<TerrainType const*>> terrain_type_pixels_list(provinces.size());
bool ret = true;
std::unordered_set<colour_t> unrecognised_province_colours;
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index 66e4daf..77bf33f 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -131,31 +131,21 @@ Pop::pop_size_t Province::get_total_population() const {
return total_population;
}
-distribution_t const& Province::get_pop_type_distribution() const {
- return pop_types;
-}
-
-distribution_t const& Province::get_culture_distribution() const {
- return cultures;
-}
-
-distribution_t const& Province::get_religion_distribution() const {
- return religions;
-}
-
/* REQUIREMENTS:
* MAP-65, MAP-68, MAP-70, MAP-234
*/
void Province::update_pops() {
total_population = 0;
- pop_types.clear();
- cultures.clear();
- religions.clear();
+ pop_type_distribution.clear();
+ ideology_distribution.clear();
+ culture_distribution.clear();
+ religion_distribution.clear();
for (Pop const& pop : pops) {
total_population += pop.get_size();
- pop_types[&pop.get_type()] += pop.get_size();
- cultures[&pop.get_culture()] += pop.get_size();
- religions[&pop.get_religion()] += pop.get_size();
+ pop_type_distribution[&pop.get_type()] += pop.get_size();
+ //ideology_distribution[&pop.get_???()] += pop.get_size();
+ culture_distribution[&pop.get_culture()] += pop.get_size();
+ religion_distribution[&pop.get_religion()] += pop.get_size();
}
}
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp
index 6c022b7..2fd15c9 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -3,6 +3,7 @@
#include <cassert>
#include "openvic-simulation/economy/Building.hpp"
+#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/pop/Pop.hpp"
namespace OpenVic {
@@ -72,7 +73,10 @@ namespace OpenVic {
std::vector<Pop> pops;
Pop::pop_size_t total_population;
- distribution_t pop_types, cultures, religions;
+ decimal_map_t<PopType const*> PROPERTY(pop_type_distribution);
+ decimal_map_t<Ideology const*> PROPERTY(ideology_distribution);
+ decimal_map_t<Culture const*> PROPERTY(culture_distribution);
+ decimal_map_t<Religion const*> PROPERTY(religion_distribution);
std::vector<adjacency_t> adjacencies;
province_positions_t positions;
@@ -109,9 +113,6 @@ namespace OpenVic {
size_t get_pop_count() const;
std::vector<Pop> const& get_pops() const;
Pop::pop_size_t get_total_population() const;
- distribution_t const& get_pop_type_distribution() const;
- distribution_t const& get_culture_distribution() const;
- distribution_t const& get_religion_distribution() const;
void update_pops();
void update_state(Date today);