From 618b3d7f61a9e5589dd51ce2dc9784bb1f39de2f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 29 Nov 2025 16:15:19 +0300 Subject: [PATCH] fix world generator --- src/world/generator/WorldGenerator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/world/generator/WorldGenerator.cpp b/src/world/generator/WorldGenerator.cpp index 227b7d1d..1f9a2241 100644 --- a/src/world/generator/WorldGenerator.cpp +++ b/src/world/generator/WorldGenerator.cpp @@ -91,7 +91,7 @@ static inline void generate_pole( voxel* voxels, int x, int z ) { - uint y = top; + uint y = std::min(top, CHUNK_H - 1); uint layerExtension = 0; for (const auto& layer : layers.layers) { // skip layer if can't be generated under sea level @@ -106,7 +106,9 @@ static inline void generate_pole( } else { layerHeight += layerExtension; } - layerHeight = std::min(static_cast(layerHeight), y+1); + layerHeight = std::min( + static_cast(layerHeight), std::min(CHUNK_H - 1, y + 1) + ); for (uint i = 0; i < layerHeight; i++, y--) { voxels[vox_index(x, y, z)].id = layer.rt.id;