From 2fec521cc6bbe7b2cda0eef3b830acbfc8b68333 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Sun, 30 Apr 2023 23:59:54 +0100 Subject: Hashmaps instead of linear + better province hover --- extension/src/openvic2/map/Map.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'extension/src/openvic2/map/Map.hpp') diff --git a/extension/src/openvic2/map/Map.hpp b/extension/src/openvic2/map/Map.hpp index a075505..cb8dcb1 100644 --- a/extension/src/openvic2/map/Map.hpp +++ b/extension/src/openvic2/map/Map.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include "Region.hpp" @@ -27,7 +26,8 @@ namespace OpenVic2 { */ struct Map { using terrain_t = uint8_t; - using terrain_variant_map_t = std::unordered_map; + using terrain_variant_map_t = std::map; + #pragma pack(push, 1) struct shape_pixel_t { index_t index; @@ -35,6 +35,8 @@ namespace OpenVic2 { }; #pragma pack(pop) private: + using colour_index_map_t = std::map; + IdentifierRegistry provinces; IdentifierRegistry regions; IdentifierRegistry mapmodes; @@ -43,6 +45,9 @@ namespace OpenVic2 { size_t width = 0, height = 0; std::vector province_shape_image; + colour_index_map_t colour_index_map; + + index_t get_index_from_colour(colour_t colour) const; public: Map(); @@ -58,8 +63,6 @@ namespace OpenVic2 { Province const* get_province_by_index(index_t index) const; Province* get_province_by_identifier(std::string const& identifier); Province const* get_province_by_identifier(std::string const& identifier) const; - Province* get_province_by_colour(colour_t colour); - Province const* get_province_by_colour(colour_t colour) const; index_t get_province_index_at(size_t x, size_t y) const; Region* get_region_by_identifier(std::string const& identifier); -- cgit v1.2.3-56-ga3b1