From 0e6f294ad74ab9400273aa63e788ecb8ba1a28e6 Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Sun, 11 Jun 2023 20:42:07 +0800 Subject: [PATCH] no longer gen stuff that is explored by players again --- .../HighDetailIncompleteFullDataSource.java | 10 ++++++++-- .../LowDetailIncompleteFullDataSource.java | 13 ++++++++---- .../interfaces/IIncompleteFullDataSource.java | 3 ++- .../GeneratedFullDataFileHandler.java | 20 +++++++++++++++++-- .../core/generation/WorldGenerationQueue.java | 4 ++-- .../core/generation/tasks/WorldGenTask.java | 5 ++++- 6 files changed, 43 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java b/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java index c706a9dc2..6d244bb07 100644 --- a/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java +++ b/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java @@ -65,6 +65,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo public final int dataPointsPerSection; public boolean isEmpty = true; public EDhApiWorldGenerationStep worldGenStep = EDhApiWorldGenerationStep.EMPTY; + private boolean isPromoted = false; @@ -614,10 +615,15 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo return this; } } - + isPromoted = true; CompleteFullDataSource fullDataSource = CompleteFullDataSource.createEmpty(this.sectionPos); this.applyToFullDataSource(fullDataSource); return fullDataSource; } - + + @Override + public boolean hasBeenPromoted() { + return isPromoted; + } + } diff --git a/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java b/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java index 832ab2866..9758951c6 100644 --- a/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java +++ b/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java @@ -52,6 +52,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp private boolean isEmpty = true; public EDhApiWorldGenerationStep worldGenStep = EDhApiWorldGenerationStep.EMPTY; + private boolean isPromoted = false; @@ -514,12 +515,16 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp { return this; } - + isPromoted = true; return new CompleteFullDataSource(this.sectionPos, this.mapping, this.dataArrays); } - - - + + @Override + public boolean hasBeenPromoted() { + return isPromoted; + } + + //================// // helper classes // //================// diff --git a/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/interfaces/IIncompleteFullDataSource.java b/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/interfaces/IIncompleteFullDataSource.java index 074302530..427236c42 100644 --- a/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/interfaces/IIncompleteFullDataSource.java +++ b/core/src/main/java/com/seibel/lod/core/dataObjects/fullData/sources/interfaces/IIncompleteFullDataSource.java @@ -17,5 +17,6 @@ public interface IIncompleteFullDataSource extends IFullDataSource * @return a new {@link CompleteFullDataSource} if successful, this if the promotion failed, . */ IFullDataSource tryPromotingToCompleteDataSource(); - + + boolean hasBeenPromoted(); } diff --git a/core/src/main/java/com/seibel/lod/core/file/fullDatafile/GeneratedFullDataFileHandler.java b/core/src/main/java/com/seibel/lod/core/file/fullDatafile/GeneratedFullDataFileHandler.java index c801e313c..3a67b2e16 100644 --- a/core/src/main/java/com/seibel/lod/core/file/fullDatafile/GeneratedFullDataFileHandler.java +++ b/core/src/main/java/com/seibel/lod/core/file/fullDatafile/GeneratedFullDataFileHandler.java @@ -1,10 +1,12 @@ package com.seibel.lod.core.file.fullDatafile; import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor; +import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource; import com.seibel.lod.core.dataObjects.fullData.sources.HighDetailIncompleteFullDataSource; import com.seibel.lod.core.dataObjects.fullData.sources.interfaces.IFullDataSource; import com.seibel.lod.core.dataObjects.fullData.sources.interfaces.IIncompleteFullDataSource; import com.seibel.lod.core.dataObjects.fullData.sources.LowDetailIncompleteFullDataSource; +import com.seibel.lod.core.file.metaData.BaseMetaData; import com.seibel.lod.core.generation.tasks.IWorldGenTaskTracker; import com.seibel.lod.core.generation.WorldGenerationQueue; import com.seibel.lod.core.generation.tasks.WorldGenResult; @@ -21,6 +23,7 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import java.util.function.Function; public class GeneratedFullDataFileHandler extends FullDataFileHandler { @@ -173,7 +176,17 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler .thenApply((voidValue) -> incompleteFullDataSource.tryPromotingToCompleteDataSource()); } } - + +/* @Override + public CompletableFuture onDataFileRefresh(IFullDataSource source, BaseMetaData metaData, Function updater, Consumer onUpdated) + { + return super.onDataFileRefresh(source, metaData, updater, (IFullDataSource d) -> { + if (d instanceof CompleteFullDataSource) { + + } + } + }*/ + /** * Checks if the given {@link IFullDataSource} is fully generated and * if it isn't, creates the necessary world gen request(s) to finish it.
@@ -351,7 +364,10 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler @Override - public boolean isMemoryAddressValid() { return this.targetFullDataSourceRef.get() != null; } + public boolean isMemoryAddressValid() { + IFullDataSource ref = this.targetFullDataSourceRef.get(); + return ref != null && !((IIncompleteFullDataSource)ref).hasBeenPromoted(); + } @Override public Consumer getOnGenTaskCompleteConsumer() diff --git a/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java b/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java index aefc995d1..3421b83ea 100644 --- a/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java +++ b/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java @@ -272,9 +272,9 @@ public class WorldGenerationQueue implements Closeable, IDebugRenderable { CheckingTasks.add(newGenTask); // TODO this isn't a long term fix, in the long term the tree should automatically remove out of bound nodes when moved - if (!this.waitingTaskQuadTree.isSectionPosInBounds(taskSectionPos)) + if (!this.waitingTaskQuadTree.isSectionPosInBounds(taskSectionPos) || !newGenTask.StillValid()) { - // skip and remove out-of-bound tasks + // skip and remove out-of-bound tasks or tasks that are no longer valid taskNode.value = null; continue; } diff --git a/core/src/main/java/com/seibel/lod/core/generation/tasks/WorldGenTask.java b/core/src/main/java/com/seibel/lod/core/generation/tasks/WorldGenTask.java index 812aab9b5..4e33f5b90 100644 --- a/core/src/main/java/com/seibel/lod/core/generation/tasks/WorldGenTask.java +++ b/core/src/main/java/com/seibel/lod/core/generation/tasks/WorldGenTask.java @@ -25,5 +25,8 @@ public final class WorldGenTask this.taskTracker = taskTracker; this.future = future; } - + + public boolean StillValid() { + return taskTracker.isMemoryAddressValid(); + } }