From 7b252b173bb51f53bbdee87bfa6a5d327d1ce88a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 27 Apr 2026 07:27:03 -0500 Subject: [PATCH] Fix wyncraft getting stuck at low LOD quality --- .../core/util/RenderDataPointReducingList.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointReducingList.java b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointReducingList.java index 3bd332676..baac95b93 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointReducingList.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointReducingList.java @@ -451,6 +451,21 @@ public class RenderDataPointReducingList extends AbstractPhantomArrayList this.setBigger(smaller, bigger); } + if (writeIndex == 0) + { + // if every data point in the list is NULL (0) the write index will be 0, + // and in order to prevent accessing index -1 below, + // setting the write index to 1 is needed. + + // This shouldn't happen normally, however if the lod data is slightly malformed + // (which is specifically the case for the commonly shared wyncraft LODs) + // this check is needed. + // It would probably be best to fix the 6 or so NULL datapoints that are next + // to each other in the full data source, but for now this fix works. + + writeIndex = 1; + } + this.smallest = this.sortingArray.getShort(0); this.biggest = this.sortingArray.getShort(writeIndex - 1); this.setSmaller(this.getSmallest(), NULL);