fix crash with get_textures_weight_for_unit()

This commit is contained in:
T1ti
2024-07-14 03:13:08 +02:00
parent 478d842e10
commit de7df101d3
2 changed files with 11 additions and 3 deletions

View File

@@ -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 << "</font>";
select_info << "<br><b>Ground Effect</b>: " << chunk->getTextureSet()->getEffectForLayer(counter);
unsigned int effect_id = chunk->getTextureSet()->getEffectForLayer(counter);
if (effect_id == 0xFFFFFFFF)
effect_id = 0;
select_info << "<br><b>Ground Effect</b>: " << effect_id;
counter++;
}

View File

@@ -1357,6 +1357,11 @@ std::array<float, 4> 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<float, 4> { 0.f, 0.f, 0.f, 0.f };
else if (nTextures == 1)
return std::array<float, 4> { 100.f, 0.f, 0.f, 0.f };
// 8x8 bits per unit
for (int x = 0; x < 8; x++)
{