diff --git a/crates/engine/src/world.rs b/crates/engine/src/world.rs index 4d10724..042dbf2 100644 --- a/crates/engine/src/world.rs +++ b/crates/engine/src/world.rs @@ -251,7 +251,17 @@ impl LightmapAtlas { if extent[0] <= 0 || extent[1] <= 0 { continue; } - sizes.push((index, extent[0] as u32, extent[1] as u32)); + let width = extent[0] as u32; + let height = extent[1] as u32; + // Лимиты на случай повреждённого BSP: без них `width + 2` может + // переполниться, а упаковка — уйти в многочасовой цикл. Такая + // грань просто останется без атласа (белый свет), а не уронит клиент. + const MAX_BLOCK: u32 = 4096; + const MAX_BLOCK_AREA: u32 = 1024 * 1024; + if width > MAX_BLOCK || height > MAX_BLOCK || width * height > MAX_BLOCK_AREA { + continue; + } + sizes.push((index, width, height)); } if sizes.is_empty() { return None;