diff --git a/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java b/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java index e5862714d..b85349d2f 100644 --- a/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java +++ b/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java @@ -469,7 +469,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile // wait for the tracker to be garbage collected(?) while (phantom != null) { - LOGGER.info("Full Data at pos: "+phantom.pos+" has been freed. "+lifeCycleDebugSet.size()+" Full Data files remaining."); + //LOGGER.info("Full Data at pos: "+phantom.pos+" has been freed. "+lifeCycleDebugSet.size()+" Full Data files remaining."); phantom.close(); phantom = (DataObjTracker) lifeCycleDebugQueue.poll(); } 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 559fad90e..0ab91b0f2 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 @@ -82,10 +82,17 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler // confirm the quad tree has at least one node in it LodUtil.assertTrue(!missingPositions.isEmpty() || !existingFiles.isEmpty()); + // determine the type of dataSource that should be used for this position - IIncompleteFullDataSource dataSource = pos.sectionDetailLevel <= SparseFullDataSource.MAX_SECTION_DETAIL ? - SparseFullDataSource.createEmpty(pos) : - SingleChunkFullDataSource.createEmpty(pos); + IIncompleteFullDataSource incompleteFullDataSource; + if (pos.sectionDetailLevel <= SparseFullDataSource.MAX_SECTION_DETAIL) + { + incompleteFullDataSource = SparseFullDataSource.createEmpty(pos); + } + else + { + incompleteFullDataSource = SingleChunkFullDataSource.createEmpty(pos); + } if (missingPositions.size() == 1 && existingFiles.isEmpty() && missingPositions.get(0).equals(pos)) @@ -96,13 +103,13 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler if (worldGenQueue != null) { // queue this section to be generated - GenTask genTask = new GenTask(pos, new WeakReference<>(dataSource)); - worldGenQueue.submitGenTask(dataSource.getSectionPos().getSectionBBoxPos(), dataSource.getDataDetail(), genTask) + GenTask genTask = new GenTask(pos, new WeakReference<>(incompleteFullDataSource)); + worldGenQueue.submitGenTask(incompleteFullDataSource.getSectionPos().getSectionBBoxPos(), incompleteFullDataSource.getDataDetail(), genTask) .whenComplete((genTaskCompleted, ex) -> this.onWorldGenTaskComplete(genTaskCompleted, ex, genTask, pos)); } // return the empty dataSource (it will be populated later) - return CompletableFuture.completedFuture(dataSource); + return CompletableFuture.completedFuture(incompleteFullDataSource); } else { @@ -121,23 +128,24 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler LOGGER.debug("Creating {} from sampling {} files: {}", pos, existingFiles.size(), existingFiles); // read in the existing data - final ArrayList> futures = new ArrayList<>(existingFiles.size()); + final ArrayList> loadDataFutures = new ArrayList<>(existingFiles.size()); for (FullDataMetaFile existingFile : existingFiles) { - futures.add(existingFile.loadOrGetCachedAsync() + loadDataFutures.add(existingFile.loadOrGetCachedAsync() .exceptionally((ex) -> /*Ignore file read errors*/null) .thenAccept((data) -> { if (data != null) { //LOGGER.info("Merging data from {} into {}", data.getSectionPos(), pos); - dataSource.sampleFrom(data); + incompleteFullDataSource.sampleFrom(data); } }) ); } - return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) - .thenApply((voidValue) -> dataSource.trySelfPromote()); + + return CompletableFuture.allOf(loadDataFutures.toArray(new CompletableFuture[0])) + .thenApply((voidValue) -> incompleteFullDataSource.trySelfPromote()); } } diff --git a/core/src/main/java/com/seibel/lod/core/util/gridList/MovableGridRingList.java b/core/src/main/java/com/seibel/lod/core/util/gridList/MovableGridRingList.java index f780cc466..5311b590a 100644 --- a/core/src/main/java/com/seibel/lod/core/util/gridList/MovableGridRingList.java +++ b/core/src/main/java/com/seibel/lod/core/util/gridList/MovableGridRingList.java @@ -186,19 +186,19 @@ public class MovableGridRingList extends ArrayList implements List /** see {@link MovableGridRingList#clear(Consumer)} for full documentation */ @Override public void clear() { this.clear(null); } - /** @param consumer the consumer run on each item before it is removed from the list */ - public void clear(Consumer consumer) + /** @param removedItemConsumer the consumer run on each item before it is removed from the list */ + public void clear(Consumer removedItemConsumer) { this.moveLock.writeLock().lock(); try { - if (consumer != null) + if (removedItemConsumer != null) { super.forEach((item) -> { if (item != null) { - consumer.accept(item); + removedItemConsumer.accept(item); } }); } @@ -222,7 +222,7 @@ public class MovableGridRingList extends ArrayList implements List /** see {@link MovableGridRingList#moveTo(int, int, Consumer)} for full documentation */ public boolean moveTo(int newCenterX, int newCenterY) { return this.moveTo(newCenterX, newCenterY, null); } /** Returns true if the grid was successfully moved, false otherwise */ - public boolean moveTo(int newCenterX, int newCenterY, Consumer consumer) + public boolean moveTo(int newCenterX, int newCenterY, Consumer removedItemConsumer) { Pos2D cPos = this.minPosRef.get(); int newMinX = newCenterX - this.halfSize; @@ -248,7 +248,7 @@ public class MovableGridRingList extends ArrayList implements List // and update the pos if (Math.abs(deltaX) >= this.size || Math.abs(deltaY) >= this.size) { - this.clear(consumer); + this.clear(removedItemConsumer); } else { @@ -262,9 +262,9 @@ public class MovableGridRingList extends ArrayList implements List || y - deltaY >= this.size) { T item = this._swapUnsafe(x+cPos.x, y+cPos.y, null); - if (item != null && consumer != null) + if (item != null && removedItemConsumer != null) { - consumer.accept(item); + removedItemConsumer.accept(item); } } }