aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Map.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-11-07 22:38:07 +0100
committer GitHub <noreply@github.com>2023-11-07 22:38:07 +0100
commitae2742113ec7283a2a5afa62f8bfd98a865c4208 (patch)
tree601591215af0c6724766019ebb577141ea5807c5 /src/openvic-simulation/map/Map.cpp
parent1603fbafb1c03830f38fefd87d8bd0d7d3f135a2 (diff)
parentd30421fa7d7f6ad87d3f90cc0ab491742f0d2548 (diff)
Merge pull request #64 from OpenVicProject/modifier-instance
ModifierEffects stored as instances
Diffstat (limited to 'src/openvic-simulation/map/Map.cpp')
-rw-r--r--src/openvic-simulation/map/Map.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp
index 4df17bf..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;
@@ -292,7 +298,7 @@ bool Map::setup(BuildingManager const& building_manager, PopManager const& pop_m
return ret;
}
-void Map::update_state(Date const& today) {
+void Map::update_state(Date today) {
for (Province& province : provinces.get_items()) {
province.update_state(today);
}
@@ -300,7 +306,7 @@ void Map::update_state(Date const& today) {
update_total_map_population();
}
-void Map::tick(Date const& today) {
+void Map::tick(Date today) {
for (Province& province : provinces.get_items()) {
province.tick(today);
}
@@ -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;
@@ -514,7 +520,7 @@ bool Map::load_map_images(fs::path const& province_path, fs::path const& terrain
goto set_terrain;
}
}
- if (unrecognised_province_colours.find(province_colour) == unrecognised_province_colours.end()) {
+ if (!unrecognised_province_colours.contains(province_colour)) {
unrecognised_province_colours.insert(province_colour);
if (detailed_errors) {
Logger::warning(