aboutsummaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-04-07 16:10:08 +0200
committer Hop311 <hop3114@gmail.com>2023-04-07 16:10:08 +0200
commit2364fbc03f0a44bcef0881b38a5cf74fa819fb7f (patch)
tree7590bbbb867479e178255a6d22c1cab7674ed0df /extension
parent0b13a13037860cfec6644f34c2f22cd62e933d1e (diff)
Movement tweaks
Diffstat (limited to 'extension')
-rw-r--r--extension/src/MapSingleton.cpp5
1 files changed, 3 insertions, 2 deletions
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<const Province::index_t*>(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{};