From de7df101d377e2c11739e2f8b1e5ff3e3f6f4575 Mon Sep 17 00:00:00 2001 From: T1ti <40864460+T1ti@users.noreply.github.com> Date: Sun, 14 Jul 2024 03:13:08 +0200 Subject: [PATCH] fix crash with get_textures_weight_for_unit() --- src/noggit/Selection.cpp | 9 ++++++--- src/noggit/texture_set.cpp | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/noggit/Selection.cpp b/src/noggit/Selection.cpp index b28a1be4..41218695 100755 --- a/src/noggit/Selection.cpp +++ b/src/noggit/Selection.cpp @@ -41,7 +41,7 @@ void selected_chunk_type::updateDetails(Noggit::Ui::detail_infos* detail_widget) // test compare active layer algorithm with blizzard. can reuse the same for saving - + // TODO remove this int matching_count = 0; int not_matching_count = 0; @@ -49,7 +49,7 @@ void selected_chunk_type::updateDetails(Noggit::Ui::detail_infos* detail_widget) auto tile = chunk->mt; - bool debug_test = true; + bool debug_test = false; if (debug_test) for (int chunk_x = 0; chunk_x < 16; chunk_x++) @@ -185,7 +185,10 @@ void selected_chunk_type::updateDetails(Noggit::Ui::detail_infos* detail_widget) if (stuck || error) select_info << ""; - select_info << "
Ground Effect: " << chunk->getTextureSet()->getEffectForLayer(counter); + unsigned int effect_id = chunk->getTextureSet()->getEffectForLayer(counter); + if (effect_id == 0xFFFFFFFF) + effect_id = 0; + select_info << "
Ground Effect: " << effect_id; counter++; } diff --git a/src/noggit/texture_set.cpp b/src/noggit/texture_set.cpp index 5fd72c7b..c8571244 100755 --- a/src/noggit/texture_set.cpp +++ b/src/noggit/texture_set.cpp @@ -1357,6 +1357,11 @@ std::array TextureSet::get_textures_weight_for_unit(unsigned int unit_ float total_layer_2 = 0.f; float total_layer_3 = 0.f; + if (nTextures == 0) + return std::array { 0.f, 0.f, 0.f, 0.f }; + else if (nTextures == 1) + return std::array { 100.f, 0.f, 0.f, 0.f }; + // 8x8 bits per unit for (int x = 0; x < 8; x++) {