From ab2032d1d8c88230a5d82d9b1b8b8d165fcd6f19 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 2 May 2017 07:48:10 +1000 Subject: [PATCH] Fix trees causing IndexOutOfRange errors on maps with very low heights such as 16 --- ClassicalSharp/Generator/NotchyGenerator.cs | 1 + src/Client/NotchyGenerator.c | 1 + 2 files changed, 2 insertions(+) diff --git a/ClassicalSharp/Generator/NotchyGenerator.cs b/ClassicalSharp/Generator/NotchyGenerator.cs index 92972dbed..1f59685f9 100644 --- a/ClassicalSharp/Generator/NotchyGenerator.cs +++ b/ClassicalSharp/Generator/NotchyGenerator.cs @@ -347,6 +347,7 @@ namespace ClassicalSharp.Generator { continue; int treeY = heightmap[treeZ * Width + treeX] + 1; + if (treeY >= Height) continue; int treeHeight = 5 + rnd.Next(3); int index = (treeY * Length + treeZ) * Width + treeX; diff --git a/src/Client/NotchyGenerator.c b/src/Client/NotchyGenerator.c index d6dea53a2..47c37f054 100644 --- a/src/Client/NotchyGenerator.c +++ b/src/Client/NotchyGenerator.c @@ -218,6 +218,7 @@ void NotchyGen_PlantTrees() { continue; Int32 treeY = Heightmap[treeZ * Width + treeX] + 1; + if (treeY >= Height) continue; Int32 treeHeight = 5 + Random_Next(&rnd, 3); Int32 index = (treeY * Length + treeZ) * Width + treeX;