diff options
author | Hop311 <Hop3114@gmail.com> | 2023-11-22 23:11:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 23:11:42 +0100 |
commit | a54898b7770e0d66b729216173960686c67e58bb (patch) | |
tree | af8ed836a4789ef94c5bfed27abb713922f45af3 /src/openvic-simulation/map | |
parent | e76336cd92639f4ec71088fc4c80aea4c25528cd (diff) | |
parent | 738a203e0d8b4df87c42888043b99c13d5d97511 (diff) |
Merge pull request #78 from OpenVicProject/property-macro
Refactoring (*mostly* related to the property macro)
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r-- | src/openvic-simulation/map/Map.cpp | 4 | ||||
-rw-r--r-- | src/openvic-simulation/map/Map.hpp | 3 | ||||
-rw-r--r-- | src/openvic-simulation/map/TerrainType.cpp | 25 | ||||
-rw-r--r-- | src/openvic-simulation/map/TerrainType.hpp | 20 |
4 files changed, 8 insertions, 44 deletions
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp index 6df7537..549e539 100644 --- a/src/openvic-simulation/map/Map.cpp +++ b/src/openvic-simulation/map/Map.cpp @@ -21,10 +21,6 @@ const Mapmode Mapmode::ERROR_MAPMODE { "mapmode_error", 0, [](Map const& map, Province const& province) -> colour_t { return 0xFFFF0000; } }; -Mapmode::index_t Mapmode::get_index() const { - return index; -} - Mapmode::base_stripe_t Mapmode::get_base_stripe_colours(Map const& map, Province const& province) const { return colour_func ? colour_func(map, province) : NULL_COLOUR; } diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp index 189713c..4f87237 100644 --- a/src/openvic-simulation/map/Map.hpp +++ b/src/openvic-simulation/map/Map.hpp @@ -21,7 +21,7 @@ namespace OpenVic { using index_t = size_t; private: - const index_t index; + const index_t PROPERTY(index); const colour_func_t colour_func; Mapmode(std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func); @@ -31,7 +31,6 @@ namespace OpenVic { Mapmode(Mapmode&&) = default; - index_t get_index() const; base_stripe_t get_base_stripe_colours(Map const& map, Province const& province) const; }; diff --git a/src/openvic-simulation/map/TerrainType.cpp b/src/openvic-simulation/map/TerrainType.cpp index f138cb2..3048b66 100644 --- a/src/openvic-simulation/map/TerrainType.cpp +++ b/src/openvic-simulation/map/TerrainType.cpp @@ -10,36 +10,13 @@ TerrainType::TerrainType( ) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, modifier { std::move(new_modifier) }, is_water { new_is_water } {} -ModifierValue const& TerrainType::get_modifier() const { - return modifier; -} - -bool TerrainType::get_is_water() const { - return is_water; -} TerrainTypeMapping::TerrainTypeMapping( std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture -) : HasIdentifier { new_identifier }, type { new_type }, terrain_indicies { std::move(new_terrain_indicies) }, +) : HasIdentifier { new_identifier }, type { new_type }, terrain_indices { std::move(new_terrain_indicies) }, priority { new_priority }, has_texture { new_has_texture } {} -TerrainType const& TerrainTypeMapping::get_type() const { - return type; -} - -std::vector<TerrainTypeMapping::index_t> const& TerrainTypeMapping::get_terrain_indicies() const { - return terrain_indicies; -} - -TerrainTypeMapping::index_t TerrainTypeMapping::get_priority() const { - return priority; -} - -bool TerrainTypeMapping::get_has_texture() const { - return has_texture; -} - TerrainTypeManager::TerrainTypeManager() : terrain_types { "terrain types" }, terrain_type_mappings { "terrain type mappings" } {} diff --git a/src/openvic-simulation/map/TerrainType.hpp b/src/openvic-simulation/map/TerrainType.hpp index 92f78dd..0fd5157 100644 --- a/src/openvic-simulation/map/TerrainType.hpp +++ b/src/openvic-simulation/map/TerrainType.hpp @@ -9,16 +9,13 @@ namespace OpenVic { friend struct TerrainTypeManager; private: - const ModifierValue modifier; - const bool is_water; + const 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); public: TerrainType(TerrainType&&) = default; - - ModifierValue const& get_modifier() const; - bool get_is_water() const; }; struct TerrainTypeMapping : HasIdentifier { @@ -27,10 +24,10 @@ namespace OpenVic { using index_t = uint8_t; private: - TerrainType const& type; - const std::vector<index_t> terrain_indicies; - const index_t priority; - const bool has_texture; + TerrainType const& PROPERTY(type); + const std::vector<index_t> PROPERTY(terrain_indices); + const index_t PROPERTY(priority); + const bool PROPERTY(has_texture); TerrainTypeMapping( std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, @@ -39,11 +36,6 @@ namespace OpenVic { public: TerrainTypeMapping(TerrainTypeMapping&&) = default; - - TerrainType const& get_type() const; - std::vector<index_t> const& get_terrain_indicies() const; - index_t get_priority() const; - bool get_has_texture() const; }; struct TerrainTypeManager { |