diff options
author | hop311 <hop3114@gmail.com> | 2024-07-19 20:02:25 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-07-19 20:02:25 +0200 |
commit | 03647d2249f72b6545628bb844685f87c4581062 (patch) | |
tree | 435dde45bb17dc12e74cc79bd5f25cc7a7ef8dca /src/openvic-simulation/map | |
parent | a673f89bb2705826b1c646365eab1775727372b7 (diff) |
Cleanup: inheritance, const movable variables, code formattingformat-cleanup
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r-- | src/openvic-simulation/map/Region.cpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/map/TerrainType.cpp | 3 | ||||
-rw-r--r-- | src/openvic-simulation/map/TerrainType.hpp | 9 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/openvic-simulation/map/Region.cpp b/src/openvic-simulation/map/Region.cpp index 89dab20..d8c5fc1 100644 --- a/src/openvic-simulation/map/Region.cpp +++ b/src/openvic-simulation/map/Region.cpp @@ -85,7 +85,7 @@ bool ProvinceSet::contains_province(ProvinceDefinition const* province) const { } ProvinceSetModifier::ProvinceSetModifier(std::string_view new_identifier, ModifierValue&& new_values) - : Modifier { new_identifier, std::move(new_values), 0 } {} + : Modifier { new_identifier, std::move(new_values) } {} Region::Region(std::string_view new_identifier, colour_t new_colour, bool new_meta) : HasIdentifierAndColour { new_identifier, new_colour, false }, meta { new_meta } {} diff --git a/src/openvic-simulation/map/TerrainType.cpp b/src/openvic-simulation/map/TerrainType.cpp index 93a5e83..704e79e 100644 --- a/src/openvic-simulation/map/TerrainType.cpp +++ b/src/openvic-simulation/map/TerrainType.cpp @@ -7,8 +7,7 @@ using namespace OpenVic::NodeTools; TerrainType::TerrainType( std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_modifier, bool new_is_water -) : HasIdentifierAndColour { new_identifier, new_colour, false }, modifier { std::move(new_modifier) }, - is_water { new_is_water } {} +) : Modifier { new_identifier, std::move(new_modifier) }, HasColour { new_colour, false }, is_water { new_is_water } {} TerrainTypeMapping::TerrainTypeMapping( std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, diff --git a/src/openvic-simulation/map/TerrainType.hpp b/src/openvic-simulation/map/TerrainType.hpp index b534ab5..ec36363 100644 --- a/src/openvic-simulation/map/TerrainType.hpp +++ b/src/openvic-simulation/map/TerrainType.hpp @@ -6,11 +6,13 @@ namespace OpenVic { struct TerrainTypeManager; - struct TerrainType : HasIdentifierAndColour { + // Using HasColour rather than HasIdentifierAndColour to avoid needing virtual inheritance + // (extending Modifier is more useful than extending HasIdentifierAndColour). + struct TerrainType : Modifier, HasColour { friend struct TerrainTypeManager; private: - const ModifierValue PROPERTY(modifier); + ModifierValue PROPERTY(modifier); const bool PROPERTY(is_water); TerrainType(std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_modifier, bool new_is_water); @@ -26,7 +28,7 @@ namespace OpenVic { private: TerrainType const& PROPERTY(type); - const std::vector<index_t> PROPERTY(terrain_indices); + std::vector<index_t> PROPERTY(terrain_indices); const index_t PROPERTY(priority); const bool PROPERTY(has_texture); @@ -42,6 +44,7 @@ namespace OpenVic { struct TerrainTypeManager { private: using terrain_type_mappings_map_t = ordered_map<TerrainTypeMapping::index_t, size_t>; + IdentifierRegistry<TerrainType> IDENTIFIER_REGISTRY(terrain_type); IdentifierRegistry<TerrainTypeMapping> IDENTIFIER_REGISTRY(terrain_type_mapping); terrain_type_mappings_map_t terrain_type_mappings_map; |