diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java b/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java
index 5eab9d782..9063ec741 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java
@@ -377,7 +377,11 @@ public class LodRenderSection implements IDebugRenderable
return false;
}
- LodUtil.assertTrue(newBuffer.buffersUploaded, "The buffer future for " + this.pos + " returned an un-built buffer.");
+ if (!newBuffer.buffersUploaded)
+ {
+ LodUtil.assertNotReach("The buffer future for " + this.pos + " returned an un-built buffer.");
+ }
+
ColumnRenderBuffer oldBuffer = this.activeRenderBufferRef.getAndSet(newBuffer);
if (oldBuffer != null)
{
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java
index e4d8b8d52..da1d5f942 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java
@@ -94,8 +94,10 @@ public class GLBuffer implements AutoCloseable
protected void create(boolean asBufferStorage)
{
- LodUtil.assertTrue(GLProxy.getInstance().getGlContext() != EGLProxyContext.NONE,
- "Thread ["+Thread.currentThread()+"] tried to create a GLBuffer outside a OpenGL context.");
+ if (GLProxy.getInstance().getGlContext() == EGLProxyContext.NONE)
+ {
+ LodUtil.assertNotReach("Thread ["+Thread.currentThread()+"] tried to create a GLBuffer outside a OpenGL context.");
+ }
this.id = GL32.glGenBuffers();
this.bufferStorage = asBufferStorage;
@@ -165,7 +167,10 @@ public class GLBuffer implements AutoCloseable
{
LodUtil.assertTrue(!uploadMethod.useEarlyMapping, "UploadMethod signal that this should use Mapping instead of uploadBuffer!");
int bbSize = bb.limit() - bb.position();
- LodUtil.assertTrue(bbSize <= maxExpansionSize, "maxExpansionSize is ["+maxExpansionSize+"] but buffer size is ["+bbSize+"]!");
+ if (bbSize > maxExpansionSize)
+ {
+ LodUtil.assertNotReach("maxExpansionSize is [" + maxExpansionSize + "] but buffer size is [" + bbSize + "]!");
+ }
GLProxy.GL_LOGGER.debug("Uploading buffer with ["+new UnitBytes(bbSize)+"].");
// Don't upload an empty buffer
@@ -219,6 +224,7 @@ public class GLBuffer implements AutoCloseable
protected void uploadSubData(ByteBuffer bb, int maxExpansionSize, int bufferDataHint)
{
LodUtil.assertTrue(!this.bufferStorage, "Buffer is bufferStorage but its trying to use subData upload method!");
+
int bbSize = bb.limit() - bb.position();
if (this.size < bbSize || this.size > bbSize * BUFFER_SHRINK_TRIGGER)
{
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java
index 010b03335..065d1b890 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java
@@ -1,6 +1,7 @@
package com.seibel.distanthorizons.core.util;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1;
+import com.seibel.distanthorizons.coreapi.ModInfo;
/**
* Only for Legacy support
@@ -35,6 +36,8 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSour
*/
public class FullDataPointUtilV1
{
+ public static final boolean RUN_VALIDATION = ModInfo.IS_DEV_BUILD;
+
/** Represents the data held by an empty data point */
public static final int EMPTY_DATA_POINT = 0;
@@ -69,9 +72,23 @@ public class FullDataPointUtilV1
@Deprecated
public static long encode(int id, int height, int relMinY, byte blockLight, byte skyLight)
{
- LodUtil.assertTrue(relMinY >= 0 && relMinY < RenderDataPointUtil.MAX_WORLD_Y_SIZE, "Trying to create datapoint with y["+relMinY+"] out of range!");
- LodUtil.assertTrue(height > 0 && height < RenderDataPointUtil.MAX_WORLD_Y_SIZE, "Trying to create datapoint with height["+height+"] out of range!");
- LodUtil.assertTrue(relMinY + height <= RenderDataPointUtil.MAX_WORLD_Y_SIZE, "Trying to create datapoint with y+depth["+(relMinY+height)+"] out of range!");
+ if (RUN_VALIDATION)
+ {
+ // assertions are inside if-blocks to prevent unnecessary string concatenations
+ if (relMinY < 0 || relMinY >= RenderDataPointUtil.MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with y[" + relMinY + "] out of range!");
+ }
+ if (height <= 0 || height >= RenderDataPointUtil.MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with height[" + height + "] out of range!");
+ }
+ if (relMinY + height > RenderDataPointUtil.MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with y+depth[" + (relMinY + height) + "] out of range!");
+ }
+ }
+
long data = 0;
data |= id & ID_MASK;
@@ -80,11 +97,19 @@ public class FullDataPointUtilV1
data |= (long) blockLight << BLOCK_LIGHT_OFFSET;
data |= (long) skyLight << SKY_LIGHT_OFFSET;
- LodUtil.assertTrue(getId(data) == id && getHeight(data) == height && getBottomY(data) == relMinY && getBlockLight(data) == Byte.toUnsignedInt(blockLight) && getSkyLight(data) == Byte.toUnsignedInt(skyLight),
- "Trying to create datapoint with " +
- "id[" + id + "], height[" + height + "], minY[" + relMinY + "], blockLight[" + blockLight + "], skyLight[" + skyLight + "] " +
- "but got " +
- "id[" + getId(data) + "], height[" + getHeight(data) + "], minY[" + getBottomY(data) + "], blockLight[" + getBlockLight(data) + "], skyLight[" + getSkyLight(data) + "]!");
+
+ if (RUN_VALIDATION)
+ {
+ if (getId(data) != id || getHeight(data) != height || getBottomY(data) != relMinY
+ || getBlockLight(data) != Byte.toUnsignedInt(blockLight) || getSkyLight(data) != Byte.toUnsignedInt(skyLight))
+ {
+ LodUtil.assertNotReach(
+ "Trying to create datapoint with " +
+ "id[" + id + "], height[" + height + "], minY[" + relMinY + "], blockLight[" + blockLight + "], skyLight[" + skyLight + "] " +
+ "but got " +
+ "id[" + getId(data) + "], height[" + getHeight(data) + "], minY[" + getBottomY(data) + "], blockLight[" + getBlockLight(data) + "], skyLight[" + getSkyLight(data) + "]!");
+ }
+ }
return data;
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV2.java b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV2.java
index 0d9540567..491d0c256 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV2.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV2.java
@@ -19,6 +19,7 @@
package com.seibel.distanthorizons.core.util;
+import com.seibel.distanthorizons.coreapi.ModInfo;
import org.jetbrains.annotations.Contract;
/**
@@ -51,6 +52,8 @@ import org.jetbrains.annotations.Contract;
*/
public class FullDataPointUtilV2
{
+ public static final boolean RUN_VALIDATION = ModInfo.IS_DEV_BUILD;
+
/** Represents the data held by an empty data point */
public static final int EMPTY_DATA_POINT = 0;
@@ -82,9 +85,23 @@ public class FullDataPointUtilV2
*/
public static long encode(int id, int height, int relMinY, byte blockLight, byte skyLight)
{
- LodUtil.assertTrue(relMinY >= 0 && relMinY < RenderDataPointUtil.MAX_WORLD_Y_SIZE, "Trying to create datapoint with y["+relMinY+"] out of range!");
- LodUtil.assertTrue(height > 0 && height < RenderDataPointUtil.MAX_WORLD_Y_SIZE, "Trying to create datapoint with height["+height+"] out of range!");
- LodUtil.assertTrue(relMinY + height <= RenderDataPointUtil.MAX_WORLD_Y_SIZE, "Trying to create datapoint with y+depth["+(relMinY+height)+"] out of range!");
+ if (RUN_VALIDATION)
+ {
+ // assertions are inside if-blocks to prevent unnecessary string concatenations
+ if (relMinY < 0 || relMinY >= RenderDataPointUtil.MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with y[" + relMinY + "] out of range!");
+ }
+ if (height <= 0 || height >= RenderDataPointUtil.MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with height[" + height + "] out of range!");
+ }
+ if (relMinY + height > RenderDataPointUtil.MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with y+depth[" + (relMinY + height) + "] out of range!");
+ }
+ }
+
long data = 0;
data |= id & ID_MASK;
@@ -93,11 +110,19 @@ public class FullDataPointUtilV2
data |= (long) blockLight << BLOCK_LIGHT_OFFSET;
data |= (long) skyLight << SKY_LIGHT_OFFSET;
- LodUtil.assertTrue(getId(data) == id && getHeight(data) == height && getBottomY(data) == relMinY && getBlockLight(data) == Byte.toUnsignedInt(blockLight) && getSkyLight(data) == Byte.toUnsignedInt(skyLight),
- "Trying to create datapoint with " +
- "id[" + id + "], height[" + height + "], minY[" + relMinY + "], blockLight[" + blockLight + "], skyLight[" + skyLight + "] " +
- "but got " +
- "id[" + getId(data) + "], height[" + getHeight(data) + "], minY[" + getBottomY(data) + "], blockLight[" + getBlockLight(data) + "], skyLight[" + getSkyLight(data) + "]!");
+
+ if (RUN_VALIDATION)
+ {
+ if (getId(data) != id || getHeight(data) != height || getBottomY(data) != relMinY
+ || getBlockLight(data) != Byte.toUnsignedInt(blockLight) || getSkyLight(data) != Byte.toUnsignedInt(skyLight))
+ {
+ LodUtil.assertNotReach(
+ "Trying to create datapoint with " +
+ "id[" + id + "], height[" + height + "], minY[" + relMinY + "], blockLight[" + blockLight + "], skyLight[" + skyLight + "] " +
+ "but got " +
+ "id[" + getId(data) + "], height[" + getHeight(data) + "], minY[" + getBottomY(data) + "], blockLight[" + getBlockLight(data) + "], skyLight[" + getSkyLight(data) + "]!");
+ }
+ }
return data;
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java
index 316255595..85fd5ae1a 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java
@@ -23,6 +23,7 @@ import com.seibel.distanthorizons.core.level.AbstractDhLevel;
import com.seibel.distanthorizons.core.logging.SpamReducedLogger;
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnArrayView;
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.IColumnDataView;
+import com.seibel.distanthorizons.coreapi.ModInfo;
/**
@@ -63,7 +64,7 @@ public class RenderDataPointUtil
// When converting to or from an int a 128 should be added or removed.
// If there is a bug with color then it's probably caused by this.
- private static final SpamReducedLogger warnLogger = new SpamReducedLogger(1);
+ public static final boolean RUN_VALIDATION = ModInfo.IS_DEV_BUILD;
public final static int EMPTY_DATA = 0;
@@ -123,20 +124,56 @@ public class RenderDataPointUtil
public static long createDataPoint(int alpha, int red, int green, int blue, int height, int depth, int lightSky, int lightBlock, int irisBlockMaterialId)
{
- LodUtil.assertTrue(height >= 0 && height < MAX_WORLD_Y_SIZE, "Trying to create datapoint with height[" + height + "] out of range!");
- LodUtil.assertTrue(depth >= 0 && depth < MAX_WORLD_Y_SIZE, "Trying to create datapoint with depth[" + depth + "] out of range!");
+ if (RUN_VALIDATION)
+ {
+ // assertions are inside if-blocks to prevent unnecessary string concatenations
+ if (height < 0 || height >= MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with height[" + height + "] out of range!");
+ }
+ if (depth < 0 || depth >= MAX_WORLD_Y_SIZE)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with depth[" + depth + "] out of range!");
+ }
+
+ if (lightSky < 0 || lightSky >= 16)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with lightSky[" + lightSky + "] out of range!");
+ }
+ if (lightBlock < 0 || lightBlock >= 16)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with lightBlock[" + lightBlock + "] out of range!");
+ }
+
+ if (irisBlockMaterialId < 0 || irisBlockMaterialId >= 256)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with irisBlockMaterialId[" + irisBlockMaterialId + "] out of range!");
+ }
+
+ if (alpha < 0 || alpha >= 256)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with alpha[" + alpha + "] out of range!");
+ }
+ if (red < 0 || red >= 256)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with red[" + red + "] out of range!");
+ }
+ if (green < 0 || green >= 256)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with green[" + green + "] out of range!");
+ }
+ if (blue < 0 || blue >= 256)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with blue[" + blue + "] out of range!");
+ }
+
+
+ if (depth > height)
+ {
+ LodUtil.assertNotReach("Trying to create datapoint with depth[" + depth + "] greater than height[" + height + "]!");
+ }
+ }
- LodUtil.assertTrue(lightSky >= 0 && lightSky < 16, "Trying to create datapoint with lightSky[" + lightSky + "] out of range!");
- LodUtil.assertTrue(lightBlock >= 0 && lightBlock < 16, "Trying to create datapoint with lightBlock[" + lightBlock + "] out of range!");
-
- LodUtil.assertTrue(irisBlockMaterialId >= 0 && irisBlockMaterialId < 256, "Trying to create datapoint with irisBlockMaterialId[" + irisBlockMaterialId + "] out of range!");
-
- LodUtil.assertTrue(alpha >= 0 && alpha < 256, "Trying to create datapoint with alpha[" + alpha + "] out of range!");
- LodUtil.assertTrue(red >= 0 && red < 256, "Trying to create datapoint with red[" + red + "] out of range!");
- LodUtil.assertTrue(green >= 0 && green < 256, "Trying to create datapoint with green[" + green + "] out of range!");
- LodUtil.assertTrue(blue >= 0 && blue < 256, "Trying to create datapoint with blue[" + blue + "] out of range!");
-
- LodUtil.assertTrue(depth <= height, "Trying to create datapoint with depth[" + depth + "] greater than height[" + height + "]!");
long out = (long) (alpha >>> ALPHA_DOWNSIZE_SHIFT) << ALPHA_SHIFT
| (red & RED_MASK) << RED_SHIFT
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java
index 1b4dc969b..49b67e736 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java
@@ -143,7 +143,10 @@ public class QuadTree
topQuadNode = new QuadNode(rootPos, this.treeMaxDetailLevel);
boolean successfullyAdded = this.topRingList.set(ringListPosX, ringListPosZ, topQuadNode);
- LodUtil.assertTrue(successfullyAdded, "Failed to add top quadTree node at position: " + rootPos);
+ if (!successfullyAdded)
+ {
+ LodUtil.assertNotReach("Failed to add top quadTree node at position: " + rootPos);
+ }
}
if (!topQuadNode.sectionPos.contains(pos))
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java b/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java
index 275d606ea..2f31238ac 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java
@@ -90,7 +90,10 @@ public class DhClientServerWorld extends AbstractDhWorld implements IDhClientWor
IClientLevelWrapper clientLevelWrapper = (IClientLevelWrapper) levelWrapper;
IServerLevelWrapper serverLevelWrapper = clientLevelWrapper.tryGetServerSideWrapper();
LodUtil.assertTrue(serverLevelWrapper != null);
- LodUtil.assertTrue(clientLevelWrapper.getDimensionType().equals(serverLevelWrapper.getDimensionType()), "tryGetServerSideWrapper returned a level for a different dimension. ClientLevelWrapper dim: " + clientLevelWrapper.getDimensionType().getDimensionName() + " ServerLevelWrapper dim: " + serverLevelWrapper.getDimensionType().getDimensionName());
+ if (!clientLevelWrapper.getDimensionType().equals(serverLevelWrapper.getDimensionType()))
+ {
+ LodUtil.assertNotReach("tryGetServerSideWrapper returned a level for a different dimension. ClientLevelWrapper dim: " + clientLevelWrapper.getDimensionType().getDimensionName() + " ServerLevelWrapper dim: " + serverLevelWrapper.getDimensionType().getDimensionName());
+ }
DhClientServerLevel level = this.levelWrapperByDhLevel.get(serverLevelWrapper);