From 4a4a3bf29788ed38e0883d7fd80a021e0bccc56b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 18 Sep 2023 22:08:20 -0500 Subject: [PATCH] Fix LowDetailIncompleteFullDataSource divide by zero --- .../fullData/sources/LowDetailIncompleteFullDataSource.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java index fa7937a0a..64e450545 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java @@ -451,7 +451,11 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp int offsetZ = inputOffset.getZ() - baseOffset.z; - int numberOfDataPointsToUpdate = WIDTH / this.sectionPos.getWidthCountForLowerDetailedSection(inputSource.getSectionPos().getDetailLevel()); + int numberOfDataPointsToUpdate = WIDTH / this.sectionPos.getWidthCountForLowerDetailedSection(inputSource.getSectionPos().getDetailLevel()); // can be 0 if the input source is significantly smaller than this data source + // should be 1 at minimum, to prevent divide by zero errors (and because trying to get 0 data points doesn't make any sense) + numberOfDataPointsToUpdate = Math.max(1, numberOfDataPointsToUpdate); + + int inputFractionWidth = inputSource.width() / numberOfDataPointsToUpdate; for (int x = 0; x < numberOfDataPointsToUpdate; x++) {