From 2364fbc03f0a44bcef0881b38a5cf74fa819fb7f Mon Sep 17 00:00:00 2001 From: Hop311 Date: Fri, 7 Apr 2023 15:10:08 +0100 Subject: Movement tweaks --- extension/src/MapSingleton.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'extension') diff --git a/extension/src/MapSingleton.cpp b/extension/src/MapSingleton.cpp index 5c5087c..0f5fe7c 100644 --- a/extension/src/MapSingleton.cpp +++ b/extension/src/MapSingleton.cpp @@ -228,11 +228,12 @@ Error MapSingleton::load_province_shape_file(String const& file_path) { } String MapSingleton::get_province_identifier_from_pixel_coords(Vector2i const& coords) { - if (province_index_image.is_valid() && 0 <= coords.y && coords.y < height) { + if (province_index_image.is_valid()) { const PackedByteArray index_data_array = province_index_image->get_data(); const Province::index_t* index_data = reinterpret_cast(index_data_array.ptr()); const int32_t x_mod_w = UtilityFunctions::posmod(coords.x, width); - const Province* province = map.get_province_by_index(index_data[x_mod_w + coords.y * width]); + const int32_t y_mod_h = UtilityFunctions::posmod(coords.y, height); + const Province* province = map.get_province_by_index(index_data[x_mod_w + y_mod_h * width]); if (province) return province->get_identifier().c_str(); } return String{}; -- cgit v1.2.3-56-ga3b1