aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extension/src/MapMesh.cpp2
-rw-r--r--extension/src/MapSingleton.cpp11
-rw-r--r--game/src/GameSession/TerrainMap.gdshader2
3 files changed, 8 insertions, 7 deletions
diff --git a/extension/src/MapMesh.cpp b/extension/src/MapMesh.cpp
index cdbeec9..f0fc819 100644
--- a/extension/src/MapMesh.cpp
+++ b/extension/src/MapMesh.cpp
@@ -74,7 +74,7 @@ AABB MapMesh::get_core_aabb() const {
}
bool MapMesh::is_valid_uv_coord(godot::Vector2 const& uv) const {
- return -repeat_proportion <= uv.x && uv.x <= 1.0f + repeat_proportion && 0.0f <= uv.y && uv.y <= 1.0f;
+ return 0.0f <= uv.y && uv.y <= 1.0f;
}
Array MapMesh::_create_mesh_array() const {
diff --git a/extension/src/MapSingleton.cpp b/extension/src/MapSingleton.cpp
index 71977da..5c5087c 100644
--- a/extension/src/MapSingleton.cpp
+++ b/extension/src/MapSingleton.cpp
@@ -195,7 +195,7 @@ Error MapSingleton::load_province_shape_file(String const& file_path) {
if (!province_checklist[idx]) {
Province* province = map.get_province_by_index(idx + 1);
if (province) UtilityFunctions::push_error("Province missing from shape image: ", province->to_string().c_str());
- else UtilityFunctions::push_error("Province missing for index: ", idx + 1);
+ else UtilityFunctions::push_error("Province missing for index: ", static_cast<int32_t>(idx + 1));
err = FAILED;
}
}
@@ -208,14 +208,14 @@ Error MapSingleton::load_province_shape_file(String const& file_path) {
PackedByteArray colour_data_array;
colour_data_array.resize((Province::MAX_INDEX + 1) * 3);
- for (int64_t idx = 1; idx <= map.get_province_count(); ++idx) {
+ for (size_t idx = 1; idx <= map.get_province_count(); ++idx) {
const Province* province = map.get_province_by_index(idx);
if (province) {
const Province::colour_t colour = province->get_colour();
colour_data_array[3 * idx + 0] = (colour >> 16) & 0xFF;
colour_data_array[3 * idx + 1] = (colour >> 8) & 0xFF;
colour_data_array[3 * idx + 2] = colour & 0xFF;
- } else UtilityFunctions::push_error("Missing province at index ", idx);
+ } else UtilityFunctions::push_error("Missing province at index ", static_cast<int32_t>(idx));
}
static const int32_t PROVINCE_INDEX_SQRT = 1 << (sizeof(Province::index_t) * 4);
province_colour_image = Image::create_from_data(PROVINCE_INDEX_SQRT, PROVINCE_INDEX_SQRT, false, Image::FORMAT_RGB8, colour_data_array);
@@ -228,10 +228,11 @@ 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.x && coords.x < width && 0 <= coords.y && coords.y < height) {
+ if (province_index_image.is_valid() && 0 <= coords.y && coords.y < height) {
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 Province* province = map.get_province_by_colour(index_data[coords.x + coords.y * width]);
+ 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]);
if (province) return province->get_identifier().c_str();
}
return String{};
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
index be2bbe1..a6774fd 100644
--- a/game/src/GameSession/TerrainMap.gdshader
+++ b/game/src/GameSession/TerrainMap.gdshader
@@ -14,7 +14,7 @@ uniform vec2 hover_pos;
uniform vec2 selected_pos;
uvec2 vec2_to_uvec2(vec2 v) {
- return uvec2(v * 256.0);
+ return uvec2(v * 255.0);
}
uint uvec2_to_uint(uvec2 v) {