diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java index 024eb7345..1ce14c48e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java @@ -136,15 +136,8 @@ public class FullDataSourceProviderV2 this.migrationThreadPool.execute(this::convertLegacyDataSources); // update propagation doesn't need to be run on the server since only the highest detail level is needed - //if (SharedApi.getEnvironment() != EWorldEnvironment.SERVER_ONLY) // TODO - //{ - this.updateQueueProcessor = ThreadUtil.makeSingleThreadPool("Parent Update Queue ["+levelId+"]"); - this.updateQueueProcessor.execute(this::runUpdateQueue); - //} - //else - //{ - // this.updateQueueProcessor = null; - //} + this.updateQueueProcessor = ThreadUtil.makeSingleThreadPool("Parent Update Queue [" + levelId + "]"); + this.updateQueueProcessor.execute(this::runUpdateQueue); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java index 1d106e572..f347086e7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java @@ -20,7 +20,6 @@ package com.seibel.distanthorizons.core.file.fullDatafile; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; -import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.file.structure.ISaveStructure; @@ -36,7 +35,6 @@ import com.seibel.distanthorizons.core.render.renderer.DebugRenderer; import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil; -import com.seibel.distanthorizons.core.world.EWorldEnvironment; import com.seibel.distanthorizons.coreapi.util.BitShiftUtil; import it.unimi.dsi.fastutil.longs.LongArrayList; import org.apache.logging.log4j.Logger; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/RemoteFullDataSourceProvider.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/RemoteFullDataSourceProvider.java index c251fdcfd..48c2f4e8f 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/RemoteFullDataSourceProvider.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/RemoteFullDataSourceProvider.java @@ -91,32 +91,6 @@ public class RemoteFullDataSourceProvider extends GeneratedFullDataSourceProvide // from server // //===========================// - // TODO - //// get the timestamp for every maximum detail position in this section - //int posToMinimumDetailScale = BitShiftUtil.powerOfTwo(DhSectionPos.getDetailLevel(pos) - DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL); - //Map timestamps = this.getTimestampsForRange( - // DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL, - // DhSectionPos.getX(pos) * posToMinimumDetailScale, - // DhSectionPos.getZ(pos) * posToMinimumDetailScale, - // (DhSectionPos.getX(pos) + 1) * posToMinimumDetailScale, - // (DhSectionPos.getZ(pos) + 1) * posToMinimumDetailScale - //); - // - //DhSectionPos.forEachChildAtDetailLevel(pos, DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL, childPos -> - //{ - // if (!this.visitedPositions.add(childPos)) - // { - // return; - // } - // - // // check if the server has newer versions of these LODs - // Long subTimestamp = timestamps.get(childPos); - // if (subTimestamp != null) - // { - // this.syncOnLoadRequestQueue.submitRequest(childPos, subTimestamp, this.delayedFullDataSourceSaveCache::queueDataSourceForUpdateAndSave); - // } - //}); - Long timestamp = this.getTimestampForPos(pos); if (timestamp != null) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java index 0d8cf3b26..13f89c920 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java @@ -147,7 +147,6 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb // Assert that the data at least can fill in 1 single ChunkSizedFullDataAccessor LodUtil.assertTrue(DhSectionPos.getDetailLevel(pos) > requiredDataDetail + LodUtil.CHUNK_DETAIL_LEVEL); - LOGGER.info("queueing gen ["+DhSectionPos.toString(pos)+"]"); CompletableFuture future = new CompletableFuture<>(); this.waitingTasks.put(pos, new WorldGenTask(pos, requiredDataDetail, tracker, future)); @@ -287,8 +286,6 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb { //LOGGER.trace("Unable to start task: "+closestTask.pos+", skipping. Task position may have already been generated."); } - - //LOGGER.info("started gen ["+DhSectionPos.toString(closestTask.pos)+"]"); } else { @@ -325,8 +322,6 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb // send the child futures to the future recipient, to notify them of the new tasks closestTask.future.complete(WorldGenResult.CreateSplit(childFutures)); - //LOGGER.info("split ["+DhSectionPos.toString(sectionPos)+"]"); - // return true so we attempt to generate again return true; } @@ -484,8 +479,8 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb // getters / setters // //===================// - public int getWaitingTaskCount() { return this.waitingTasks.size(); } - public int getInProgressTaskCount() { return this.inProgressGenTasksByLodPos.size(); } + @Override public int getWaitingTaskCount() { return this.waitingTasks.size(); } + @Override public int getInProgressTaskCount() { return this.inProgressGenTasksByLodPos.size(); } @Override public byte lowestDataDetail() { return this.lowestDataDetail; } @@ -497,7 +492,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb @Override public void setEstimatedTotalTaskCount(int newEstimate) { this.estimatedTotalTaskCount = newEstimate; } - public void addDebugMenuStringsToList(List messageList) { } + @Override public void addDebugMenuStringsToList(List messageList) { } @@ -505,7 +500,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb // shutdown // //==========// - public CompletableFuture startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning) + @Override public CompletableFuture startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning) { LOGGER.info("Closing world gen queue"); this.queueingThread.shutdownNow(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhServerLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhServerLevel.java index 3cab0e086..c49b3b113 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhServerLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhServerLevel.java @@ -144,8 +144,6 @@ public abstract class AbstractDhServerLevel extends AbstractDhLevel implements I ServerPlayerState.RateLimiterSet rateLimiterSet = serverPlayerState.getRateLimiterSet(this); - LOGGER.info("received message ["+DhSectionPos.toString(message.sectionPos)+"]"); - if (message.clientTimestamp == null) { if (distanceFromPlayer > Config.Server.maxGenerationRequestDistance.get()) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/AbstractFullDataNetworkRequestQueue.java b/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/AbstractFullDataNetworkRequestQueue.java index e3df80701..daf7881bd 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/AbstractFullDataNetworkRequestQueue.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/AbstractFullDataNetworkRequestQueue.java @@ -111,8 +111,6 @@ public abstract class AbstractFullDataNetworkRequestQueue implements IDebugRende { return this.submitRequest(sectionPos, null, dataSourceConsumer); } public CompletableFuture submitRequest(long sectionPos, @Nullable Long clientTimestamp, Consumer dataSourceConsumer) { - //LodUtil.assertTrue(DhSectionPos.getDetailLevel(sectionPos) == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL, "Only highest-detail sections are allowed."); - AtomicBoolean added = new AtomicBoolean(false); RequestQueueEntry entry = this.waitingTasksBySectionPos.compute(sectionPos, (k, existingQueueEntry) -> { @@ -180,8 +178,7 @@ public abstract class AbstractFullDataNetworkRequestQueue implements IDebugRende } private void sendNextRequest(DhBlockPos2D targetPos) { - Map.Entry mapEntry = this.waitingTasksBySectionPos - .entrySet().stream() + Map.Entry mapEntry = this.waitingTasksBySectionPos.entrySet().stream() .filter(task -> task.getValue().networkDataSourceFuture == null) .min(Comparator.comparingInt(x -> DhSectionPos.getChebyshevSignedBlockDistance(x.getKey(), targetPos))) .orElse(null); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/server/DataSourceRequestGroup.java b/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/server/DataSourceRequestGroup.java index e183b1437..fbe415d33 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/server/DataSourceRequestGroup.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/server/DataSourceRequestGroup.java @@ -68,7 +68,7 @@ class DataSourceRequestGroup } - public RequestData tryRemoveRequest(long requestId, HangingRequestTransferConsumer hangingRequestTransferConsumer) + public RequestData tryRemoveRequest(long requestId, IHangingRequestTransferConsumer hangingRequestTransferConsumer) { RequestData removed = this.requestMessages.remove(requestId); @@ -104,6 +104,6 @@ class DataSourceRequestGroup * This is a workaround that allows the caller to transfer these requests to a new group. */ @FunctionalInterface - interface HangingRequestTransferConsumer extends Consumer> { } + interface IHangingRequestTransferConsumer extends Consumer> { } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java index 033bb9ddb..64bf74423 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java @@ -275,28 +275,6 @@ public class DhSectionPos ) - getBlockWidth(pos) / 2; } - public static int signedDistance(long pos, DhBlockPos2D blockPos) - { - // Assuming Square2D has a method to get its center and size - double halfWidth = getBlockWidth(pos) / 2.0; - - // Calculate the distance from the point to the center of the square - double dx = blockPos.x - getCenterBlockPosX(pos); - double dy = blockPos.z - getCenterBlockPosZ(pos); - - // Calculate the horizontal and vertical distances to the edges of the square - double distanceX = Math.abs(dx) - halfWidth; - double distanceY = Math.abs(dy) - halfWidth; - - // The signed distance is the max of distanceX and distanceY - // This gives us the distance to the nearest edge - // If both distances are negative, the point is inside the square - double signedDistance = Math.max(distanceX, distanceY); - - return (int) signedDistance; // Cast to int, as per function signature - } - - //==================// diff --git a/core/src/main/java/com/seibel/distanthorizons/core/pos/blockPos/DhBlockPos2D.java b/core/src/main/java/com/seibel/distanthorizons/core/pos/blockPos/DhBlockPos2D.java index 13728ba81..82cd2d397 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/pos/blockPos/DhBlockPos2D.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/pos/blockPos/DhBlockPos2D.java @@ -75,7 +75,6 @@ public class DhBlockPos2D public long distSquared(DhBlockPos2D other) { return this.distSquared(other.x, other.z); } public long distSquared(int x, int z) { return MathUtil.pow2((long) this.x - x) + MathUtil.pow2((long) this.z - z); } - public long chebyshevDist(DhBlockPos2D other) { return Math.max(Math.abs(this.x - other.x), Math.abs(this.z - other.z)); } //===========// 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 01987440d..ebd8257d9 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 @@ -475,6 +475,12 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable // queue from last to first to prevent shifting the array unnecessarily for (int i = this.missingGenerationPos.size() - 1; i >= 0; i--) { + if (!this.fullDataSourceProvider.canQueueRetrieval()) + { + // the data source provider isn't accepting any more jobs + break; + } + long pos = this.missingGenerationPos.removeLong(i); boolean positionQueued = (this.fullDataSourceProvider.queuePositionForRetrieval(pos, false) != null); if (!positionQueued)