aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-07-19 21:35:31 +0200
committer GitHub <noreply@github.com>2024-07-19 21:35:31 +0200
commitd1f3a96b72dd06b5f97dd4643e5f016a02b42ea6 (patch)
tree38015e5729afbb98cf520e2cf26d8a4623d32f2f /src/openvic-simulation/map
parente0518bee9b4c164f40716a8033b5e207c2060c0b (diff)
parent03647d2249f72b6545628bb844685f87c4581062 (diff)
Merge pull request #176 from OpenVicProject/format-cleanup
Cleanup: inheritance, const movable variables, code formatting
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/Region.cpp2
-rw-r--r--src/openvic-simulation/map/TerrainType.cpp3
-rw-r--r--src/openvic-simulation/map/TerrainType.hpp9
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;