aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2023-12-10 23:15:41 +0100
committer zaaarf <me@zaaarf.foo>2023-12-10 23:15:41 +0100
commit4ef33d4df6198e613b0f27406d49978c8ea2fb97 (patch)
tree7f07835485b877f3c01c52c188892499e5812f9b /src/openvic-simulation/map
parent1eb28bd4fb959b69a30013f6438f0257a2ee7b03 (diff)
feat: improved identifier registry macro
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/Crime.cpp2
-rw-r--r--src/openvic-simulation/map/Crime.hpp5
-rw-r--r--src/openvic-simulation/map/Map.cpp2
-rw-r--r--src/openvic-simulation/map/Map.hpp11
-rw-r--r--src/openvic-simulation/map/Province.hpp3
-rw-r--r--src/openvic-simulation/map/TerrainType.cpp3
-rw-r--r--src/openvic-simulation/map/TerrainType.hpp8
7 files changed, 7 insertions, 27 deletions
diff --git a/src/openvic-simulation/map/Crime.cpp b/src/openvic-simulation/map/Crime.cpp
index 3a9ae64..c0bc04e 100644
--- a/src/openvic-simulation/map/Crime.cpp
+++ b/src/openvic-simulation/map/Crime.cpp
@@ -6,8 +6,6 @@ using namespace OpenVic::NodeTools;
Crime::Crime(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon, bool new_default_active)
: TriggeredModifier { new_identifier, std::move(new_values), new_icon }, default_active { new_default_active } {}
-CrimeManager::CrimeManager() : crime_modifiers { "crime modifiers" } {}
-
bool CrimeManager::add_crime_modifier(
std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon, bool default_active
) {
diff --git a/src/openvic-simulation/map/Crime.hpp b/src/openvic-simulation/map/Crime.hpp
index d0dd844..26f52ab 100644
--- a/src/openvic-simulation/map/Crime.hpp
+++ b/src/openvic-simulation/map/Crime.hpp
@@ -17,15 +17,12 @@ namespace OpenVic {
struct CrimeManager {
private:
- IdentifierRegistry<Crime> crime_modifiers;
+ IdentifierRegistry<Crime> IDENTIFIER_REGISTRY(crime_modifier);
public:
- CrimeManager();
-
bool add_crime_modifier(
std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon, bool default_active
);
- IDENTIFIER_REGISTRY_ACCESSORS(crime_modifier)
bool load_crime_modifiers(ModifierManager const& modifier_manager, ast::NodeCPtr root);
};
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp
index 7bf5e7d..18f72cf 100644
--- a/src/openvic-simulation/map/Map.cpp
+++ b/src/openvic-simulation/map/Map.cpp
@@ -25,8 +25,6 @@ Mapmode::base_stripe_t Mapmode::get_base_stripe_colours(Map const& map, Province
return colour_func ? colour_func(map, province) : NULL_COLOUR;
}
-Map::Map() : provinces { "provinces" }, regions { "regions" }, mapmodes { "mapmodes" } {}
-
bool Map::add_province(std::string_view identifier, colour_t colour) {
if (provinces.size() >= max_provinces) {
Logger::error(
diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp
index bb760e6..16d12a8 100644
--- a/src/openvic-simulation/map/Map.hpp
+++ b/src/openvic-simulation/map/Map.hpp
@@ -53,9 +53,9 @@ namespace OpenVic {
private:
using colour_index_map_t = std::map<colour_t, Province::index_t>;
- IdentifierRegistry<Province> provinces;
- IdentifierRegistry<Region> regions;
- IdentifierRegistry<Mapmode> mapmodes;
+ IdentifierRegistry<Province> IDENTIFIER_REGISTRY_CUSTOM_INDEX_OFFSET(province, 1);
+ IdentifierRegistry<Region> IDENTIFIER_REGISTRY(region);
+ IdentifierRegistry<Mapmode> IDENTIFIER_REGISTRY(mapmode);
ProvinceSet water_provinces;
TerrainTypeManager PROPERTY_REF(terrain_type_manager);
@@ -73,10 +73,7 @@ namespace OpenVic {
StateManager PROPERTY_REF(state_manager);
public:
- Map();
-
bool add_province(std::string_view identifier, colour_t colour);
- IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_INDEX_OFFSET(province, 1)
IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS_CUSTOM_INDEX_OFFSET(province, 1);
bool set_water_province(std::string_view identifier);
@@ -95,11 +92,9 @@ namespace OpenVic {
std::vector<shape_pixel_t> const& get_province_shape_image() const;
bool add_region(std::string_view identifier, std::vector<std::string_view> const& province_identifiers);
- IDENTIFIER_REGISTRY_ACCESSORS(region)
IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS(region)
bool add_mapmode(std::string_view identifier, Mapmode::colour_func_t colour_func);
- IDENTIFIER_REGISTRY_ACCESSORS(mapmode)
/* The mapmode colour image contains of a list of base colours and stripe colours. Each colour is four bytes
* in RGBA format, with the alpha value being used to interpolate with the terrain colour, so A = 0 is fully terrain
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp
index e423938..0b98588 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -80,7 +80,7 @@ namespace OpenVic {
Crime const* PROPERTY_RW(crime);
// TODO - change this into a factory-like structure
Good const* PROPERTY(rgo);
- IdentifierRegistry<BuildingInstance> buildings;
+ IdentifierRegistry<BuildingInstance> IDENTIFIER_REGISTRY(building);
std::vector<Pop> PROPERTY(pops);
Pop::pop_size_t PROPERTY(total_population);
@@ -98,7 +98,6 @@ namespace OpenVic {
bool load_positions(BuildingTypeManager const& building_type_manager, ast::NodeCPtr root);
- IDENTIFIER_REGISTRY_ACCESSORS(building)
bool expand_building(std::string_view building_type_identifier);
bool load_pop_list(PopManager const& pop_manager, ast::NodeCPtr root);
diff --git a/src/openvic-simulation/map/TerrainType.cpp b/src/openvic-simulation/map/TerrainType.cpp
index 4134662..bab2a3c 100644
--- a/src/openvic-simulation/map/TerrainType.cpp
+++ b/src/openvic-simulation/map/TerrainType.cpp
@@ -16,9 +16,6 @@ TerrainTypeMapping::TerrainTypeMapping(
) : HasIdentifier { new_identifier }, type { new_type }, terrain_indices { std::move(new_terrain_indicies) },
priority { new_priority }, has_texture { new_has_texture } {}
-TerrainTypeManager::TerrainTypeManager()
- : terrain_types { "terrain types" }, terrain_type_mappings { "terrain type mappings" } {}
-
bool TerrainTypeManager::add_terrain_type(
std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water
) {
diff --git a/src/openvic-simulation/map/TerrainType.hpp b/src/openvic-simulation/map/TerrainType.hpp
index 0fd5157..1a5b09c 100644
--- a/src/openvic-simulation/map/TerrainType.hpp
+++ b/src/openvic-simulation/map/TerrainType.hpp
@@ -41,8 +41,8 @@ namespace OpenVic {
struct TerrainTypeManager {
private:
using terrain_type_mappings_map_t = std::map<TerrainTypeMapping::index_t, size_t>;
- IdentifierRegistry<TerrainType> terrain_types;
- IdentifierRegistry<TerrainTypeMapping> terrain_type_mappings;
+ IdentifierRegistry<TerrainType> IDENTIFIER_REGISTRY(terrain_type);
+ IdentifierRegistry<TerrainTypeMapping> IDENTIFIER_REGISTRY(terrain_type_mapping);
terrain_type_mappings_map_t terrain_type_mappings_map;
TerrainTypeMapping::index_t terrain_texture_limit = 0, terrain_texture_count = 0;
@@ -51,16 +51,12 @@ namespace OpenVic {
bool _load_terrain_type_mapping(std::string_view key, ast::NodeCPtr value);
public:
- TerrainTypeManager();
-
bool add_terrain_type(std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water);
- IDENTIFIER_REGISTRY_ACCESSORS(terrain_type)
bool add_terrain_type_mapping(
std::string_view identifier, TerrainType const* type, std::vector<TerrainTypeMapping::index_t>&& terrain_indicies,
TerrainTypeMapping::index_t priority, bool has_texture
);
- IDENTIFIER_REGISTRY_ACCESSORS(terrain_type_mapping)
TerrainTypeMapping const* get_terrain_type_mapping_for(TerrainTypeMapping::index_t idx) const;