no longer gen stuff that is explored by players again

This commit is contained in:
TomTheFurry
2023-06-11 20:42:07 +08:00
parent 25ba274a36
commit 0e6f294ad7
6 changed files with 43 additions and 12 deletions
@@ -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;
}
}
@@ -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 //
//================//
@@ -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();
}
@@ -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<IFullDataSource> onDataFileRefresh(IFullDataSource source, BaseMetaData metaData, Function<IFullDataSource, Boolean> updater, Consumer<IFullDataSource> 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. <br>
@@ -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<ChunkSizedFullDataAccessor> getOnGenTaskCompleteConsumer()
@@ -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;
}
@@ -25,5 +25,8 @@ public final class WorldGenTask
this.taskTracker = taskTracker;
this.future = future;
}
public boolean StillValid() {
return taskTracker.isMemoryAddressValid();
}
}