Clean up
This commit is contained in:
+2
-9
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
-2
@@ -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;
|
||||
|
||||
-26
@@ -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<Long, Long> 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)
|
||||
{
|
||||
|
||||
+4
-9
@@ -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<WorldGenResult> 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<String> messageList) { }
|
||||
@Override public void addDebugMenuStringsToList(List<String> messageList) { }
|
||||
|
||||
|
||||
|
||||
@@ -505,7 +500,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
||||
// shutdown //
|
||||
//==========//
|
||||
|
||||
public CompletableFuture<Void> startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning)
|
||||
@Override public CompletableFuture<Void> startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning)
|
||||
{
|
||||
LOGGER.info("Closing world gen queue");
|
||||
this.queueingThread.shutdownNow();
|
||||
|
||||
@@ -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())
|
||||
|
||||
+1
-4
@@ -111,8 +111,6 @@ public abstract class AbstractFullDataNetworkRequestQueue implements IDebugRende
|
||||
{ return this.submitRequest(sectionPos, null, dataSourceConsumer); }
|
||||
public CompletableFuture<RequestResult> submitRequest(long sectionPos, @Nullable Long clientTimestamp, Consumer<FullDataSourceV2> 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<Long, RequestQueueEntry> mapEntry = this.waitingTasksBySectionPos
|
||||
.entrySet().stream()
|
||||
Map.Entry<Long, RequestQueueEntry> mapEntry = this.waitingTasksBySectionPos.entrySet().stream()
|
||||
.filter(task -> task.getValue().networkDataSourceFuture == null)
|
||||
.min(Comparator.comparingInt(x -> DhSectionPos.getChebyshevSignedBlockDistance(x.getKey(), targetPos)))
|
||||
.orElse(null);
|
||||
|
||||
+2
-2
@@ -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<Collection<RequestData>> { }
|
||||
interface IHangingRequestTransferConsumer extends Consumer<Collection<RequestData>> { }
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//==================//
|
||||
|
||||
@@ -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)); }
|
||||
|
||||
|
||||
//===========//
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user