From fa984541515f7f7c063a57cc8a69d4ba1d5646d8 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 25 Jul 2021 20:51:52 -0500 Subject: [PATCH] Hopefully reduce the chance of index out of bounds exceptions --- .../java/com/seibel/lod/objects/LodDimension.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/seibel/lod/objects/LodDimension.java b/src/main/java/com/seibel/lod/objects/LodDimension.java index 7d74d3b46..ac1e095ac 100644 --- a/src/main/java/com/seibel/lod/objects/LodDimension.java +++ b/src/main/java/com/seibel/lod/objects/LodDimension.java @@ -388,13 +388,22 @@ public class LodDimension public int getWidth() { - return width; + if (regions != null) + { + // we want to get the length directly from the + // source to make sure it is in sync with region + // and isRegionDirty + return regions.length; + } + else + { + return width; + } } public void setRegionWidth(int newWidth) { width = newWidth; - halfWidth = (int)Math.floor(width / 2); regions = new LodRegion[width][width]; isRegionDirty = new boolean[width][width];