aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Map.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map/Map.hpp')
-rw-r--r--src/openvic-simulation/map/Map.hpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp
index e477b38..2575324 100644
--- a/src/openvic-simulation/map/Map.hpp
+++ b/src/openvic-simulation/map/Map.hpp
@@ -49,7 +49,6 @@ namespace OpenVic {
* MAP-4
*/
struct Map {
-
#pragma pack(push, 1)
/* Used to represent tightly packed 3-byte integer pixel information. */
struct shape_pixel_t {
@@ -63,6 +62,8 @@ namespace OpenVic {
IdentifierRegistry<Province> IDENTIFIER_REGISTRY_CUSTOM_INDEX_OFFSET(province, 1);
IdentifierRegistry<Region> IDENTIFIER_REGISTRY(region);
IdentifierRegistry<Mapmode> IDENTIFIER_REGISTRY(mapmode);
+ IdentifierRegistry<Climate> IDENTIFIER_REGISTRY(climate);
+ IdentifierRegistry<Continent> IDENTIFIER_REGISTRY(continent);
ProvinceSet water_provinces;
TerrainTypeManager PROPERTY_REF(terrain_type_manager);
@@ -87,6 +88,15 @@ namespace OpenVic {
bool add_province(std::string_view identifier, colour_t colour);
IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS_CUSTOM_INDEX_OFFSET(province, 1);
+ /* This provides a safe way to remove the const qualifier of a Province const*, via a non-const Map.
+ * It uses a const_cast (the fastest/simplest solution), but this could also be done without it by looking up the
+ * Province* using the Province const*'s index. Requiring a non-const Map ensures that this function can only be
+ * used where the Province* could already be accessed by other means, such as the index method, preventing
+ * misleading code, or in the worst case undefined behaviour. */
+ constexpr Province* remove_province_const(Province const* province) {
+ return const_cast<Province*>(province);
+ }
+
bool set_water_province(std::string_view identifier);
bool set_water_province_list(std::vector<std::string_view> const& list);
void lock_water_provinces();
@@ -97,8 +107,7 @@ namespace OpenVic {
Province* get_selected_province();
Province::index_t get_selected_province_index() const;
- bool add_region(std::string_view identifier, std::vector<std::string_view> const& province_identifiers);
- IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS(region)
+ bool add_region(std::string_view identifier, Region::provinces_t const& provinces);
bool add_mapmode(std::string_view identifier, Mapmode::colour_func_t colour_func);
@@ -124,5 +133,7 @@ namespace OpenVic {
bool load_region_file(ast::NodeCPtr root);
bool load_map_images(fs::path const& province_path, fs::path const& terrain_path, bool detailed_errors);
bool generate_and_load_province_adjacencies(std::vector<ovdl::csv::LineObject> const& additional_adjacencies);
+ bool load_climate_file(ModifierManager const& modifier_manager, ast::NodeCPtr root);
+ bool load_continent_file(ModifierManager const& modifier_manager, ast::NodeCPtr root);
};
}