diff options
author | hop311 <hop3114@gmail.com> | 2024-04-15 00:51:10 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-04-15 00:51:10 +0200 |
commit | f728fdd7319b88c299826d6a98aa11d3ec1ba6e4 (patch) | |
tree | c3ea25983923b191fe2dacf4c578086fde786726 /src/openvic-simulation/map/Map.hpp | |
parent | 5799836bee29024ce8a2d0fc45e06664c0110751 (diff) |
Rework province position loading and map dims
Diffstat (limited to 'src/openvic-simulation/map/Map.hpp')
-rw-r--r-- | src/openvic-simulation/map/Map.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp index 807945a..2a3f224 100644 --- a/src/openvic-simulation/map/Map.hpp +++ b/src/openvic-simulation/map/Map.hpp @@ -69,8 +69,7 @@ namespace OpenVic { ProvinceSet water_provinces; TerrainTypeManager PROPERTY_REF(terrain_type_manager); - int32_t PROPERTY(width); - int32_t PROPERTY(height); + ivec2_t PROPERTY(dims); std::vector<shape_pixel_t> PROPERTY(province_shape_image); colour_index_map_t colour_index_map; @@ -84,9 +83,16 @@ namespace OpenVic { StateManager PROPERTY_REF(state_manager); + inline constexpr int32_t get_pixel_index_from_pos(ivec2_t pos) const { + return pos.x + pos.y * dims.x; + } + public: Map(); + inline constexpr int32_t get_width() const { return dims.x; } + inline constexpr int32_t get_height() const { return dims.y; } + bool add_province(std::string_view identifier, colour_t colour); IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS_CUSTOM_INDEX_OFFSET(province, 1); @@ -110,7 +116,9 @@ namespace OpenVic { bool set_water_province_list(std::vector<std::string_view> const& list); void lock_water_provinces(); - Province::index_t get_province_index_at(size_t x, size_t y) const; + Province::index_t get_province_index_at(ivec2_t pos) const; + Province* get_province_at(ivec2_t pos); + Province const* get_province_at(ivec2_t pos) const; bool set_max_provinces(Province::index_t new_max_provinces); void set_selected_province(Province::index_t index); Province* get_selected_province(); |