diff --git a/src/noggit/application/NoggitApplication.cpp b/src/noggit/application/NoggitApplication.cpp index 56cebb13..043ac159 100755 --- a/src/noggit/application/NoggitApplication.cpp +++ b/src/noggit/application/NoggitApplication.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace Noggit::Application { diff --git a/src/noggit/project/ApplicationProjectWriter.cpp b/src/noggit/project/ApplicationProjectWriter.cpp index 701209a4..2a445140 100755 --- a/src/noggit/project/ApplicationProjectWriter.cpp +++ b/src/noggit/project/ApplicationProjectWriter.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace Noggit::Project { diff --git a/src/noggit/rendering/LiquidRender.cpp b/src/noggit/rendering/LiquidRender.cpp index c66dbc2b..87148bb2 100755 --- a/src/noggit/rendering/LiquidRender.cpp +++ b/src/noggit/rendering/LiquidRender.cpp @@ -51,6 +51,10 @@ void LiquidRender::draw(math::frustum const& frustum } else { + // In some cases samplers_upload_buf becomes empty and causes crash + if (samplers_upload_buf.size() < N_SAMPLERS) + samplers_upload_buf.resize(N_SAMPLERS); + std::fill(samplers_upload_buf.begin(), samplers_upload_buf.end(), -1); for (std::size_t j = 0; j < render_layer.texture_samplers.size(); ++j) diff --git a/src/noggit/rendering/WMOGroupRender.cpp b/src/noggit/rendering/WMOGroupRender.cpp index 31c5e663..c995920b 100755 --- a/src/noggit/rendering/WMOGroupRender.cpp +++ b/src/noggit/rendering/WMOGroupRender.cpp @@ -338,9 +338,13 @@ void WMOGroupRender::initRenderBatches() std::size_t batch_counter = 0; for (auto& batch : _wmo_group->_batches) { - for (std::size_t i = 0; i < (batch.vertex_end - batch.vertex_start + 1); ++i) + // some custom models have bugged batch.vertex_end as 0, avoid crash + if (batch.vertex_end >= batch.vertex_start) { - _render_batch_mapping[batch.vertex_start + i] = static_cast(batch_counter + 1); + for (std::size_t i = 0; i < (batch.vertex_end - batch.vertex_start + 1); ++i) + { + _render_batch_mapping[batch.vertex_start + i] = static_cast(batch_counter + 1); + } } std::uint32_t flags = 0;